2010-06-08 83 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(); 
} 

如果未使用使用塊,並拋出異常,則可能會泄露網絡連接等資源。

相關問題