2010-06-08 55 views

回答

5

只需设置对象的Url属性调用任何的服务方法之前:

YourService service = new YourService(); 
service.Url = "http://some.other.url/"; 

// Now you're ready to call your service method 
service.SomeUsefulMethod(); 
2
YourWebService service = new YourWebService(); 
service.Url = "http://www.example.com/YourWebService.asmx"; 
service.CallMethod(); 
6

我本来upvoted其他的答案中的一个 - 他们几乎是正确的。

using (YourService service = new YourService()) 
{ 
    service.Url = "http://some.other.url/"; 

    // Now you're ready to call your service method 
    service.SomeUsefulMethod(); 
} 

如果未使用使用块,并抛出异常,则可能会泄露网络连接等资源。

相关问题