The JavaTM Web Services Tutorial
Home  

Contents

Preface

Who Should Use This Tutorial
About the Examples
Prerequisites for the Examples
Running the Examples
Related Information
How to Print This Tutorial
Typographical Conventions

Introduction to Web Services

The Role of XML and the Java Platform
What Is XML?
What Makes XML Portable?
Overview of the Java APIs for XML
JAXP
The SAX API
The DOM API
The XSLT API
JAX-RPC
Using JAX-RPC
JAXM
Getting a Connection
Creating a Message
Populating a Message
Sending a Message
JAXR
Using JAXR
Sample Scenario
Scenario
Conclusion

Understanding XML

Introduction to XML
What Is XML?
Why Is XML Important?
How Can You Use XML?
XML and Related Specs: Digesting the Alphabet Soup
Basic Standards
Schema Standards
Linking and Presentation Standards
Knowledge Standards
Standards That Build on XML
Summary
Designing an XML Data Structure
Saving Yourself Some Work
Attributes and Elements
Normalizing Data
Normalizing DTDs

Getting Started With Tomcat

Setting Up
Getting the Example Code
Checking the Environment Variables
Creating the Getting Started Application
The Converter Class
The Web Client
Building and Deploying the Getting Started Application Using Ant
Setting the CLASSPATH
Creating the Build File for Ant
Compiling the Source Files
Deploying the Application
Running the Getting Started Application
Starting Tomcat
Running the Web Client
Shutting Down Tomcat
Modifying the Application
Modifying a Class File
Modifying the Web Client
Reloading the Application
Common Problems and Their Solutions
Compilation Errors
Deployment Errors

Java API for XML Processing

The JAXP APIs
An Overview of the Packages
The Simple API for XML (SAX) APIs
The SAX Packages
The Document Object Model (DOM) APIs
The DOM Packages
The XML Stylesheet Language for Transformation (XSLT) APIs
The XSLT Packages
Where Do You Go from Here?

Simple API for XML

Writing a Simple XML File
Creating the File
Writing the Declaration
Adding a Comment
Adding Nested Elements
Adding HTML-Style Text
Adding an Empty Element
The Finished Product
Echoing an XML File with the SAX Parser
Creating the Skeleton
Importing Classes
Setting up for I/O
Implementing the ContentHandler Interface
Setting up the Parser
Writing the Output
Spacing the Output
Handling Content Events
Compiling and Running the Program
Command Scripts
Checking the Output
Identifying the Events
Compressing the Output
Inspecting the Output
Documents and Data
Adding Additional Event Handlers
Identifying the Document's Location
Handling Processing Instructions
Summary
Handling Errors with the Nonvalidating Parser
Substituting and Inserting Text
Handling Special Characters
Using an Entity Reference in an XML Document
Handling Text with XML-Style Syntax
Handling CDATA and Other Characters
Creating a Document Type Definition (DTD)
Basic DTD Definitions
Defining Text and Nested Elements
Limitations of DTDs
Special Element Values in the DTD
Referencing the DTD
DTD's Effect on the Nonvalidating Parser
Tracking Ignorable Whitespace
Cleanup
Documents and Data
Empty Elements, Revisited
Defining Attributes and Entities in the DTD
Defining Attributes in the DTD
Defining Entities in the DTD
Echoing the Entity References
Additional Useful Entities
Referencing External Entities
Echoing the External Entity
Summarizing Entities
Referencing Binary Entities
Using a MIME Data Type
The Alternative: Using Entity References
Using the Validating Parser
Configuring the Factory
Changing the Environment Variable
Experimenting with Validation Errors
Error Handling in the Validating Parser
Defining Parameter Entities and Conditional Sections
Creating and Referencing a Parameter Entity
Conditional Sections
Parsing the Parameterized DTD
DTD Warnings
Handling Lexical Events
How the LexicalHandler Works
Working with a LexicalHandler
Using the DTDHandler and EntityResolver
The DTDHandler API
The EntityResolver API

Document Object Model

Reading XML Data into a DOM
Creating the Program
Additional Information
Looking Ahead
Displaying a DOM Hierarchy
Echoing Tree Nodes
Convert DomEcho to a GUI App
Create Adapters to Display the DOM in a JTree
Finishing Up
Examining the Structure of a DOM
Displaying A Simple Tree
Displaying a More Complex Tree
Finishing Up
Constructing a User-Friendly JTree from a DOM
Compressing the Tree View
Acting on Tree Selections
Handling Modifications
Finishing Up
Creating and Manipulating a DOM
Obtaining a DOM from the Factory
Normalizing the DOM
Other Operations
Finishing Up
Using Namespaces
Defining a Namespace
Referencing a Namespace
Defining a Namespace Prefix

XML Stylesheet Language for Transformations

Introducing XSLT and XPath
The XSLT Packages
How XPath Works
Summary
Writing Out a DOM as an XML File
Reading the XML
Creating a Transformer
Writing the XML
Writing Out a Subtree of the DOM
Summary
Generating XML from an Arbitrary Data Structure
Creating a Simple File
Creating a Simple Parser
Modifying the Parser to Generate SAX Events
Using the Parser as a SAXSource
Doing the Conversion
Transforming XML Data with XSLT
Defining an Ultra-Simple article Document Type
Creating a Test Document
Writing an XSLT Transform
Processing the Basic Structure Elements
Writing the Basic Program
Trimming the Whitespace
Processing the Remaining Structure Elements
Process Inline (Content) Elements
Printing the HTML
What Else Can XSLT Do?
Concatenating XSLT Transformations with a Filter Chain
Writing the Program
Understanding How it Works
Testing the Program
Conclusion

Java API for XML Messaging

Overview of JAXM
Messages
Connections
Messaging Providers
Running the Samples
The Sample Programs
The Provider Administration Tool
Tutorial
Client without a Messaging Provider
Client with a Messaging Provider
Adding Attachments
Code Examples
Request.java
MyUddiPing.java

Java API for XML-based RPC

What is JAX-RPC?
A Simple Example: HelloWorld
HelloWorld at Runtime
HelloWorld Files
Overview of Steps
Setting Up
Coding the Service Definition Interface and Implementation Class
Compiling the Service Definition Code
Creating the Configuration File
Generating the Stubs and Ties
Creating the Deployment Descriptor
Packaging the Service Definition
Deploying the Service Definition
Coding the Client
Compiling the Client Code
Running the Client
The Dynamic Invocation Interface
When to Use DII
A DII Client Example

Java API for XML Registries

Overview of JAXR
What is a Registry?
What Is JAXR?
JAXR Architecture
Implementing a JAXR Client
Establishing a Connection
Querying a Registry
Managing Registry Data
Running the Client Examples
Using the Registry Browser
Querying a Registry
Managing Registry Data

The Java WSDP Registry Server

Setting Up the Registry Server
Using the JAXR Registry Browser with the Registry Server
Adding Organizations
Querying the Registry
Using the Command Line Client Scripts with the Registry Server
Using the JAXR API to Access the Registry Server
Using the Indri Tool to Access the Registry Server Database

Web Applications

Web Application Life Cycle
Web Application Archives
Creating a WAR File
Web Application Deployment Descriptors
Prolog
Context Parameters
Filter Mappings
Event Listeners
Alias Paths
Error Mappings
References to Environment Entries, Resource Environment Entries, or Resources
Deploying Web Applications
Specifying the Web Application Context
Example
Running Web Applications
Updating Web Applications
Internationalizing and Localizing Web Applications
Accessing Databases from Web Applications
The Examples
Downloading and Starting the Database Server
Populating the Database
Configuring the Web Application to Use the Database
Configuring the Server to Recognize the Database

Java Servlet Technology

What is a Servlet?
The Example Servlets
Troubleshooting
Servlet Life Cycle
Handling Servlet Life Cycle Events
Handling Errors
Sharing Information
Using Scope Objects
Controlling Concurrent Access to Shared Resources
Accessing Databases
Initializing a Servlet
Writing Service Methods
Getting Information From Requests
Constructing Responses
Filtering Requests and Responses
Programming Filters
Programming Customized Requests and Responses
Specifying Filter Mappings
Invoking Other Web Resources
Including Other Resources in the Response
Transferring Control to Another Web Component
Accessing the Web Context
Maintaining Client State
Accessing a Session
Associating Attributes with a Session
Session Management
Session Tracking
Finalizing a Servlet
Tracking Service Requests
Notifying Methods to Shut Down
Creating Polite Long-Running Methods

JavaServer Pages Technology

What is a JSP Page?
The Example JSP Pages
The Life Cycle of a JSP Page
Translation and Compilation
Execution
Initializing and Finalizing a JSP Page
Creating Static Content
Creating Dynamic Content
Using Objects Within JSP Pages
JSP Scripting Elements
Including Content in a JSP Page
Transferring Control to Another Web Component
Param Element
Including an Applet
Extending the JSP Language

JavaBeans Components in JSP Pages

JavaBeans Component Design Conventions
Why Use a JavaBeans Component?
Creating and Using a JavaBeans Component
Setting JavaBeans Component Properties
Retrieving JavaBeans Component Properties

Custom Tags in JSP Pages

What is a Custom Tag?
The Example JSP Pages
Using Tags
Declaring Tag Libraries
Making the Tag Library Implementation Available
Types of Tags
Defining Tags
Tag Handlers
Tag Library Descriptors
Simple Tags
Tags With Attributes
Tags With Bodies
Tags That Define Scripting Variables
Cooperating Tags
Examples
An Iteration Tag
A Template Tag Library
How Is a Tag Handler Invoked?

JavaServer Pages Standard Tag Library

The Example JSP Pages
Using JSTL
Expression Language Support
Twin Libraries
Specifying an Expression Language Evaluator
Simplest Possible Expression Language (SPEL)
Tag Collaboration
Core Tags
Expression Tags
Flow Control Tags
Import Tags
XML Tags
Core Tags
Flow Control Tags
Transformation Tags
Internationalization Tags
Messaging Tags
Formatting Tags
SQL Tags
query Tag Result-Related Interfaces

The xrpcc Tool

Syntax
Configuration File
Starting With RMI Interfaces
Starting With a WSDL Document
Specifying the Type Mapping

HTTP Overview

HTTP Requests
HTTP Responses

Java Encoding Schemes

Bios For Contributing Authors

Home