-
-
Notifications
You must be signed in to change notification settings - Fork 3
Using the WsContract just to use the namespace
Cussa Mitre edited this page Sep 2, 2017
·
3 revisions
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");
- Home
- Migrating from v1 to v2
- Referencing the Library
- Make a simple call
- Adding Parameters
- Adding Authentication
- Adding Custom Headers
- Calling a web method without use a typed return
- Using the WsContract and the ServiceCatalog
- Using the WsContract just to use the namespace
- Using the WsMapper: no more ugly properties!
- SoapActionComplement: because sometimes it's necessary even more!