-
-
Notifications
You must be signed in to change notification settings - Fork 3
Adding Parameters
Cussa Mitre edited this page Sep 2, 2017
·
4 revisions
It's totally normal that when uses web services, we have to provide some information as input to it.
To work with that, you can add parameters to the WebService object.
The AddParameter method has two parameters: the name of the parameter and the value. It can accept any type of object as the value. If the value provided is a complex type, it will generate the correct Xml to execute the request.
var wsCon = new WebService("http://localhost/XitSoap/ProductService.asmx");
wsCon.AddParameter("Name", "product 01");
var result = wsCon.Invoke<Product>("SearchProduct");
//Creating the parameter to add
var filterClass = new FilterClass() { ProductName = "product 01", Category = 1 };
var wsCon = new WebService("http://localhost/XitSoap/ProductService.asmx");
wsCon.AddParameter("Filter", filterClass);
var result = wsCon.Invoke<Product>("SearchProduct");
1 Parameter. 3 Lines of code. Request done!
- 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!