Home
TOC Index |
Running the Samples
The Java WSDP includes several JAXM sample applications. It also includes various implementations that make it possible for you to run the sample applications. These implementations, which constitute the JAXM reference implementation, are the following:
- an implementation of the JAXM API
- an implementation of a messaging provider
- basic implementations of ebXML and SOAP-RP profiles, which run on top of SOAP
All of the sample applications use the JAXM API, of course, and some use other implementations as well. For example, the sample application Remote uses the implementations of the messaging provider and the ebXML profile; the SOAP-RP sample uses the implementations for the messaging provider and the SOAP-RP profile. The next section, (The Sample Programs), gives more information about the sample applications and what they do.
Most of the samples run in a container, so before running them, you need to start Tomcat (see Starting Tomcat).
Once Tomcat is running, you can run the JAXM samples by following these steps:
- Open a browser window and set it to
http://localhost:8080/index.html- On the page that comes up, click on one of the sample programs listed. Then follow the instructions in the new window that comes up.
The Sample Programs
The sample programs illustrate various kinds of applications you can write with the JAXM API. Note that the Simple, Translator, and SAAJ Simple examples log messages sent and received to the directory in your Java WSDP installation where you started Tomcat. So if, for example, you start Tomcat from the
<
JWSDP_HOME
>/bin
directory, that is where the messages will be logged. These messages are the XML that is sent over the wire, which you might find easier to understand after you have gone through the tutorial.
- Simple -- A simple example of sending and receiving a message using the local provider. Note that a local provider should not be confused with a messaging provider. The local provider is simply a mechanism for returning the reply to a message that was sent using the method
SOAPConnection.call
. Note that a message sent by this method will always be a request-response message. Running this example generates the filessent.msg
andreply.msg
, which you will find in the directory where you started Tomcat.- SAAJ Simple -- An application similar to the Simple example except that it is written using only the SAAJ API. In SAAJ Simple, the
call
method takes a JavaObject
rather than aURLEndpoint
object to designate the recipient, and thus uses only thejavax.xml.soap
package. Running this example generates the filessent.msg
andreply.msg
, which you will find in the directory where you started Tomcat.- Translator -- An application that uses a simple translation service to translate a given word into different languages. If you have given the correct proxy host and proxy port, the word you supply will be translated into French, German, and Italian. Running this example generates the files
request.msg
andreply.msg
in the directory where you started Tomcat. Checkreply.msg
after getting the reply in the SOAP body and again after getting the reply as an attachment to see the difference in what is sent as a reply.- JAXM Tags -- An example that uses JavaServer Pages tags to generate and consume a SOAP message
- Remote -- An example of a round trip message that uses a JAXM messaging provider that supports the basic ebXML profile to send and receive a message
- SOAP-RP -- An example of a round trip message that uses a JAXM messaging provider that supports the basic SOAP-RP profile to send and receive a message
There are two other sample programs,
jaxm-uddiping
andjaxm-standalone
, that do not run in Tomcat. To run them, go to the<
JWSDP_HOME
>/samples/jaxm
directory, where you will find the directoriesuddiping
andstandalone
. Each directory contains aREADME
file that explains what to do.In the Examples section of the JAXM tutorial (UddiPing.java and MyUddiPing.java), you will find an application that modifies the code in
UddiPing.java
and also explains in detail how to run it. You might find it more convenient to wait until you have reached that section before trying to run thejaxm-uddiping
andjaxm-standalone
samples.The preceding list presented the sample applications according to what they do. You can also look at the sample applications as examples of the three possible types of JAXM client:
- Those that do not use a messaging provider and also do not run in a containerThese are called standalone applications. The samples
jaxm-standalone
andjaxm-uddiping
are examples of standalone clients.- Those that do not use a messaging provider and run in a containerThe samples Simple, SAAJ Simple, Translator, and JAXM Tags are examples of this type.
- Those that use a messaging provider and run in a containerThe samples Remote and SOAP-RP are examples of this type.
Source Code for the Samples
Source code for the sample applications is in the directory
<JWSDP_HOME
>/docs/tutorial/examples/jaxm/samples/You will find six directories, one for each of the samples that runs in Tomcat. The
jaxmtags
directory contain a number of.jsp
files. The other directories all have two files,SendingServlet.java
andReceivingServlet.java
. In addition to those two files, thetranslator
directory contains the fileTranslationService.java
.If you want to see all of the files that make up a Web web application, you can go to the directory
<
JWSDP_HOME
>/webapps
and unpack the.war
files. For example, for the Simple sample, you would do the following:cd <JWSDP_HOME
>/webapps jar -xvf jaxm-simple.warIn addition to the source files and class files for the Simple sample, you will find the files
web.xml
andbuild.xml
. .The
web.xml
file, referred to as a deployment descriptor, associates the endpoint passed to the methodSOAPConnection.call
orProviderConnection.send
with a particular servlet class. When the container encounters an endpoint, which is generally a URI, it uses theweb.xml
file to determine the appropriate servlet class and runs it. See the end of the section Sending the Request for an example and explanation.The
build.xml
file is theAnt
file to use to run the application.
Home
TOC Index |
This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.
All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.