Sunday, July 15, 2012

Monitoring SOAP Messages Made Easy With JAX-WS RI 2.0.1

Posted by ramapulavarthi on August 17, 2006 at 10:32 AM PDT
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 "", 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]---
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=""><S:Body><addNumbers xmlns=""><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=""><S:Body><addNumbersResponse xmlns=""><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 "" 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.
Related Topics >>

No comments: