Hi,
I want to invoke an ASP.NET web service via an http POST request using C# (i.e. I don't want to use the SoapHttpClientProtocol object generated by running wsdl.exe).
As far as I can tell, the process involves:
creating an HttpWebRequest object which points to the url/method of the web service, with the method;
Creating a SOAP xml envelope;
Serialising any parameters I want to pass to the web method using an XmlSerializer;
Making the request, and parsing the response.
I would like to do this without having to copy and use generated code.
(1) seems pretty straightforward;
(2) I don't know if the envelope here is standard, or how it should change depending on the webservice method I am calling. I guess I might need to add custom soap headers if required by the service?
(3) What is the process of doing this? I assume that I need to do something like this:
MyClass myObj;
XmlSerializer ser = new XmlSerializer(myObj.GetType());
TextWriter writer = new StringWriter();
ser.Serialize(writer, myObj);
string soapXml = writer.ToString();
writer.Close();
Also, I guess I should add the soapXml to the soap:Body element
(4) I believe I should extract and deserialize the contents of the soap:Body element as well. Is it OK to use the reverse of the process in (3)?
Thanks,
K.