views:

27

answers:

2

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?

+1  A: 

You can use code similar to the following:

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

Hatch