What's New in Java Web Services Developer Pack 1.1

By Qusay H. Mahmoud, April 2003  

The Java Web Services Developer Pack (Java WSDP) has evolved into an integrated toolkit for developing, building, testing, and deploying Web Services, as well as Web and XML-based applications. The current version of Java WSDP, 1.1, has added new features, fixed bugs, and made developing and deploying Web services easier. This article provides a quick overview, describes the technologies that are now part of Java WSDP 1.1, and highlights the new features focusing on the new installer and the Java Architecture for XML Binding (JAXB).

If you are new to Web Services, please check out the Introduction to Web Services and the The Java Web Services Tutorial.

Overview of Java WSDP

The Java Web Services Developer Pack (Java WSDP):

  • Is an integrated toolkit that allows Java developers to develop, test, and deploy Web Services quickly and easily.
  • Is an all-in-one download containing key technologies, tools, and APIs that simplify Web services development using the Java 2 Platform.
  • Provides implementations of Java standards for Web services standards including WSDL, SOAP, and UDDI.
  • Provides implementations standards for Web application development such as JavaServer Pages (JSP Pages) and the JSP Standard Tag Library (JSTL).
  • Provides implementations for parsing, transforming and binding XML documents.

Java WSDP Technologies and Tools

Java WSDP 1.1 incorporates the following technologies and tools:

  • Java Architecture for XML Binding (JAXB) v1.0: The JAXB API provides Java developers with an efficient and standard way of mapping between XML and Java code. It increases the productivity of Java developers because they can write less code themselves and do not have to be experts in XML. Also, it allows developers to easily extend their applications with XML and Web services technologies.

  • Java API for XML Processing (JAXP) v1.2.2: The JAXP API supports processing of XML documents using DOM, SAX, and XSLT, enables applications to parse and transform XML documents independent of a particular XML processing implementation, and provides developers with the flexibility to swap between XML processors without making application code change.

  • Java API for XML-based RPC (JAX-RPC) v1.0.3: This API enables Java developers to develop SOAP-based portable Web services. It is worth noting that JAX-RPC Web services can be deployed on the Java 2 platform, Enterprise Edition (J2EE) v1.3.

  • Java API for XML Registries (JAXR) v1.0.3: The JAXR API is an abstract uniform Java API for accessing different kinds of XML registries. It provides a single set of APIs to access a variety of XML registries, including UDDI and the ebXML Registry. You don't need to worry about the nitty-gritty details of each registry's information model. This abstraction is consistent with the Java philosophy of "Write Once, Run Anywhere". It enables value-added capabilities beyond what the underlying registries can do. As an example, a non-JAXR UDDI client can't do taxonomy browsing and taxonomy-aware smart queries -- which are available to a JAXR client for UDDI. The JAXR information model is based on the ebXML Registry Information Model (RIM), with enhancements to support UDDI. The ebXML RIM is more generic and extensible than the UDDI XML data structures, so the ebXML RIM can be extended to satisfy the needs of UDDI. The JAXR Reference Implementation, which is part of the Java Web Services Developer Pack (Java WSDP) implements the level 0 capability profile defined by the JAXR specification (JSR 93), which allows access to both UDDI and ebXML registries at a basic level.

  • SOAP with Attachments API for Java (SAAJ) v1.1.1: This API enables developers to produce and consume messages conforming to the SOAP 1.1 specification and SOAP with Attachments note.

  • Java API for XML Messaging (JAXM) v1.1.1: The JAXM API enables Java developers to send and receive document oriented XML messages between applications using a pure Java API. It implements SOAP 1.1 with Attachments messaging, allowing developers to focus on building, sending, receiving, and decomposing messages for their applications instead of programming low-level XML communications routines.

  • Java Servlets: Servlets are Java classes that are capable of generating dynamic HTML content using print statements. What is important about Servlets, however, is that they run in a container and the APIs provide session and object life cycle management. Consequently, using Servlets gains you all the benefits from the Java platform which include the sandbox (security), database access API via JDBC, and cross platform portability of servlets.

  • JavaServer Pages: JSP Pages abstract servlets to a higher level, allowing Web developers and designers to rapidly develop and maintain information-rich dynamic Web pages. The JSP technology promotes separation between business logic and presentation.

  • JavaServer Pages Standard Tag Library (JSTL) v1.0.3: The JavaServer Pages Standard Tag Library (JSTL) is a standard tag library that provides support for common, structural tasks, such as: iteration and conditionals, processing XML documents, internationalization, and database access using the Structured Query Language (SQL). It provides four separate tag libraries, each containing custom actions that target a specific functional area: (1) core action, (2) XML processing, (3) internationalization, and (4) database access. In addition, the JSTL introduces the concept of an expression language (EL) to simplify page development.

  • Java WSDP Registry Server v1.0_04: The Java WSDP Registry Server implements Version 2 of the Universal Description, Discovery and Integration (UDDI) specification to provide a UDDI registry for Web services in a private environment. Use it as a test registry for Web services application development to test applications that you develop that use the Java API for XML Registries (JAXR). A Registry Browser is also provided to perform queries and updates on registry data.

  • Ant Build Tool 1.5.1: Ant is a XML-based Java build tool.

  • Apache Tomcat 4.1.2 container: Tomcat is the servlet and JSP container.

New Features in Java WSDP 1.1

Several bugs were fixed in the Java WSDP 1.1, and two new primary features were added:

  1. An enhanced installer that allows developers to select individual technologies to be installed that are appropriate for specific development requirements. Figure 1 shows a snapshot of the new installer when performing custom installation.

  2. Figure 1: Enhanced Installer in Java WSDP 1.1
  3. Java Architecture for XML Binding 1.0 (JAXB): A Java technology that enables developers to generate Java classes from XML schemas.

Java Architecture for XML Binding

JAXB is a Java technology that simplifies the life of developers by allowing them to easily create and maintain XML-enabled Java applications without being XML experts. This is done by taking advantage of the fact that valid XML documents satisfy a set of constraints by conforming to a schema. At the core of JAXB is a binding compiler and a runtime framework to support mapping between XML documents and Java objects. The job of the binding compiler is to translate W3C XML Schema Language into Java classes and interfaces without having the developer write parsing code in SAX (Simple API for XML) or DOM (Document Object Model).

JAXB vs. SAX and DOM

The Simple API for XML (SAX) is simply a standard interface, implemented by many different XML parsers, that was developed by members of the XML-DEV mailing list, currently hosted by OASIS. The main advantage of SAX is that it is lightweight and fast, because it is an event-based API, meaning it reports parsing events (such as the start and end of elements) directly to the application using callbacks. Therefore, the application implements handlers to deal with the different events, much like handling events in a graphical user interface.

The Document Object Model (DOM) is a platform- and language-neutral interface for accessing and updating documents. Unlike SAX however, DOM accesses an XML document through a tree structure, composed of element nodes and text nodes. The tree will be built in memory and therefore there are large memory requirements when using DOM. The advantage of DOM, however, is that it is simpler to program with than SAX.

Both SAX and DOM provide automatic structure validation, but in order to perform content validation in either SAX or DOM, the developer must provide the necessary extra code, which might be complicated and error-prone. JAXB, on the other hand, can perform structure and content validation with Java classes generated from a schema. Like DOM, however, a JAXB application builds an in-memory data structure, but unlike DOM a content tree is specific to one source schema and allows access to the data with the generated classes' accessor methods. What is important to note about JAXB accessor methods is that they follow the JavaBeans standard and have specific names that relate to the schema, and the generated interfaces by JAXB are more intuitive than DOM.

SAX and DOM are more appropriate than JAXM for content that is dynamic and not constrained by a well-known schema prior to processing the content.

XML Schema Language

An XML Schema is a powerful way to describe constraints and allowable elements, attributes, entities, and relationships in an XML document. It is similar to, but more powerful than, a DTD (Document Type Definition). It is more powerful because it specifies attributes data types such as decimal, fixed, date; as well as constraints such as pattern value, positiveInteger, and others. On the other hand, in a DTD you can only specify data types for textual data using PCDATA and CDATA.

A valid XML document containing data constrained by an XML schema is called a document instance and the structure and data within the document is called a content tree. The following XML document, po.xml, is taken from the Java Web Services Tutorial:

Code Sample 1: po.xml

<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
    <shipTo country="US">
        <name>Alice Smith</name>
        <street>123 Maple Street</street>


    <billTo country="US">
        <name>Robert Smith</name>
        <street>8 Oak Avenue</street>

        <item partNum="242-NO" >

                <productName>Nosferatu - Special Edition (1929)</productName>

        <item partNum="242-MU" >
                <productName>The Mummy (1959)</productName>

        <item partNum="242-GZ" >
                <productName>Godzilla and Mothra: Battle for Earth/
                Godzilla vs. King Ghidora</productName>


The XML document, po.xml, in Code Sample 1 defines its data by following the XML Schema, po.xsd shown in Code Sample 2. Again, this is taken from the Java Web Services Tutorial.

Code Sample 2: po.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
<xsd:element name="comment" type="xsd:string"/>
<xsd:complexType name="PurchaseOrderType">

    <xsd:element name="shipTo" type="USAddress"/>
    <xsd:element name="billTo" type="USAddress"/>
    <xsd:element ref="comment" minOccurs="0"/>
    <xsd:element name="items" type="Items"/>

  <xsd:attribute name="orderDate" type="xsd:date"/>

<xsd:complexType name="USAddress">
    <xsd:element name="name" type="xsd:string"/>
    <xsd:element name="street" type="xsd:string"/>

    <xsd:element name="city" type="xsd:string"/>
    <xsd:element name="state" type="xsd:string"/>
    <xsd:element name="zip" type="xsd:decimal"/>
  <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>

<xsd:complexType name="Items">
    <xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
         <xsd:element name="productName" type="xsd:string"/>

         <xsd:element name="quantity">
             <xsd:restriction base="xsd:positiveInteger">
               <xsd:maxExclusive value="100"/>

         <xsd:element name="USPrice" type="xsd:decimal"/>
         <xsd:element ref="comment" minOccurs="0"/>
         <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/>
        <xsd:attribute name="partNum" type="SKU" use="required"/>


<!-- Stock Keeping Unit, a code for identifying products -->
<xsd:simpleType name="SKU">
  <xsd:restriction base="xsd:string">

     <xsd:pattern value="\d{3}-[A-Z]{2}"/>


If you have already installed the Java WSDP 1.1, you can find this purchase order example in the directory $JWSDP_HOME\jaxb-1.0\examples\users-guide\SampleApp1. To run this example, use the ant tool that comes with the Java WSDP, which can be found at: jwsdp-1.1\jakarta-ant-1.5.1\bin. Here is a sample output:

Output Sample: JAXB SampleApp1

Buildfile: build.xml

     [echo] Compiling the schema...
      [xjc] Compiling file:/C:/jwsdp-1.1/jaxb-1.0/examples/users-guide/
    [mkdir] Created dir: C:\jwsdp-1.1\jaxb-1.0\examples\users-guide\
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Loading source files for package primer.po...
  [javadoc] Constructing Javadoc information...
  [javadoc] Standard Doclet version 1.4.1

  [javadoc] Building tree for all the packages and classes...
  [javadoc] Building index for all the packages and classes...
  [javadoc] Building index for all classes...
     [echo] Compiling the java source files...
    [javac] Compiling 12 source files to C:\jwsdp-1.1\jaxb-1.0\
     [echo] Running the sample application...
     [java] Ship the following items to:
     [java]     Alice Smith
     [java]     123 Maple Street
     [java]     Cambridge, MA 12345
     [java]     US

     [java]     5 copies of "Nosferatu - Special Edition (1929)"
     [java]     3 copies of "The Mummy (1959)"
     [java]     3 copies of "Godzilla and Mothra: Battle for Earth/
     Godzilla vs.King Ghidora"

Total time: 16 seconds

In this example, the JAXB binding compiler, xjc, generates the following Java classes in the directory primer\po:

impl (DIR)
  - CommentImpl$Unmarshaller.class
  - CommentImpl.class
  - CommentImpl.java
  - ItemsImpl$ItemTypeImpl$Unmarshaller.class
  - ItemsImpl$ItemTypeImpl.class
  - ItemsImpl$Unmarshaller.class
  - ItemsImpl.class
  - ItemsImpl.java
  - PurchaseOrderImpl$Unmarshaller.class
  - PurchaseOrderImpl.class
  - PurchaseOrderImpl.java
  - PurchaseOrderTypeImpl$Unmarshaller.class
  - PurchaseOrderTypeImpl.class
  - PurchaseOrderTypeImpl.java
  - USAddressImpl$Unmarshaller.class
  - USAddressImpl.class
  - USAddressImpl.java

Here is a sample application that demonstrates how to unmarshal an instance document into a Java content tree and access data contained within it:

Code Sample 3: Main.java

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

// import java content classes generated by binding compiler
import primer.po.*;

public class Main {

    // This sample application demonstrates how to unmarshal an instance
    // document into a Java content tree and access data contained within it.

    public static void main( String[] args ) {
        try {
            // create a JAXBContext capable of handling classes generated into
            // the primer.po package
            JAXBContext jc = JAXBContext.newInstance( "primer.po" );
            // create an Unmarshaller
            Unmarshaller u = jc.createUnmarshaller();
            // unmarshal a po instance document into a tree of Java content
            // objects composed of classes from the primer.po package.
            PurchaseOrder po = 
                (PurchaseOrder)u.unmarshal( new FileInputStream( "po.xml" ) );
            // examine some of the content in the PurchaseOrder
            System.out.println( "Ship the following items to: " );
            // display the shipping address
            USAddress address = po.getShipTo();
            displayAddress( address );

            // display the items
            Items items = po.getItems();
            displayItems( items );
        } catch( JAXBException je ) {
        } catch( IOException ioe ) {

    public static void displayAddress( USAddress address ) {
        // display the address
        System.out.println( "\t" + address.getName() );
        System.out.println( "\t" + address.getStreet() ); 
        System.out.println( "\t" + address.getCity() +
                            ", " + address.getState() + 
                            " "  + address.getZip() ); 

        System.out.println( "\t" + address.getCountry() + "\n"); 


    public static void displayItems( Items items ) {
        // the items object contains a List of primer.po.ItemType objects
        List itemTypeList = items.getItem();

        // iterate over List
        for( Iterator iter = itemTypeList.iterator(); iter.hasNext(); ) {
            Items.ItemType item = (Items.ItemType)iter.next(); 
            System.out.println( "\t" + item.getQuantity() +
                                " copies of \"" + item.getProductName() +
                                "\"" ); 

The default data types binding are shown in Table 1.

Table 1: JAXB Mapping of Schema Built-in Data Types to Java
XML Schema Type Java Data Type
xsd:string java.lang.String
xsd.integer java.math.BigInteger
xsd:int int
xsd:long long
xsd:short short
xsd:decimal java.math.BigDecimal
xsd:float float
xsd:double double
xsd:boolean boolean
xsd:byte byte
xsd:QName javax.xml.namespace.QName
xsd:dateTime java.util.Calendar
xsd:base64Binary byte[]
xsd:hexBinary byte[]
xsd:unsignedInt long
xsd:unsignedShort int
xsd:unsignedByte short
xsd:time java.util.Calendar
xsd:date java.util.Calendar
xsd:anySimpleType java.lang.String

Note that while the default bindings generated by the JAXB binding compiler will be sufficient for most developers' needs, it is possible to customize by modifying the default bindings.


The Java Web Services Developer Pack 1.1 (Java WSDP 1.1) is an integrated toolkit that enables Java developers to easily develop, test, and deploy Web Services as well as Web and XML-based applications. If you wish to learn more about Java Web Services and get a flavor for the effort involved in developing them, I'd recommend you turn to the Java Web Services Tutorial. And, if you like to meet and listen to the experts, JavaOne 2003 has a complete track on Web Services featuring exciting technical sessions for novice, intermediate and advanced developers as well as managers.

For more information

- Web Services and Java Technology

- Download Java WSDP 1.1

- Web Services BluePrints

- The Java Web Services Tutorial

- Registration and Discovery of Web Services (demonstrates how to use JAXR)

- Web Application Development with JSP and XML in Mind (contains examples of SAX and DOM)


Special thanks to Rajiv Mordani, Ryan Shoemaker, and Eduardo Pelegri-Llopart of Sun Microsystems, whose feedback helped me improve this article.

Have a question about programming? Use Java Online Support.