corner imagecorner image
FeaturesPluginsDocs & SupportCommunityPartners

Web Service Passing Binary Data, pt7: Logging and Optimizing the Service

Note: The current release is NetBeans IDE 6.5. If you are using NetBeans IDE 6.5, see the latest version of this tutorial.

JAX-WS provides an easy and effective way to optimize binary data transfer. It is known as "message optimization", provided by the Message Transmission Optimization Mechanism (MTOM). Message optimization is the process of transmitting web service messages in the most efficient manner. It is achieved in web service communication by encoding messages prior to transmission and then de-encoding them when they reach their final destination. MTOM uses XOP (XML-binary Optimized Packaging) to transmit binary data to and from the web service. The Web Service Designer lets you enable MTOM easily, as shown in this section and described here.

Tutorials In This Trail

Content on this page applies to NetBeans IDE 6.1

Logging and Optimizing the Web Service

To be able to verify, later, that MTOM is working correctly, begin by setting up a logging mechanism on the server. This lets you monitor the request and response messages without changing the client code. Pass the system property -Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true to the server so that you can monitor the SOAP messages as well as the HTTP headers that the web service is receiving and sending from and to the client.

To Log and Optimize the Web Service:

Open the Admin Console, from the server's node in the Services window, as shown here:
Java application with consumed ws

The Admin Console opens in the browser. Enter your username and password and press Enter.

In the Admin Console, use the JVM Options section, shown below, to set this property on the server.
-Dcom.sun.xml.ws.transport.http.HttpAdapter.dump=true


Java application with consumed ws In the Services window, restart the server. While the server starts up, look in the Output window and make sure you see the property amongst the other server output, as shown below.
Java application with consumed ws
Redeploy the enterprise application to the Tester application, invoke an operation via the Tester application, and notice the Output window again, showing HTTP requests and responses, because of the logging mechanism that you enabled in the previous steps.
Java application with consumed ws

Now that we have HTTP logging working correctly, we will optimize the message transfer of our images.

Open the web service in the Web Service Visual Designer and select "Optimize Transfer of Binary Data (MTOM)".
Java application with consumed ws
In the Services window, restart the server. While the server starts up, notice the following in the Output window.
Java application with consumed ws

As indicated in the highlighted lines in the Output window, by using MTOM we ensure that binary data is not contained within the SOAP body. Instead, it is sent as a SOAP attachment, while the attachment is included in the SOAP message.



See Also

For more information about using NetBeans IDE 6.1 to develop Java EE applications, see the following resources:

To send comments and suggestions, get support, and keep informed on the latest developments on the NetBeans IDE Java EE development features, join the mailing list.

Companion
Projects:
MySQL Database Server   GlassFish Community: an Open Source Application Server   Open Solaris  Open JDK: an Open SourceJDK   Mobile & Embedded Community     Sponsored by 
Sponsored by Sun Microsystems


You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser