开发者

Programmatically edit the end point of a web service

Is there a way I can programmatically 开发者_开发知识库change the <endpoint address="..." /> value of a web service? In my app.config file, I have the following code:

<system.serviceModel>
   <bindings>
       ...
   </bindings>
   <client>
     <endpoint address="http://dev.remotedomain.com/WebServices/WebService.asmx"
         binding="basicHttpBinding" bindingConfiguration="InboxServiceSoap"
         contract="InboxServiceSoap"
         name="InboxServiceSoap" />
   </client>
</system.serviceModel>

I want to be able to change

address="http://dev.remotedomain.com/WebServices/WebService.asmx"

to

address="http://mymachine/WebServices/WebService.asmx"

in code. Is this possible progammatically in .NET?


You can use code similar to the following:

Dim service as new XXXXXClient service.Endpoint.Address = New EndpointAddress(myUrl)


See this article for more information: http://geekswithblogs.net/dlanorok/archive/2007/07/18/Dynamic-Configuration-for-WCF-Service-Base-Address.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜