7

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?

CB4
  • 690
  • 3
  • 13
  • 25
  • You can always trace and write a SOAP request/response. Check this link: https://stackoverflow.com/questions/461744/get-soap-message-before-sending-it-to-the-webservice-in-net. If you only wish to check and not log or write it, I would recommend use Fiddler. – praty Oct 17 '17 at 03:03

1 Answers1

17

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

Activex
  • 306
  • 3
  • 9