11

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?

1
  • 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.
    – praty
    Oct 17, 2017 at 3:03

1 Answer 1

21

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

2
  • What is "request" ?
    – David
    Dec 12, 2021 at 12:56
  • An answer from many years ago, but this was a big help and just what I needed today. Thanks.
    – Jim K
    Aug 8, 2023 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.