How to change the URL that consumes a Webservice?

Asked

Viewed 1,066 times

1

I have a Webservice written in C# and the client application (data collectors).

Collectors consume Webservice to view information in the main comic. On every client I install my Webservice (Data Server) has a different IP.

How can I parameterize client applications (collectors) via code to consume Webservice in a different IP than I used to add Web References?

Is there any way to change via code the IP to fetch the Webservice?

Ex.:

MeuWS objColetar = new MeuWS();
objColetar.URL = novoIP;
objColetar.FuncaoColetar(param1, param2);
  • 1

    Lucio, you checked the Web.Config ? Usually endpoints are registered there.

  • But doesn’t Web.Config only exist in Web applications? My client application is Windowsce, so it should be App.Config, however, I don’t know how to create it.

  • understood, as you had not explained, I thought it was an application that had Web.Config or App.Config... If there is App.Config, they would be there..

  • So, but how do I create this app.config ?

  • So it should be already created, since you have configured the application. Which version of the framework ?

2 answers

1

Try the following:

MeuWS objColetar = new MeuWS();
objColetar.Endpoint.Address = new System.ServiceModel.EndpointAddress(novoIP); // por exemplo, http://129.135.145.177:8080
objColetar.FuncaoColetar(param1, param2);

0

Try this:

ServiceReferenceAbrasfV201.nfseClient wsClient = 
        new ServiceReferenceAbrasfV201.nfseClient("nfseSOAP1", EnderecoWebService);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.