1

I am consuming a SOAP web service from .NET code, by adding a reference to the service. Now the service wsdl endpoint might change in the future, so I want to add it to the config file in order to make my app more dynamic. Now I won't be able to use added reference anymore so I want to call the service from code without using service reference. I cannot create a ChannelFacotry as I do not have the interface type for the service as it is not WCF. So I cannot use something like this:

BasicHttpBinding binding = new BasicHttpBinding("MyBinding");
EndpointAddress address = new EndpointAddress(baseUrl);

ChannelFactory factory = new ChannelFactory<IService>(binding, address);

Is there any way I can consume SOAP web service without adding a service reference. And if not at all, is there any way for me to update the url of the ServiceReference dynamically from code?

Coding Duchess
  • 6,445
  • 20
  • 113
  • 209
  • 1
    http://stackoverflow.com/questions/125399/how-can-i-dynamically-switch-web-service-addresses-in-net-without-a-recompile – stuartd Nov 15 '16 at 17:39

1 Answers1

-1

why not just add it as a "web reference" instead of a service reference.

  1. From the solution explorer right click and add Service references
  2. Click advanced on the lower left
  3. Click "Add Web Reference" in the lower left.

Then add you web reference. Once the reference is added to your project. Right click on the new reference and show the properties. Select "URL Behavior" as Dynamic.

This will allow you to change the url in the future if the web service moves.

Fran
  • 6,440
  • 1
  • 23
  • 35