Adding Parameters - HodStudio/XitSoap GitHub Wiki

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.

Adding string as parameter

var wsCon = new WebService("http://localhost/XitSoap/ProductService.asmx");
wsCon.AddParameter("Name", "product 01");
var result = wsCon.Invoke<Product>("SearchProduct");

Adding complex types as parameter

//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!

⚠️ **GitHub.com Fallback** ⚠️