Creating a SOAP Envelope programatically and including it in the HttpWebRequest in .NET
-
08-07-2019 - |
Question
I'm involved in a project that would call a webservice dynamically.
I have figured out a way to call a webservice method that has no method parameters on it, but now what I need is for me to call web methods that have parameters on it.
Was wondering if there are good examples on how I could create a soap envelope and how I could include this in my HttpWebRequest?
Thank you so much!
Cheers, Ann
Solution
Is there any reason you want to generate SOAP envelopes manually and use HttpWebRequest to call a web service when you could generate a client proxy from the WSDL (using svcutil.exe or wsdl.exe) and let the framework do the heavy lifting for you?
Normally web services expose a contract that describes the operations you can invoke and the types that are involved allowing clients to discover it and use it.
OTHER TIPS
What about serialization with SoapFormatter?
You can also use strong typed classes by using interfaces and dynamicaly loaded assemblies via
Assembly a = Assembly.LoadFile("Path");
and you'll be able to "hot plug" new proxies or other types.