In the current project I need to communicate with third-party web services from .NET. The difficult part is constructing SOAP messages and posting to the server. After googling enough I found by using SoapClient class I can easily construct/send/receive soap message but I think for that I’ve to add references to WSE assemblies and it is kind of obsolete.
Is it the right way to use SoapClient for this scenario or any other better ways there in WCF?
If the service provides a
.wsdlfile, you can have VS generate strongly-typed proxy/wrapper classes for you by adding a service reference (this is done using the command-line toolwsdl.exe). Right-click on your project in Visual Studio and select “Add Service Reference…” and enter the URL of the.wsdlfile. “Add Service Reference…” will generate client classes with methods and strongly-typed request and response types corresponding to the methods defined in the web service definition. The proxies can be configured to allow both synchronous and asynchronous method invocation.See this MSDN article for more details.