Home > Articles > Programming > Java

J2EE-Supported Web Service Standards and Technologies

Just getting going with Web services, and planning to use Java? In this sample chapter, you'll earn about the various Web service standards (including XML, SOAP, WSDL, and UDDI) and the J2EE 1.4 platform technologies that support those standards. You'll also be introduced to a new alphabet soup of J2EE platform XML-related APIs, including JAXP, JAXR, JAX-RPC, and SAAJ, with a high-level architectural point of view.
This chapter is from the book

This chapter describes current, universally accepted Web Service standards and the J2EE platform's support for these standards. The Web services computing paradigm enables applications and services running on different platforms to easily communicate and interoperate with each other. To be so widely accepted, the paradigm must give service implementors flexibility in their implementation approach. Just as important, each such implementation must be assured that it can work with another implementation. Proven technologies facilitate Web service development, and these sorts of accepted standards enable interoperability.

2.1 Overview of Web Service Standards

Standards differ from technologies. Standards are a collection of specifications, rules, and guidelines formulated and accepted by the leading market participants. While these rules and guidelines prescribe a common way to achieve the standard's stated goal, they do not prescribe implementation details. Individual participants devise their own implementations of an accepted standard according to the standard's guidelines and rules. These various implementations of a standard by different vendors give rise to a variety of technologies. However, despite the implementation detail differences, the technologies can work together if they have been developed according to the standard's specifications.

For Web services to be successful, the Web service standards must be widely accepted. To enable such wide acceptance, the standards used for Web services and the technologies that implement those standards should meet the following criteria:

  • A Web service should be able to service requests from any client regardless of the platform on which the client is implemented.

  • A client should be able to find and use any Web service regardless of the service's implementation details or the platform on which it runs.

Standards establish a base of commonality and enable Web services to achieve wide acceptance and interoperability. Standards cover areas such as:

  • Common markup language for communication— To begin with, service providers, who make services available, and service requestors, who use services, must be able to communicate with each other. Communication mandates the use of a common terminology, or language, through which providers and requestors talk to one another. A common markup language facilitates communication between providers and requestors, as each party is able to read and understand the exchanged information based on the embedded markup tags. Although providers and requestors can communicate using interpreters or translators, using interpreters or translators is impractical because such intermediary agents are inefficient and not cost effective. Web services use eXtensible Markup Language (XML) for the common markup language.

  • Common message format for exchanging information— Although establishing a common markup language is important, by itself it is not sufficient for two parties (specifically, the service providers and service requestors) to properly communicate. For effective communication, the parties must be able to exchange messages according to an agreed-upon format. By having such a format, parties who are unknown to each other can communicate effectively. Simple Object Access Protocol (SOAP) provides a common message format for Web services.

  • Common service specification formats— In addition to common message formats and markup language, there must be a common format that all service providers can use to specify service details, such as the service type, how to access the service, and so forth. A standard mechanism for specifying service details enables providers to specify their services so that any requestor can understand and use them. For example, Web Services Description Language (WSDL) provides Web services with common specification formats.

  • Common means for service lookup— In the same way that providers need a common way to specify service details, service requestors must have a common way to look up and obtain details of a service. This is accomplished by having common, well-known locations where providers can register their service specifications and where requestors know to go to find services. By having these common, well-known locations and a standard way to access them, services can be universally accessed by all providers and requestors. Universal Description, Discovery, and Integration (UDDI) specification defines a common means for looking up Web services.

Although they do not exhaustively discuss these basic standards, the next sections provide enough information about the standards to enable further discussion about the J2EE technologies that implement them. For complete details, see the reference section at the end of this chapter. In addition to these basic standards, more complex Web services that implement enterprise-level processes need standards for security, transactions, process flow control, and so forth.

2.1.1 Extensible Markup Language

The eXtensible Markup Language (XML), a standard accepted throughout the industry, enables service providers and requestors to communicate with each other in a common language. XML is not dependent on a proprietary platform or technology, and messages in XML can be communicated over the Internet using standard Internet protocols such as HTTP. Because XML is a product of the World Wide Web Consortium (W3C) body, changes to it will be supported by all leading players. This ensures that as XML evolves, Web services can also evolve without backward compatibility concerns.

XML is a simple, flexible, text-based markup language. XML data is marked using tags enclosed in angled brackets. The tags contain the meaning of the data they mark. Such markup allows different systems to easily exchange data with each other. This differs from tag usage in HTML, which is oriented to displaying data. Unlike HTML, display is not inherent in XML. Code Example 2.1 shows the code from an XML document representing an individual's contact information.

Example 2.1. XML Document Example

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
    <Name>John Doe</Name>
        <Street>4140 Network Circle</Street>
        <City>Santa Clara</City>

A Document Type Definition (DTD) or XML Schema Definition (XSD) describes the structure of an XML document. It has information on the tags the corresponding XML document can have, the order of those tags, and so forth. An XML document can be validated against its DTD or its XSD. Validating an XML document ensures that the document follows the structure defined in its DTD or XSD and that it has no invalid XML tags. Thus, systems exchanging XML documents for some purpose can agree on a single DTD or XSD and validate all XML documents received for that purpose against the agreed-upon DTD/XSD before processing the document. Code Example 2.2 is the DTD for the XML document in Code Example 2.1.

Example 2.2. Document Type Definition

<!ELEMENT ContactInformation (Name, Address, HomePhone, EMail)>
<!ELEMENT Address (Street, City, State, Country)>
<!ELEMENT Country (#PCDATA)>
<!ELEMENT HomePhone (#PCDATA)>

Unfortunately, DTDs are an inadequate way to define XML document formats. For example, DTDs provide no real facility to express data types or complex structural relationships. XML schema definitions standardize the format definitions of XML documents. Code Example 2.4 shows the XSD schema for the sample XML document in Code Example 2.3.

Example 2.3. XML Document

<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
   <Name>John doe</Name>
   <Street>4140 Network Circle</Street>
   <City>Santa Clara</City>

Example 2.4. XSD Schema

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns=" http://simple.example.com/CInfoXmlDoc"
   <xsd:element name="ContactInformation">
   <xsd:element name="Name" type="xsd:string" />
   <xsd:element name="Address">
   <xsd:element name="Street"
   type="xsd:string" />
   <xsd:element name="City"
   type="xsd:string" />
   <xsd:element name="State"
   type="xsd:string" />
   <xsd:element name="Country"
   type="xsd:string" />
   <xsd:element name="HomePhone" type="xsd:string" />
   <xsd:element name="EMail" type="xsd:string" />

When considering XML schemas, it is important to understand the concept of XML namespaces. To enable using the same name with different meanings in different contexts, XML schemas may define a namespace. A namespace is a set of unique names that are defined for a particular context and that conform to rules specific for the namespace. Since a namespace is specific to a particular context, each namespace is unrelated to any other namespace. Thus, the same name can be used in different namespaces without causing a duplicate name conflict. XML documents, which conform to an XML schema and have multiple elements and attributes, often rely on namespaces to avoid a collision in tag or attribute names or to be able to use the same tag or attribute name in different contexts.

Technically speaking, an XML namespace defines a collection of names and is identified by a URI reference. (Notice in Code Example 2.4 the code xmlns="http://simple.example.com/CInfoXmlDoc". Code such as this indicates that the XML schema defines a namespace for the various elements and attributes in the document.) Names in the namespace can be used as element types or attributes in an XML document. The combination of URI and element type or attribute name comprises a unique universal name that avoids collisions.

For example, in Code Example 2.4, there is a namespace that defines the ContactInformation document's element types, such as Name and Address. These element types are unique within the contact information context. If the document included another namespace context, such as BankInformation that defined its own Name and Address element types, these two namespaces would be separate and distinct. That is, a Name and Address used in the context of BankInformation would not conflict with a name and address used in the context of ContactInformation.

2.1.2 Simple Object Access Protocol

XML solves the need for a common language, and the Simple Object Access Protocol (SOAP) fills the need for a common messaging format. SOAP enables objects not known to one another to communicate; that is, to exchange messages. SOAP, a wire protocol similar to Internet Inter-ORB Protocol (IIOP) and Java Remote Method Protocol (JRMP), is a text-based protocol that uses an XML-based data encoding format and HTTP/SMTP to transport messages. SOAP is independent of both the programming language and the operational platform, and it does not require any specific technology at its endpoints, making it completely agnostic to vendors, platforms, and technologies. Its text format also makes SOAP a firewall-friendly protocol. Moreover, SOAP is backed by leading industrial players and can be expected to have universal support.

To enable message exchanges, SOAP defines an envelope, which contains a SOAP body, within which the message is included, and an optional SOAP-specific header. The whole envelope—body plus header—is one complete XML document. (See Figure 2.1.)

02fig01.gifFigure 2.1 SOAP Message Structure32030 Figure caption Figure 2.1 SOAP Envelope

The header entries may contain information of use to recipients, and these header entries may also be of use to intermediate processors since they enable advanced features. The body, which contains the message contents, is consumed by the recipient. SOAP is agnostic about the message contents; the only restriction is that the message be in XML format.

Code Example 2.5 shows a simple but complete example of a SOAP request for obtaining a stock quote.

Example 2.5. Example SOAP Request

<SOAP-ENV:Envelope xmlns:SOAP-ENV="SoapEnvelopeURI"
        <m:GetLastTradePrice xmlns:m="ServiceURI">

This example shows how a SOAP message is encoded using XML and illustrates some SOAP elements and attributes. All SOAP messages must have an Envelope element and must define two namespaces: One namespace connotes the SOAP envelope (xmlns:SOAP-ENV) and the other indicates the SOAP encoding (SOAP-ENV:encodingStyle). SOAP messages without proper namespace specification are considered invalid messages. The encodingStyle attribute is important, as it is used to specify serialization rules for the SOAP message. Moreover, there can be no DTD referrals from within SOAP messages.

While optional, the Header element when used should be the first immediate child after the Envelope. The Header element provides a way to extend the SOAP message by specifying additional information such as authentication and transactions. Specifying this additional information as part of the Header tells the message recipient how to handle the message.

There are many attributes that can be used in the SOAP Header element. For example, the actor attribute of the Header element enables a SOAP message to be passed through intermediate processes enroute to its ultimate destination. When the actor attribute is absent, the recipient is the final destination of the SOAP message. Similarly, many other attributes may be used. However, this chapter does not address these details.

The Body element, which must be present in all SOAP messages, must follow immediately after the Header element, if it is present. Otherwise, the Body element must follow immediately after the start of the Envelope element. The Body contains the specification of the actual request (such as method calls). The Fault element in the SOAP Body enables error handling for message requests.

Note that this chapter does not discuss details of Header elements, attributes, and other additional features, such as SOAP with attachments and binding HTTP, although they are part of the SOAP standard. Interested readers should refer to the SOAP specifications.

2.1.3 Registry Standards

The Universal Description, Discovery, and Integration (UDDI) specification defines a standard way for registering, deregistering, and looking up Web services. UDDI is a standards-based specification for Web service registration, description, and discovery. Similar to a telephone system's yellow pages, a UDDI registry's sole purpose is to enable providers to register their services and requestors to find services. Once a requestor finds a service, the registry has no more role to play between the requestor and the provider.

Figure 2.2 shows how UDDI enables dynamic description, discovery, and integration of Web services. A Web service provider registers its services with the UDDI registry. A Web service requestor looks up required services in the UDDI registry and, when it finds a service, the requestor binds directly with the provider to use the service.

02fig02.gifFigure 2.2 Role of a Registry in a Web Service93783 Figure caption Figure 1.2 UDDI

The UDDI specification defines an XML schema for SOAP messages and APIs for applications wanting to use the registry. A provider registering a Web service with UDDI must furnish business, service, binding, and technical information about the service. This information is stored in a common format that consists of three parts:

  1. White pages— describe general business information such as name, description, phone numbers, and so forth

  2. Yellow pages— describe the business in terms of standard taxonomies. This information should follow standard industrial categorizations so that services can be located by industry, category, or geographical location.

  3. Green pages— list the service, binding, and service-specific technical information

The UDDI specification includes two categories of APIs for accessing UDDI services from applications:

  1. Inquiry APIs— enable lookup and browsing of registry information

  2. Publishers APIs— allow applications to register services with the registry

UDDI APIs behave in a synchronous manner. In addition, to ensure that a Web service provider or requestor can use the registry, UDDI uses SOAP as the base protocol. Note that UDDI is a specification for a registry, not a repository. As a registry it functions like a catalog, allowing requestors to find available services. A registry is not a repository because it does not contain the services itself.

2.1.4 Web Services Description Language

The Web Services Description Language (WSDL) defines a standard way for specifying the details of a Web service. It is a general-purpose XML schema that can be used to specify details of Web service interfaces, bindings, and other deployment details. By having such a standard way to specify details of a service, clients who have no prior knowledge of the service can still use that Web service.

WSDL specifies a grammar that describes Web services as a collection of communication endpoints, called ports. The data being exchanged are specified as part of messages. Every type of action allowed at an endpoint is considered an operation. Collections of operations possible on an endpoint are grouped together into port types. The messages, operations, and port types are all abstract definitions, which means the definitions do not carry deployment-specific details to enable their reuse.

The protocol and data format specifications for a particular port type are specified as a binding. A port is defined by associating a network address with a reusable binding, and a collection of ports define a service. In addition, WSDL specifies a common binding mechanism to bring together all protocol and data formats with an abstract message, operation, or endpoint. See Figure 2.3.

02fig03.gifFigure 2.3 WSDL Service Description35272 Figure caption Figure 2.3

Code Example 2.6 shows a WSDL document for a weather Web service that returns a given city's weather information. The Web service, which uses SOAP as the communication protocol, expects to receive the city name as String type data and sends String type data as its response.

Example 2.6. WSDL Document for Weather Web Service

<?xml version="1.0" encoding="UTF-8"?>
<definitions name="WeatherWebService"
   <message name="WeatherService_getWeather">
      <part name="String_1" type="xsd:string"/>
   <message name="WeatherService_getWeatherResponse">
      <part name="result" type="xsd:string"/>
   <portType name="WeatherService">
      <operation name="getWeather" parameterOrder="String_1">
         <input message="tns:WeatherService_getWeather"/>
   <binding name="WeatherServiceBinding"
      <operation name="getWeather">
            <soap:body use="literal"
            <soap:body use="literal"
         <soap:operation soapAction=""/></operation>
   <service name="WeatherWebService">
      <port name="WeatherServicePort"

A complete WSDL document consists of a set of definitions starting with a root definitions element followed by six individual element definitions—types, message, portType, binding, port, and service—that describe the services.

  • The types element defines the data types contained in messages exchanged as part of the service. Data types can be simple, complex, derived, or array types. Types, either schema definitions or references, that are referred to in a WSDL document's message element are defined in the WSDL document's type element.

  • The message element defines the messages that the Web service exchanges. A WSDL document has a message element for each message that is exchanged, and the message element contains the data types associated with the message.

  • The portType element specifies, in an abstract manner, operations and messages that are part of the Web service. A WSDL document has one or more portType definitions for each Web service it defines.

  • The binding element binds the abstract port type, and its messages and operations, to a transport protocol and to message formats.

  • The service and port elements together define the name of the Web service and, by providing a single address for binding, assign an individual endpoint for the service. A port can have only one address. The service element groups related ports together and, through its name attribute, provides a logical name for the service.

This description is for a simple WSDL document. Each element definition has various attributes and WSDL has additional features, such as fault handling. WSDL also specifies how to bind directly with HTTP/MIME, SMTP/MIME, and so forth, but these are beyond the scope of the current discussion. For more details, see the WSDL specification available at http://www.w3c.org/TR/wsdl.

2.1.5 Emerging Standards

So far we have examined existing standards, which meet the needs of simple Web services. Organizations that cross various industries have been formed to create and promote cross-platform standards. The Web Services Interoperability Organization (WS-I) is one such group. WS-I has published a WS-I Basic Profile that defines a set of cross-platform standards, such as those just examined, to promote and ensure interoperability. But other standards are required to address issues for Web services that handle complex business processes. These issues include strict security requirements, business processes interacting with other business processes and having long-lived transactions or transactions that span multiple business processes, or business processes nested within other processes. These business processes must also execute properly even when run on different platforms. Various standards bodies and organizations such as WS-I are currently working on these standards. Since these standards are still being defined and it is not yet clear which standards will be accepted as universal, we do not go into the details of emerging standards.

Now that we have examined the Web service standards, let's go on to see how J2EE supports these accepted standards.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020