An alternative way to do SOAP Requests without use the WSDL
In 2015, we face a very simple problem: the automatically generated code by Visual Studio to use webservices has a lot of code smells. Facing this problem, we created a library that generates the SOAP requests based on your models, without code smells in your code.
Install-Package HodStudio.XitSoap
Link: https://www.nuget.org/packages/HodStudio.XitSoap
If you are using the version 1.x from our library, please, read carefully how to upgrade to version 2.x because it is a major refactor to improve some usages. It's nothing complicated, but if you just upgrade from version 1 to version 2, your code will have some problems.
Create an object of WebService, with the base URL and the namespace that will be used.
var wsCon = new WebService("http://www.webservicex.net/ConvertSpeed.asmx", "http://www.webserviceX.NET/");
Add the parameters to execute your call.
wsCon.AddParameter("speed", 100D);
wsCon.AddParameter("FromUnit", "milesPerhour");
wsCon.AddParameter("ToUnit", "kilometersPerhour");
Add the authentication.
wsCon.SetAuthentication(new BearerTokenAuthentication("myBearerToken"));
Invoke the method, providing the return type.
var result = wsCon.Invoke<double>("ConvertSpeed");
For more situations and examples, please, take a look on our Documentation on the Wiki.
To see the planned new features, take a look on our RoadMap.
To run the tests, we provide a mock project Web. It should be runned on http://localhost/XitSoap so the tests can try to connect to it. Some of the tests are runned against published web services on the internet. In case you are not connected to the internet, they will fail.