Get SOAP Message before sending it to the WebService in .NET

后端 未结 6 1808
粉色の甜心
粉色の甜心 2020-12-03 05:26

I\'m calling an external HTTPS webservice.

In order to check what is wrong, the owner needs the SOAP request I\'m sending.

I have a web reference and the gen

6条回答
  •  伪装坚强ぢ
    2020-12-03 05:45

    If you work in a more restricted environment and don't have the luxury of using an application like Fiddler, you can do the following:

    1. Generate your web reference as usual.
    2. Write code to perform whatever web method call you're going to me.
    3. Create a new ASP .NET project of your choice, I went with MVC 4.
    4. Create a handler or controller/action, and extract the request stream like this:

    using (var reader = new System.IO.StreamReader(Request.InputStream)) { result = reader.ReadToEnd(); }

    1. Put a breakpoint on it and run it in debug mode.
    2. On your client, set the Url of the SOAP request to your new controller/handler.
    3. Run your client. You should catch the breakpoint on your web app with your SOAP message.

    It's not an ideal or pretty solution, but if you are working in a moderately restricted environment, it gets the job done.

提交回复
热议问题