开发者

Logging service SOAP request and response

I am trying to log the soap request and response messages of a service in C#. I have a ready made soap extension which does all this, how开发者_C百科ever I am having trouble adding it to the service method.

Since I have a service reference added in my VS project and not a web service reference, when i check the reference file for this service, I don't see the method which is doing the invoking of the remote service. All the examples I saw were of adding to a web service, which has a different reference format.

How can I log the soap messages in this case?


Soap extension is only for using ASMX based service or client = Add web reference. Once you used Add service reference you are using WCF client API instead and you cannot use Soap extension. You must create message inspector instead.

If you need message logging only for debugging purpose you can use built in WCF message logging.


There is an another way to see XML SOAP - custom MessageEncoder. The main difference from IDispatchMessageInspector / IClientMessageInspector is that it works on lower level, so it captures original byte content including any malformed xml.

In order to implement tracing using this approach you need to wrap a standard textMessageEncoding with custom message encoder as new binding element and apply that custom binding to endpoint in your config.

Also you can see as example how I did it in my project - wrapping textMessageEncoding, logging encoder, custom binding element and config.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜