Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the xml representation of the SOAP request message?

I have the WSDL of a SOAP web service and I am consuming it via my MVC application.

From adding the WSDL as a web service to my Visual Studio solution it automatically creates a proxy class for me and it handles all the serialization/destabilization for me which is really awesome for a while. I have been using this proxy class to call/send my SOAP request to the web service (with pure c# code and no XML involves) and I got my response message back and everything is working great.

However, there is a need now for me to find what is the exact xml representation of the SOAP message that I am sending to the web service. How can I get/find/make this?

like image 492
CB4 Avatar asked Oct 17 '17 02:10

CB4


1 Answers

you can do it like this

var serxml = new System.Xml.Serialization.XmlSerializer(request.GetType());
var ms = new MemoryStream();
serxml.Serialize(ms, request);
string xml = Encoding.UTF8.GetString(ms.ToArray());

where xml is your raw SOAP

like image 195
Activex Avatar answered Oct 02 '22 12:10

Activex