|
|
||
Rama Pulavarthi's BlogAugust 2006 ArchivesMonitoring SOAP Messages Made Easy With JAX-WS RI 2.0.1Posted by ramapulavarthi on August 17, 2006 at 10:32 AM | Permalink | 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. JAX-WS Customizations made easy with NetBeans 5.5Posted by ramapulavarthi on August 11, 2006 at 01:49 PM | Permalink | Comments (4)Often you need to override the default WSDL to Java bindings like changing XML Namespace to package mapping, generating asynchronous methods etc. Forget about vendor specific tool features or options you need to pass to customize WSDL to Java mapping. As you know, JAX-WS Specification defines a standard binding language to customize WSDL 1.1 to Java binding. Whatever JAX-WS implementation you choose, it will generate the same Java bindings with the customization file. You can specify this customization by embedding the <jaxws:bindings> in the wsdl or specify in an external file and pass it to the WSDL to Java mapping tool. wsimport tool of JAX-WS RI supports customization in both ways. JAX-WS defines lots of ways to customize WSDL to Java mapping from modifying the XML to Java name mapping, generating wrapper style signatures, generating asynchronous methods etc. Though the binding language is rich in its options, its confusing to write a customization file (sample) by hand as you need to exactly know what customization can be applied on a particular wsdl element. There comes NetBeans to the rescue. ![]() NetBeans 5.5 with its built-in support for JAX-WS Web Services also provides a nice GUI to customize WSDL to Java bindings easily. All you need to do is right click on a Web Service(created from WSDL) or a Web Service Reference and select "Edit Web Service Attributes" as shown above. It opens up a window categorized according to WSDL definitions. As shown below, if you want to generate asynchronous methods, select the check box "Enable Asynchronous Client". What NetBeans does in the background is embed JAX-WS customizations in the wsdl. NetBeans is also smart enough to provide different options for Web Service and Web Service Client. For example, on a Web Service you can specify "Use Provider Interface" on a port which is not available on Web Service Client, "Enable Asynchronous Client" can only be specified on Web Service Client. Not only does it embed the customization, it regenerates the Java artifacts by invoking wsimport with the customization as shown in below. You can even specify external customization files for customizing schema mappings.
Support of JAX-WS customization is a good start. There are some improvements that can be done. Currently it embeds the customization in the wsdl. It is convenient if it were in an external file as you dont want customization to show up in the wsdl which is used for deployment. Although NetBeans regenerates the Java artifacts, it does n't refactor the references in the application. Often schemas also need to be customized. JAXB has tons of customizations to modify XML Schema to Java mapping. NetBeans does n't yet support basic things in jaxb global customization like mapping of namespace to pacakge name or generating Interfaces instead of Classes etc. I hope these will be addressed in future release of NetBeans. There is a bug in NetBeans 5.5 Beta 2, where Web Services created from WSDL disappear after creation. It has been fixed in the recent builds. Download latest daily build of NetBeans 5.5 and try it yourself. | ||
|
|