开发者

Capture SOAP Envelope (C# WinForm calling .ASMX external vendor service)

I'm calling a third-party vendor's external SSL web service from a .NET 3.5 client (WinForm). The vendor has asked me to send them the Soap Header to verify why things aren't working.

I used WireShark to capture packets, but since the web service is SSL, the packets are encrypted.

Is there a few magic lines of code to add to my C# client to save or display the Soap Envelope either right before I call their web/method or right after? 开发者_C百科


How exactly are you accessing the web service? Are you using WCF or another mechanism?

One way that should always work is to use Fiddler. It basically acts like a proxy, intercepting the calls between your client and the web service (or any HTTP call, really) and then providing you with the contents of the request and response.

From there, you can get the SOAP envelope and send it to the vendor.

If you are using WCF, you could use a custom endpoint behavior to inject a IClientMessageInspector implementation. This implementation would have access to the Message (which is the object representation of the SOAP envelope) instance both before the request is sent to the server (through the BeforeSendRequest method implementation) as well as after you receive the reply (through the AfterReceiveReply method implementation).


In .NET 2.0 I used Web Service Extensions 3.0 and implemented a PolicyAssertion and a SoapFilter. The ProcessMessage function will give you complete access to save/modify the soap header and body.


envelope.Save("c:\\filename.xml");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜