You are here:
Developing Java Web Services

This course prepares Java programmers to develop Web services and clients according to the Web Services Interoperability (WS-I) Organization’s WS-Basic profile: that is, using SOAP 1.1, WSDL 1.1 and XML Schema 1.0. (WS-Basic also calls for UDDI, which has more to do with publishing than development.) Students get an overview of the interoperable and Java-specific Web services architectures, and then learn the standard APIs for SOAP messaging and WSDL-driven, component-based service development. Both document-style and RPC-style messages and services are covered in depth.

The first module provides an overview of the world of Java-based Web services. It is designed to be equally useful to Java developers and to project managers and technologists. There is a great deal of hands-on demonstration of running Web services, inspecting SOAP traffic, WSDL definitions, and a little bit of Java code, but no Java coding. The focus is on the artchitecture itself, and on the roles that various protocols, APIs, tools, and application components play in a working Web service and/or client. The module can also be effective as a standalone seminar and introdution to Web services. (UDDI and JAXR for publishing and discovery are also included here, even though the remaining modules focus on development only.)

The second module develops an understanding of the Simple Object Access Protocol (SOAP) 1.1, and skills in using the Java API for XML Messaging (JAXM) and SOAP with Attachments API for Java (SAAJ) 1.1 to build SOAP-based Web services and clients. Students will learn to read SOAP and to write it by hand, and then will proceed to use the JAXM and SAAJ to develop servlets that respond to SOAP/HTTP messages. Intermediate and advanced techniques, such as integrating JAXP code with SAAJ, JSPs for Web services, and working with SOAP attachments, are also covered. The standard SOAP “Section 5” data encoding is studied in the module’s final chapter.

The final module teaches students how to develop Web services using SOAP, WSDL, and Java, with the help of the Java API for XML-Based RPC, or JAX-RPC. JAX-RPC abstracts almost all the details of SOAP messaging using WSDL as a description language for interface and implementation; this allows the Java developer to concentrate on application and service specifics. (In this way JAX-RPC is analogous to Java RMI and the EJB architecture, and SOAP/HTTP is treated as nothing more or less than an RPC transport protocol.) JAX-RPC specifies service development either from WSDL documents as a starting point or beginning with Java code and generating the WSDL for client use; this module addresses both possible development paths and analyzes their relative advantages. Also, both servlet and EJB endpoint models are studied, and the module concludes with exercises in handling SOAP headers and sharing message context information between various JAX-RPC classes.

 
Who Should Attend
 
Prerequisites
Experience in Java Programming, including object-oriented Java and the Java streams model, will be helpful, but is not necessary. All of the hands-on coding in this module is in instructor-led demonstrations, and the student can choose to participate or just to observe. Some understanding of XML and XML Schema will be helpful, but is not strictly necessary. Various related technology is discussed in the course: JAXP, SAX, DOM, XSLT, XPath, JSP and JSTL. None of these is a formal prerequisite for the course, and labs are built to allow students without experience in these things to work through successfully. Experience in these areas will be helpful, however.
 
Features of this Course
Interactive hands-on lab exercises.
 
Benefits of Attending this Class

Upon completion of this course, students should be able to:

During class, students will:

  • Describe the motivation for developing and using Web services in business software.
  • Describe the Web services architecture.
  • Describe common scenarios for Web-service implementation and client-side use.
  • Describe the Java Web services architecture:
  • Identify the Java specifications that relate to key Web-service protocols.
  • Identify the major models for Web-service endpoint implementation, and relate the Java Web services architecture to the Java 2 Enterprise platform.
  • Understand the importance of SOAP to the Web services architecture.
  • Learn the structure of SOAP and how it is designed to travel over existing standard protocols including HTTP, SMTP, and FTP.
  • Understand the role of the SOAP header in extending messaging capabilities and semantics, for instance for routing, security or transaction support.
  • Understand the role of JAXM and SAAJ in the Java Web services architecture.
  • Build a Java Web service as a JAXM/SAAJ servlet.
  • Implement simple point-to-point SOAP communications using JAXM and SAAJ from a standalone client application.
  • Mix and match SAAJ, SAX and DOM code in a Web-service implementation.
  • Implement a simple Web service using JSP and JSTL XML tags.
  • Implement a JSP Web-service client using custom tags that wrap JAXM.
  • Create, send, receive, and read SOAP attachments using SAAJ.
  • Understand the role of WSDL in providing type information for Web services.
  • Write WSDL documents to describe messages, interfaces and services.
  • Understand the role of the JAX-RPC in the Java Web services architecture.
  • Identify the alternatives for development paths through Java code and WSDL artifacts on server and client sides, and describe the advantages of each.
  • Understand the mapping of WSDL to Java classes and components.
  • Analyze Java domain models and identify the useful JAX-RPC mappings.
  • Add a SOAP interface to an existing Web application by generating SOAP messaging code using JAX-RPC tools.
  • Build a Web service based on an existing WSDL document.
  • Build a Web-service client based on a WSDL document.
  • Describe the relationship between the EJB 2.1 and JAX-RPC 1.0 specifications, and how EJBs can implement Web-service endpoints.
  • Add a SOAP interface to an existing system of EJBs, and build an EJB implementation of a Web service based on a predefined WSDL descriptor.
  • Describe the usefulness of SOAP headers in Web service design and implementation.
  • Describe the use of the JAX-RPC message context in reading and managing SOAP headers.
  • Implement a JAX-RPC message handler to adapt an existing Web service.
  • Implement a session-aware JAX-RPC Web service that relies on HTTP sessions
    based on cookies.
 
Course Contents

Module 1 – Overview of Java Web Services

1. The Web Services Architecture

Evolution of Web Services
Motivation for Web Services
HTTP and XML
Interoperability Stacks
The Wire Stack
Simple Object Access Protocol (SOAP)
The Description Stack
Web Service Description Language (WSDL)
The Discovery Stack
Universal Description, Discovery and Integration (UDDI)
Hosting Web Services: Scenarios
Demonstration: A Running Web Service and Client

2. The Java Web Services Architecture

Java and Web Services
Web Services and the J2EE
The Java API for XML Processing (JAXP)
The SOAP With Attachments API for Java (SAAJ)
The Java API for XML Messaging (JAXM)
Demonstration: A SOAP-Based Web Service Using JAXM and SAAJ
The Java API for XML-Based RPC (JAX-RPC)
Demonstration: A WSDL-Enabled Web Service Using JAX-RPC
WSDL-to-Java vs. Java-to-WSDL
The Java API for XML Registries (JAXR)
The Registry Server

3. Java Web Services Case Study

Multi-Tier Architecture
Moving to Web Services
Mapping Domain Classes Using JAX-RPC
Demonstration: Creating the SOAP Interface and Generating WSDL
Demonstration: Building the Client with JAX-RPC Stubs
The UDDI Information Model
White, Yellow and Green Pages
Demonstration: UDDI Publishing with JAXR
UDDI as a Web Service
Demonstration: Discovering a Web Service via UDDI

Module 2 – The Java APIs for SOAP Messaging

1. The Simple Object Access Protocol (SOAP)

SOAP Messaging Model
SOAP Namespaces
SOAP over HTTP
The SOAP Envelope
The Message Header
The Message Body
SOAP Faults
Attachments
XML Schema
Validating Message Content

2. The Java APIs for SOAP Messaging (SAAJ)

The SAAJ Object Model
Parsing a SOAP Message
Reading Message Content
Working with Namespaces
Creating a Message
Setting Message Content

3. The Java API for XML Messaging (JAXM)

Messaging Scenarios
Point-to-Point Messaging
JAXM Message Providers
The JAXM Messaging Model
Creating a Connection
Sending a Message

4. Parsing and Transformations

The Java API for XML Processing (JAXP)
SAX and DOM Parsing
XSLT Transformations
Piping Between SAAJ and JAXP
Streaming Between SAAJ and JAXP
Validating Request Content

5. Web Services and JSP

JSP and XML
The JSTL
Core and XML Actions
JSP, JSTL and SOAP
Reading SOAP Using XPath
JSPs as Web-Service Clients
Custom Tags for JAXM and SAAJ

6. SOAP Attachments

SAAJ Object Model, Revisited
The SOAPMessage Class
MIME
The Java Activation Framework
The MimeHeaders Class
The AttachmentPart Class
Adding SOAP Attachments
Identifying Attachments
Reading Attachments

7. SOAP Encoding

The Need for a Common Encoding
The SOAP Section-5 Encoding
Type Model
Relationship to XML Schema
Values
Accessors
Structures
Arrays
Multiple-Reference Values
Mapping SOAP Types to Java

Module 3 – The Java API for XML-Based RPC

1. Web Services Description Language (WSDL)

Web Services as Component-Based Software
The Need for an IDL
Web Services Description Language
WSDL Information Model
The Abstract Model - Service Semantics
Message Description
Messaging Styles
The Concrete Model - Ports, Services, Locations
Extending WSDL - Bindings
Service Description

2. The Java API for XML-Based RPC (JAX-RPC)

The Java Web Services Architecture
Two Paths
How It Works - Build Time and Runtime
Mapping Between WSDL/XML and Java
Generating from WSDL
Generating from Java
Which Way to Go?
Passing Objects
Another CORBA?

3. Generating Web Services from Java Code

The Java-to-XML Mapping
Primitive Types and Standard Classes
Value Types and JavaBeans
The Java-to-WSDL Mapping
Simple and Complex Types
Arrays and Enumerations
Service Endpoint Interface
Scope of Code Generation
Inheritance Support
Multi-Tier Application Design
Analyzing the Domain
When Things Don't Fit
Conversational State
Extensible Type Mapping

4. Generating Java Web Services from WSDL

The XML-to-Java Mapping
Simple and Complex Types
Enumerations
Arrays
Miscellaneous, Optionally-Supported Constructs
The WSDL-to-Java Mapping
Mapping Operation Inputs and Outputs
Building a Service Client
Locating a Service
Client-Side Validation
Creating a Web Service
XML and WSDL Design Guidelines
Deploying the Service

5. Web Services and EJB

Enterprise JavaBeans
Three Tiers for J2EE
EJB 2.1 and JAX-RPC
Session Beans as Web Service Endpoints
How It Works - Build Time and Runtime
The Bean's Service Endpoint Interface
SOAP as an RMI Transport
Adding a SOAP Interface to a Session Bean
Generating From WSDL
" Gotchas"

6. Message Context and Message Handlers

SOAP Headers
Handling SOAP Headers
Servlet Endpoint Context
EJB Endpoint Context
Using SAAJ
JAX-RPC Message Handlers
Handler Chains
Processing Model and Patterns
Using JAXP
Session Management

 
 
 
Disclaimer: HP-UX, Tru64 Unix, OpenVMS and are registered trademarks of the Hewlett Packard Corporation. Solaris and Java are registered trademarks of Sun Corporation. AIX is a registered trademark of IBM. Oracle is aregistered trademark of Oracle Corporation.