SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
The Java Web Services Tutorial is a comprehensive, example-driven, "roll up your sleeves and dive in" guide to building Web services applications with Java technology. This edition provides a head start on using the Java Web Services Developer Pack (WSDP) from Sun Microsystems. This complete, ready-to-use package includes a variety of technologies and tools required to build and deploy comprehensive Web services applications today.
Web services offer powerful new ways for enterprises to effectively communicate with each other using diverse computing hardware. This paradigm takes the Java platform's "Write Once, Run Anywhere" capabilities to a new level by providing a completely portable data model. By supporting the latest standards for XML-based Web services, the Java APIs for XML make it easy to build Web services with minimal hand tweaking of data. This tutorial explains these APIs in detail and provides practical examples to reinforce your understanding of key concepts.
The accompanying CD-ROM includes:
This package also includes instructions for deploying Web services applications on the Java 2 SDK, Enterprise Edition.
An Introductory Tutorial on Web Services, Java and XML
Foreword.
Preface.
1. 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.
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.
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.
Cannot Start the Tomcat Server.
Compilation Errors.
Deployment Errors.
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.
Compiling and Running the Programs.
Where Do You Go from Here?
Writing a Simple XML File.
Creating the File.
Writing the Declaration.
Adding a Comment.
Defining the Root Element.
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.
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.
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.
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.
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.
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.
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.
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 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.
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 Response.
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.
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 Component Design Conventions.
Why Use a JavaBeans Component?
Creating and Using a JavaBeans Component.
Setting JavaBeans Component Properties.
Retrieving JavaBeans Component Properties.
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?
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.
Syntax.
Configuration File.
Starting with RMI Interfaces.
Starting with a WSDL Document.
Specifying the Type Mapping.
HTTP Requests.
HTTP Responses.
The Java™ Web Services Tutorial is a beginner's guide to developing Web services and Web applications using the Java Web Services Developer Pack (Java WSDP). The Java WSDP is an all-in-one download containing key technologies to simplify building of Web services using the Java 2 Platform. The technologies available on the Java WSDP are:
To provide a development and deployment environment, the Java WSDP includes the:
Here we cover all the things you need to know to make the best use of The Java™ Web Services Tutorial.
Who Should Use This TutorialThis tutorial is intended for programmers interested in developing and deploying Web services and Web applications on the Java WSDP.
About the ExamplesThis tutorial includes many complete, working examples.
To understand the examples you will need a good knowledge of the Java programming language, SQL, and relational database concepts. The following topics in the Java Tutorial are particularly relevant:
This section tells you everything you need to know to obtain, build, deploy, and run the examples.
If you are viewing this online, you need to download The Java Web™ Services Tutorial from:
http://java.sun.com/webservices/downloads/webservicestutorial.htmlOnce you have installed the tutorial bundle, the example source code is in the <JWSDP_HOME>/docs/tutorial/examples directory, with subdirectories for each of the technologies included in the pack.
This tutorial documents the Java WSDP EA1. To build, deploy, and run the examples you need a copy of the Java WSDP and the Java 2 Platform, Standard Edition (J2SE™) SDK 1.3.1 or 1.4. You can download the Java WSDP from:
http://java.sun.com/webservices/downloads/webservicespack.htmlthe J2SE 1.3.1 SDK from:
http://java.sun.com/j2se/1.3/or the J2SE 1.4 SDK from:
http://java.sun.com/j2se/1.4/Most of the examples are distributed with a configuration file for version 1.4.1 of ant, a portable build tool contained in the Java WSDP. Directions for building the examples are provided in each chapter.
Most of the Java WSDP examples run on Tomcat. Before you can run an example you must first deploy it on Tomcat. To deploy an application execute ant deploy. The deploy task usually copies some files into the <JWSDP_HOME>/webapps directory. Some things you need to keep in mind:
You run Tomcat by executing the startup script in a terminal window.
You reload an application with the command:
This command invokes the manager Web application. Before you can use this application you must add your user name and password combination and associate the role name manager with it to <JWSDP_HOME>/conf/tomcat-users.xml, which can be edited with any text editor. This file contains an element <user> for each individual user, which might look something like this: The Tomcat reference documentation distributed with the Java WSDP contains information about the manager application. For further information on the technologies discussed in this tutorial see the reference documentation contained in the Java WSDP (<JWSDP_HOME>/docs/index.html). References to individual technology homes listed in some chapters map as follows:
0201768119P03262002