In this post we will learn how to Change web service url at run time dynamically. Consider an example as Magento merchant web service in which each merchant has a service that is hosted on thier own domains.
Merchant 1 service url : http://merchant1.com/WebService1.asmx?WSDL
Merchant 2 service url : http://merchant2.com/WebService1.asmx?WSDL
Now consider we are trying to use the above web services which we will modify the service url at runtime dynamically.
First we added the WSDL reference fro Merchant 1 http://merchant1.com/WebService1.asmx?WSDL now we want to consume the webservice for merchant 2.
The following is the code
Merchant 1.WebService1 mservice = new Merchant 1.WebService1(); mservice.Url = " http://merchant2.com/WebService1.asmx";