Skip to content

Make a simple call

Cussa Mitre edited this page Sep 2, 2017 · 5 revisions

When you just want to do a simple call, this is the easiest approach!

Create the WebService with the url and the namespace (optional). If you don't provide the namespace, the default "http://tempuri.org/" will be used. When call the Invoke method, inform which web method you want and what is the return type.

var wsCon = new WebService("http://localhost/XitSoap/ProductService.asmx");
var result = wsCon.Invoke<Product>("GetProduct");

2 Lines. Request done!

And if I want to provide the namespace, will it take too much effort?

No. The WebService constructor has a overload where you can provide the namespace.

var wsCon = new WebService("http://localhost/XitSoap/ProductService.asmx", "http://tempuri.org/");
var result = wsCon.Invoke<Product>("GetProduct");

Still 2 Lines. Request done!