The Source for Java Technology Collaboration
User: Password:



Rama Pulavarthi

Rama Pulavarthi's Blog

Monitoring SOAP Messages Made Easy With JAX-WS RI 2.0.1

Posted by ramapulavarthi on August 17, 2006 at 10:32 AM | Comments (4)

One of the things people want to do while developing Web Services is to look at what the client is sending and receiving. To monitor soap traffic, there are some GUI tools like TCP Monitor and WSMonitor. These monitors are implemented with a 'man in the middle' approach where-in, the monitor listens to a port (Client send requests to this port) and forwards it to another port (Server listens to this port). Since these tools use port forwarding, you need to change your Web Service client to send request to the port where the monitor listens (Especially, if you are using static clients generated by wsimport, the default endpoint address taken from the wsdl needs to be overidden by setting ENDPOINT_ADDRESS_PROPERTY on the proxy).

In JAX-WS 2.0.1, You can monitor the request and response messages without changing the client. When you invoke the Web Service, just pass the System property "com.sun.xml.ws.transport.http.client.HttpTransportPipe.dump=true", it prints out the request and response message.

This is the sample request and response, I got by running fromwsdl sample in JAX-WS 2.0.1 M1 bundle by passing this system property.

---[HTTP request]---
SOAPAction: 
Content-Type: text/xml
Accept: text/xml, multipart/related, text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><addNumbers xmlns="http://duke.example.org"><arg0>10</arg0><arg1>20</arg1></addNumbers></S:Body></S:Envelope>--------------------

---[HTTP response 200]---
Date: Thu, 17 Aug 2006 00:35:42 GMT
Content-type: text/xml
Transfer-encoding: chunked
Server: Apache-Coyote/1.1
null: HTTP/1.1 200 OK
<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><addNumbersResponse xmlns="http://duke.example.org"><return>30</return></addNumbersResponse></S:Body></S:Envelope>--------------------

Jitu explained in his blog, how one can use local transport to test Web Services without deploying the service on to a Web Container. In such case, you can pass "com.sun.xml.ws.transport.local.LocalTransportPipe.dump=true" to monitor SOAP messages.

This can be helpful to just see what the client is sending/receiving to the server very easily. Of course, if you need sophisticated functions like replaying the request, you have to use those monitors.

Try this out yourselves by getting GlassFish 9.1 V2.


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • That's a nice way to avoid monitors on client side. But why not same on sever side as well ?

    Posted by: prashant_sk on August 20, 2006 at 07:43 PM

  • Yes, We are working on a similar thing on server-side. I will update the blog when it is ready.

    In the meanwhile, you can use Glassfish's Monitoring Tool to do that.
    http://developers.sun.com/prodtech/appserver/reference/techart/ws_mgmt.html explains how to use it.

    Posted by: ramapulavarthi on September 28, 2006 at 12:12 PM

  • Thanks for a very helpful post. I am working on a project with JAX-WS and Resin (unfortunately we are not allowed to use Glassfish) so the tip regarding HttpTransportPipe was wonderful.

    That said, is there any way to write the SOAP messages to a file and not just display them on the console (along with other debug info)? For example, is it possible to configure something like log4j to capture the SOAP messages?

    Thanks Rama!

    Posted by: kipkerplunk on March 17, 2008 at 12:42 PM

  • Hello, I'm using JDK 1.6.0_04 and successfuly using wsimport to generate web service proxy classes. I want to monitor SOAP messages sent and received as described above. I'm setting system properties like

    System.setProperty("com.sun.xml.ws.transport.local.LocalTransportPipe.dump", "true");

    but they don't seem to work - I get no SOAP output. Are there any such properties that I can set to monitor SOAP messages in the standard JDK, or does only GlassFish support this?

    Posted by: luxner on April 02, 2008 at 09:28 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds