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

15,272

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

Share:
15,272
CB4
Author by

CB4

Updated on June 09, 2022

Comments

  • CB4
    CB4 almost 2 years

    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?

    • praty
      praty over 6 years
      You can always trace and write a SOAP request/response. Check this link: stackoverflow.com/questions/461744/…. If you only wish to check and not log or write it, I would recommend use Fiddler.
  • David
    David over 2 years
    What is "request" ?