How to see SOAP data my client application sends? - c#

I have a project where I have created web service proxy classes with wsdl.exe and then simply create an instance of that class (inherits System.Web.Services.Protocols.SoapHttpClientProtocol) and call the method that should send a SOAP message. I'm using Visual Studio 2008 if that matters. And I'm trying this in my development machine without access to actual web service that is located inside of customer's intranet. So, the sending will of course not succeed and I will not get any response back but all I would like to see is the exact content of SOAP messages this solution creates and tries to send. How do I see that?

Use fiddler.

Have a look at SOAPUI from eviware.com.
Its a free for personal use Java app. Among other things you can
set it up to run as a dummy test server. Just load up hte WSDL
and enter the dummy data.
In test server mode it will log your requests so you can see whats happening
inside the request message.

If you're Web service is accessed by clear text, non-SSL HTTP, you can just use a sniffer, like Wireshark, to see the data coming from and to your application. Wireshark can trace, filter and analyze wire data. I have used it do debug HTTP and other protocols many times, and it's a great tool to do this.

SOAP messages are simply XML data sent using the HTTP POST method. So you can for example install a local web server on your development machine, configure your web service to use some dummy URI on this server, and grab the network traffic with WireShark (AKA ethereal). The big advantage of this method is that it involves no coding.
Alternatively you can use an HTTP echo server that dumps its incoming traffic, like this one (found while googling "http echo server"):

You can intercept the call with tcpMon

Related

Add TCP logger to existing windows service without rebuilding

I have a windows service running in a production environment that I need to perform some diagnostic work on. The service listens on a specified port, receives and processes a TCP request, and issues a TCP response.
What I'd like to do is intercept this request and response so I can log it to a database. However I cannot recompile the code and need to make as few changes to the server as possible.
I seem to recall a past instance where a colleague was able to create an interceptor DLL and drop this into the root folder of a WCF or Web API service in order to accomplish a similar task. Would it be possible to accomplish something like that with this TCP service?
As long as the app uses System.Net.Socket, you can use the built in .net network tracing via app.config, docs from Microsoft here.
Adding source System.Net.Socket and System.Net with maxdatasize 1024 will cause it to log the first 1024 bytes of each send and receive.

How to Debug a web service

We have a Win32 application that connects to a third party application to send some info to it. That application has a web service that we call its methods. One of its web methods is called GetDevices and when our application is calling it, it will fail to work and I have no idea what are the details of this failure. So we should write a small diagnosis application that can create some detailed log files to know what is going, send it to them to run it and then we may know what is going on with more detail. Now do you have any ideas what is a good way to write such a diagnosis application for this debugging purpose?
If this web service is using HTTP (either SOAP or REST) you can use Fiddler to snoop the HTTP traffic and see what's happening.
When web requests are made, the request (and response from the server) will show up in Fiddler, and you can use that to determine why it's not doing what you expect.

How to debug soap web services?

If I have a server sitting somewhere that is not returning the correct information to a client that uses async methods to communicate with it, how do I debug this with soap?
I mean, atleast with rest I can just type in a web address inside a browser and see on the screen the xml response. But how is debugging usually done with soap?
Note, my client is c#/wpf and the server is java
Have look at soapUI. I usually use it to develop and debug soap based web services.
As already mentioned soapUI is great tool if you want to test communication manually. If you want to see what exactly happens between your application and the service use Fiddler.

WCF Test Client that allows me to view/edit the request XML

From time to time we need to test why a certain request coming from our MQ to a WCF service failed. I need to be able to debug the service and find out where it went wrong and resolve the issue. The only information i have is the XML request that was sent to the service. Before we moved to WCF i used a custom tool to send the request to my ASMX debug instance but since we moved to WCF I dont seem to have that option. All the clients i have tried only allow you to fill in the fields through a UI and this is not an option when dealing with huge requests.
Is there a free or open source client that will allow me to do this? I have searched and tried loads but none seem to do it.
Alternatively is there a tutorial or article on writing a test client of this kind? Again i have searched but there seems to be a lack of information on WCF clients and a huge amount on the services.
tl;dr; Im looking for a WCF test client that will allow me to paste in an XML request and send it to a WCF service or a tutorial that will start me in the right direction.
Of course it is not free, but one of our teams is using Altova XMLSpy for that purpose and it works fine.
You can also check (Not sure they will allow you to edit SOAP, but have a try):
SoapUI
WCF Storm
Also check Web Service Studio 2.0 I have tried it will allow you to edit requests.
Not sure I totally understand what you're looking for:
to see the MSMQ messages, you should open the MMC snapin for MSMQ administration on your server where the MSMQ queues live - is that what you're looking for?
in order to create and send out arbitrary XML messages, have a look at SoapUI which is available in a free (and already very capable) version, or alternatively look at SoapBits

In C#, how would I capture the SOAP used in a web service call?

I have a C# application that is a client to a web service. One of my requirements is to allow capturing the SOAP that I send, so that if there is a problem, I can either fix the bug, or demonstrate that the problem is in the service I am calling.
My WebReference proxy service class derives from System.Web.Services.Protocols.SoapHttpClientProtocol as usual. If I had a magic wand, I would make this base class implement an event OnPost that I could handle to write the SOAP into my logs and continue.
Short of running a packet sniffer like WireShark, is there an easy way to get this level of logging?
I think what you are looking for is addressed in this question:
Getting RAW Soap Data from a Web Reference Client running in ASP.net
It looks like a lot of code though.
If the application is running on your local box and the web service isn't doing anything funky, you can use Fiddler. Fire Up IE, run Fiddler, and you'll see your web service calls go through fiddler's proxy too.
I just used this this morning to do almost the same thing. I had to prove the data my web service was sending wasn't messed up.
To see this traffic in fiddler use the following code:
mySoapHttpClientProtocol.Url = mySoapHttpClientProtocol.Url.Replace("localhost", "localhost.fiddler");
Otherwise, Visual Studio's built in web server will bypass all proxies.
Take a look at SoapExtensions.
They are what you need.
For some reason Fiddler was not showing my local service calls when using the ASP.NET Development Server that comes with Visual Studio. To get around this I changed the web service Url at runtime to be the Fiddler port, just to capture the SOAP message.
You can do this from the Immediate window, for example:
myservice.Url = "localhost:8888" (or whatever port you have Fiddler on)
I used the SoapUI client to test responses.
Just "." add the address in your endpoint after "localhost".
like this:
<endpoint address="http://localhost.:8868/FEInvoice.asmx" binding="basicHttpBinding"
bindingConfiguration="FEInvoice_Test" contract="EInvoiceIntegration.FEInvoiceSoap"
name="FEInvoice_Test" />

Categories