Using the WsContract just to use the namespace - HodStudio/XitSoap GitHub Wiki

Sometimes, you just have to call one address, but with several namespaces. In this cases, you can use the WebService informing the base address and use the WsContract only to differ the namespace to use. In the following example, we are using the WsContract, but we didn't register it on the ServiceCatalog.

[WsContract("UsZipContract", "http://www.webserviceX.NET")]
public class CityZipSearch

//Same Contract, Different namespaces (case sensitive)
[WsContract("UsZipContract", "http://www.webservicex.net")]
public class CityZipAdd

We create the WebService using the base address, but let the namespace without information. When the Invoke method is called, he will resolve the correct namespace dynamically, based on the WsContract for each class.

var wsCon = new WebService("http://www.webservicex.net/uszip.asmx");
var citySearch = wsCon.Invoke<CityZipSearch>("GetInfoByZIP");
var cityAdd = wsCon.Invoke<CityZipAdd>("AddCity");
⚠️ **GitHub.com Fallback** ⚠️