views:

1957

answers:

3

I have a VB.NET web service that calls a third party web service. How can I view the SOAP message generated by .NET before it is sent to the third party web service and how can I see the SOAP response before it is serialized by .NET.

When creating a standalone EXE, I see the Reference.vb file that is automatically generated, but don't see a similar file when my project is a web service. I have found lots of C# code to do this, but none in VB.NET.

Edit - Fiddler and TCP loggers are great, but will not work for my purposes. I need to be able to access the raw SOAP messages from within the application so I can log them or modify them. I need to do more than just see the messages going back and forth.

+1  A: 

You can use fiddler or a tcp sniffer to filter and identify all outgoing and incoming traffic on your host.

This is if you want to see the xml request and response.

Jobo
I'd like to be able to access the raw SOAP messages from within .NET so I can log them or modify them.
Ari
Fiddler should do the job.
Otávio Décio
Yes get fiddler, with the new .net webservices (WCF) fiddler may not be able to detect the traffic if using tcp communication, so use a tcp sniffer to do the job.
Jobo
A: 

How about using an extension to allow you to examine the SOAP message?

Accessing Raw SOAP Messages in ASP.NET Web Services http://msdn.microsoft.com/en-us/magazine/cc188761.aspx

Fireworks
A: 

I was trying to do the same thing and this seems to work for me:

Dim message As String = OperationContext.Current.RequestContext.RequestMessage.ToString()

I didn't think it would be that easy since most of the time ToString() returns the name of the class, but I tried it out and low and behold.

I know you asked this back in January so if since then you've figured out a better way let me know.

Please note that if you're catching the exception in a class that implements IErrorHandler then you have to perform this operation from within the ProvideFault() method instead of the HandleError() method because the context is closed before it gets to call the HandleError() method.

Hope this helps.

Adam