以编程方式编辑Web服务的终点

时间:2010-08-19 13:43:32

标签: .net web-services configuration console-application

有没有办法可以通过编程方式更改网络服务的<endpoint address="..." />值?在我的app.config文件中,我有以下代码:

<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>

我希望能够改变

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

address="http://mymachine/WebServices/WebService.asmx"
代码中的

。这可能是.NET中的程序吗?

2 个答案:

答案 0 :(得分:4)

您可以使用类似于以下内容的代码:

将新服务视为新的XXXXXClient service.Endpoint.Address =新的EndpointAddress(myUrl)

答案 1 :(得分:0)

相关问题