Samples

This document explains the samples that are bundled along with JAX-WS RI 2.1.2 M1. The samples included with JAX-WS RIthat is distributed on Java.net documents how to use JAX-WS RIin a non-Java EE 5 servlet container using a proprietary deployment descriptor sun-jaxws.xml and servlet com.sun.xml.ws.transport.http.servlet.WSServlet. This means that you can these JAX-WS RIapplications in any servlet container that has been enabled with JAX-WS RI. Applications that use the proprietary DD and servlet will run in a JAX-WS RIenabled Java EE 5 servlet container, but they will be non-portable. If you wish to use these JAX-WS RIsamples in a Java EE container in a Java EE portable manner you need to modify them to use the standard Java EE 5 deployment descriptor; please refer to the Java EE 5 or Glassfish documentation/samples.

All these samples are tested to run on Glassfish Promoted Build v2 50 build and on Apache Tomcat 5.x.

1.0 Directory Structure

This section explains the directory structure of the samples directory in the bundle:

docs

index.html, this file

fromjava-wsaddressing Starting from Java endpoint how to develop W3C WS-Addressing endpoint
fromwsdl-wsaddressing Starting from WSDL how to develop a WS-Addressing endpoint

fromjava

Demonstrates how to build, deploy, and invoke a simple Web service starting from a Java service endpoint implementation using annotations.

fromjavahandler

Same as fromjava sample but with a simple logging handler on the client and server.

fromwsdl

Demonstrates how to build, deploy, and invoke a simple Web service starting from a WSDL using external customizations.

fromwsdl_secure

Same as fromwsdl sample but demonstrates how to build, deploy, and invoke an HTTPS Web service and client from a WSDL.

fromwsdlhandler

Same as fromwsdl sample but with a simple logging handler on the client and server.

dispatch

Demonstrates how to dynamically invoke web service endpoints.

provider Demonstrates how to build, deploy, and invoke javax.xml.ws.Provider based Web service endpoint.

asyncprovider

Demonstrates how to build, deploy, and invoke a server side asynchronous Provider based Web service endpoint.

annotations

Same as fromjava but shows how to specify a different parameter name, operation name, targetNamespace, and other similar features.

async

Demonstrates how to generate async operations in a client SEI from a WSDL and invoke it from the client application.

external-customize

Demonstrates how a client client application can customize a published WSDL using external binding file.

inline-customize

Demonstrates how a client application and server endpoint can be generated from a WSDL with embedded binding declarations.

mtom

Demonstrates how to enable MTOM and swaRef.

mtom-soap12

Same as mtom sample but shows how to specify SOAP 1.2 binding.

fromjava-soap12

Same as fromjava sample but shows how to specify SOAP 1.2 binding.

fromwsdl-soap12

Same as fromwsdl sample but shows how to specify SOAP 1.2 binding.

supplychain

Same as fromjava sample but using JavaBeans as parameter and return types.
Also the service can be built and deployed using Endpoint API.

mime

Demonstrates how a MIME binding is defined in the WSDL to send wsdl:part as MIME attachments. This requires that the development model is 'starting from WSDL'.

wsimport_catalog

Demonstrates a how a WSDL and schema URI's can be resolved using catalog mechanism using wsimport ant tasks' catalog attribute and also using ant's core type xmlcatalog.

catalog

Shows the catalog capability on the client side; Catalog is used every time the implementation tries to access a resource identified by URI that is believed to contain either a WSDL document or any other document on which it depends .

restful

Shows an example of a REST Web Service implemented as a JAX-WS 2.0 Provider and accessed via a JAX-WS Dispatch client. The Request uses an HTTP GET Request Method and uses the JAX-WS MessageContext properties PATH_INFO and QUERY_STRING.

stateful This sample shows the JAX-WS RI's stateful webservice support feature.

2.0 Prerequisites

Here is the list of prerequisites that needs to be met before any of the samples can be invoked:

  1. Download Java 2 Standard Edition 5.0 Update 2 or later ( J2SE 5.0). Set JAVA_HOME to the J2SE 5.0 installation directory.

  2. Download Glassfish Promoted Build v2 50 and install it.

  3. Make sure that the Application Server is configured for port 8080 (which is the default HTTP port for Glassfish installation) as samples hardcoded with this port info. Otherwise, you need to change samples to use the correct port.

  4. Set up the environment,

    1. Set AS_HOME to point to the Application Server installation directory.

    2. Set JAXWS_HOME to the JAX-WS installation directory.

  5. Glassfish Promoted Build v2 50 integrates JAX-WS RI 2.1.2 M1. So you may just start using it and skip step 6 below unless you want to use the latest JAX-WS RI 2.1.2 M1.

  6. If you have installed a standalone JAX-WS RIbundle,

    1. 'cd JAXWS_HOME' then invoke 'ant install'. This will add jaxws 2.1.2 M1  jars in the classpath-prefix in domain.xml. This is required so that Glassfish picks-up JAXWS 2.1.2  jar.

3.0 Invoking the sample

Each sample can be built, deployed and invoked using the ANT_HOME/bin/ant and build.xml ant script in the root directory of the sample. Each ant script supports the following set of targets:

server

Builds and deploy the service endpoint WAR

client

Builds the client

run

Runs the client


Some samples(e.g. fromjava, supplychain) can be built, deployed using javax.xml.ws.Endpoint API. These samples support extra targets:

server-j2se

Builds and deploys the Endpoint API based service endpoint(doesn't terminate until server-j2se-stop is called)

server-j2se-stop
Stops the Endpoint API based service endpoint(need to run from a different window)


It is essential for the service endpoint to be deployed on Application Server before clients can be built because clients use the WSDL exposed from the service endpoint deployed in the Application Server. So please make sure that your Application Server is either running before the server target is invoked or run it after the server target is invoked. You will have to wait a few minutes for the Application Server to deploy the service endpoint correctly before building the client.

Running Samples with Tomcat:

  1. Set CATALINA_HOME to your Tomcat installation.

  2. Make sure that tomcat is configured for port 8080 as samples hardcoded with this port info. Otherwise, you need to change samples to use the correct port.

  3. If you have installed a standalone JAX-WS bundle, Copy the JAX-WS RIjars and its dependency jars to /shared/lib.

  4. Set JAXWS_HOME to the JAX-WS RIinstallation directory.

  5. Make sure the Tomcat container is up and running before running sample.

  6. While running the ant targets in samples, specify “-Dtomcat=true”. For example:

ant clean server -Dtomcat=true, this will build the service and deploy the war to /webapps.

ant clean client, this would create client-side artifacts and compiles the files.

ant run

We appreciate your feedback, please send it to users@jax-ws.dev.java.net.