Sun Java System logo     
JAXM Translator Sample Application



JAXM Translator Sample Application


This document describes how to utilize the JAXM Translator sample application in conjunction with the Sun Java (tm) System Application Server 7.

This sample application document contains the following sections:



Overview

The purpose of this document is to demonstrate the support for the Java API for XML Messaging in the Sun Java (tm) System application server.

The Java API for XML Messaging
The Java™ API for XML Messaging (JAXM) Optional Package enables applications to send and receive document oriented XML messages using a pure Java API. JAXM implements Simple Object Access Protocol (SOAP) 1.1 with Attachments messaging so that developers can focus on building, sending, receiving, and decomposing messages for their applications instead of programming low level XML communications routines.

In this sample application, the sending servlet (SendingServlet.java) sends the form input values in a SOAP message that is received by the receiving servlet (ReceivingServlet.java). The receiving servlet will the forward these values to the translation service (TranslationService.java).

The TranslationService talks to babelfish.altavista.com making an HTTP connection and extracts the translations of the input text string from the response. The text is translated to German, Italian and French languages.

The translations can be returned either as attachments to a JAXM message or within the SOAPBody depending on which option is chosen in the radio button from the application's index.html. If using a proxy, the proxy settings (both host and port) need to be entered.

For more information on JAXM, go to http://java.sun.com/xml/jaxm/index.html.

The source code is located at

<install_root>/samples/webservices/jaxm/translator/src/ .



Compiling and Assembling the Application



This section describes how to compile and assemble the application using a Command Line Interface.

See the Sample Application Build Facility document for details on using a build facility.

To rebuild the entire application from scratch, perform the following steps:

  1. Compile and assemble the application.

    Execute the asant command under <install_root>/samples/webservices/jaxm/translator/src .

  2. Create Javadocs for the application.

    Execute the asant javadocs command under <install_root>/samples/webservices/jaxm/translator/src/ to create javadocs.

    The Javadocs are created under <install_root>/samples/webservices/jaxm/translator/javadocs.

  3. Clean the web application project area (optional).

    Execute the asant clean command under <install_root>/samples/webservices/jaxm/translator/src/ to clean the application build and assemble area.



Deploying the Sample Application

To deploy the application, do the following:

Execute the command asant deploy under <install_root>/samples/webservices/jaxm/translator/src

This will deploy the jaxm-translator.war file located under <install_root>/samples/webservices/jaxm/translator/


Note You must run asant undeploy before redeploying this sample. This will ensure that all modules are undeployed and the resources are disabled.




Verifying Deployment

As an optional step, you can use the Sun Java (tm) System Application Server Administration Tool to verify that the application has been registered. Otherwise, proceed directly to Running the Sample Application.

To verify the registration of the application, do the following:

Execute the command asadmin list-components to look at applications deployed with a server instance. For example:

<install_root>/bin/asadmin list-components -u <username> -w <password> -H <host> -p <port> <server instance name>

You will see jaxm-translator listed.



Running the Sample Application



You can run the application through the following URL:

http://<hostname>:<port>/jaxm-translator

Enter a word or phrase to be tranlated in the corresponding textfield. Check one of the items, "In SOAP Body", or "As Attachments", in the radio buttons. Leave the Proxy Host and Proxy Port fields empty. Click on "Translate" button.

The files created by the sample, request.msg and reply.msg, are located under <install_root>/domains/domain1/<server-instance>/config/

Troubleshooting



  • There is a known issue with the translation web site, this sample is trying to connect to, which translates the input text. You will notice in the request.msg and reply.msg files that the SOAP messages were sent and received successfully. However in the reply.msg file, the translation web site returned the same text you inputed and did not do any translation.

  • If you encounter problems when running the application, review the log files at <install-root>/domains/domain1/<server-instance>/logs/server.log to learn what exactly went wrong.



Copyright © 2002 Sun Microsystems, Inc. All rights reserved.

Last Updated July 12, 2002