异步方式是自定义一个类,继承你引用的Webservice类,实现给某个属性赋值
public class MasterService : MasterDataServiceSoapClient
{
public MasterService()
: base()
{
try
{
string uri = string.Format("http://{0}:{1}/{2}", "localhost", "1111", "MasterDataService.asmx");
base.Endpoint.Address = new System.ServiceModel.EndpointAddress(new Uri(uri) { });
}
catch (Exception ex)
{
throw ex;
}
}
}
同步方式,也是继承你引用的Webservice类,重新赋值某个属性
class ServiceProxy : ScanDemo.WS.Service { public ServiceProxy() { ServiceProtocol sp = new ServiceProtocol(); sp.LoadConfigs(); Url = string.Format("http://{0}:{1}/ScanDemo.WS/Service.asmx", sp.Server, sp.Port); } }