Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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, however 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?

like image 947
Jackhammer Avatar asked Aug 24 '11 08:08

Jackhammer


People also ask

What is SOAP request and response?

CIC uses a request/response model to process SOAP requests. This mechanism should be familiar to anyone who has used a web browser. A client (e.g. web browser) connects to a server and passes a request (fetch a web page). The client then waits for the server to respond.

How do you trace a SOAP request and response?

In SOAP web service, each HTTP request or response encapsulates a SOAP envelope, these messages are easy to trace by using Eclipse IDE, build-in “TCP/IP monitor” tool. The idea is host another server in between the client and server to perform port forward function to intercept the HTTP traffic.

What is a SOAP log?

The SOAP Response log displays information on a SOAP response that your virtual API (virtual service) sent to the client. To view this data, simply select the needed response on the Transaction Log page: Click the image to enlarge it.


2 Answers

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.

like image 153
Ladislav Mrnka Avatar answered Oct 06 '22 18:10

Ladislav Mrnka


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.

like image 23
baur Avatar answered Oct 06 '22 16:10

baur