views:

118

answers:

2

How can I get the SOAP header of my web service function as xml?

I need an XML version of my working SOAP header to use as an example for someone with broken SOAP headers. He's using a different programming language, but since the headers are sent in XML, we're hoping we can compare those easily. I'm using C# and ToString() just gives me the name of the object. After googling, I tried Fiddler, but that didn't catch anything, and SOAP Extensions look way too complicated for what seems like a really simple task.

+3  A: 

There is no easy way to do this with ASMX web services. If you were using WCF, it would be a trivial matter of turning on message logging.

Fiddler should catch everything, and it's well worth learning how to use. Be sure to look in the online documentation to learn how to capture traffic from localhost to localhost.

John Saunders
+1 - I use Fiddler to give examples to the SAP developers.
James Black
ok, I think I figured out how to capture traffic for localhost, but I'm still not sure where I'm supposed to be looking for the SOAP xml
thchaver
I don't understand. It's in the traffic. Request and response. Play with the tabs until you find it.
John Saunders
A: 

The accepted answer to this question mentions that you can capture traffic to a web service using soapUI. You can use it to act as a proxy or HTTP tunnel in order to capture messages sent to your web service. I think using it in HTTP Tunnel mode makes sense, because then you won't have to do anything with your client other than to point the URL to soapUI instead of your actual service.

The soapUI website talks about the SOAP Monitor feature, though I don't think it offers a good explanation for setting up the HTTP tunnel.

Here are the steps involved (based on soapUI 3.0.1):

  1. Open Soap UI
  2. create a New soapUI Project... 2.1 Give your project a name 2.2 Enter the path to your service's WSDL (http://localhost/.../YourService.asmx?WSDL)
  3. Right-click on the project you just created
  4. Select "Launch SOAP Monitor"
  5. Choose "HTTP Tunnel"
  6. Specify an unused port number for "Port". The default will probably work.
  7. Enter the URL to your web service in "Set endpoint for HTTP Tunnel"
  8. If you are using SSL, then you may need to fill in some of the other fields; otherwise, click OK
  9. The HTTP tunnel is running, so now just reconfigure a client to use the HTTP tunnel instead of the actual web service. So if your actual service is "http://localhost:1234/YourService.asmx", then reconfigure your client to use "http://localhost:{Port}/YourService.asmx" where {Port} is the number you entered in step #6.
  10. Now just run your client normally. You'll see the traffic logged in the soapUI interface. Select a message and click on the "Message Content" button at the bottom of the window to view the actual SOAP message.
Dr. Wily's Apprentice