Question

I post this questions after lot of time reading different messages about WCF.

I have developed a WFC service that is working at an specific location.

I have developed a vb.net app that consum the WCF service mentioned. It works fine.

I have now a new choice. How can I change from the app the address of the service?. I mean, suppose the service is located at IP a.b.c.d, and now has changed to e.f.d.r. How can I change this on the app?. Should I modify the app.config of the app in execution time? should be possible? Isn't another way to change the address?

A piece of the app.config I'm using on the app is the following:

< bindings>
    < basicHttpBinding>
        < binding name="BasicHttpBinding_IWCF_ServicioWeb" />
    < /basicHttpBinding>
< /bindings>
< client>
    < endpoint address="http://localhost:49311/WCF_ServicioWeb.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCF_ServicioWeb"
        contract="MiServicioWeb.IWCF_ServicioWeb" name="BasicHttpBinding_IWCF_ServicioWeb" />
< /client>

I hope someone could help me...

Was it helpful?

Solution

Just add an ApplicationSettings entry to your config file

    <MyApp.Properties.Settings>
        <setting name="MyServiceUrl" serializeAs="String">
            <value>http://a.b.com/ServicioWeb.svc</value>
        </setting>
    </MyApp.Properties.Settings>

Now, every time you need to call the service write

Using wcf = New ServicioClient("BasicHttpBinding_IWCF_ServicioWeb", 
       New EndpointAddress(YourAppNameSpace.Properties.Settings.Default.MyServiceUrl))

       .... call your wcf methods ....
End Using

OTHER TIPS

I see that you are using basicHttpBinding. If you are not using either Transport or Message security and certificate validation is not an issue then it's just a matter of changing the Endpoint Address both on the service (server) and in the client application that is consuming the WCF service.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top