Web Services Standards for Java and J2EE


In order to use web services from Java, you need to be able to access web services provided by others from Java, as well as create web services others can use from J2EE components.

For a Java or J2EE application to act as a client of a web service, a mapping between the WSDL description of the service and Java is needed. The Java API for XML-Based RPC (also known as JAX-RPC) defines the mappings between WSDL portTypes and Java interfaces, as well as between Java and XML Schema types. You can learn more about JAX-RPC at http://java.sun.com/xml/jaxrpc/.

You can use a J2EE component to implement a web service. This is accomplished by creating a WSDL description that defines the component's interface and binding information, and then providing the infrastructure in the application server required to accept requests on the service. The J2EE standard for this capability is Web Services for J2EE also known as JSR-109. You can learn more about this standard at http://www.jcp.org/en/jsr/detail?id=109.

JAX-RPC addresses the use of WSDL-based web services in a J2SE environment. JSR-109 addresses how JAX-RPC is to be used in a J2EE environment, placing restrictions on JAX-RPC functions that are inappropriate in a managed environment. JSR-109 also specifies the deployment information to be used by J2EE containers to define a web service implementation, as well as the deployment information used by a client in a managed environment to access a web service.

In the case of WebSphere version 5.0, these standards are implemented on a J2EE 1.3-compliant runtime. These standards are expected to be included in J2EE 1.4. Following these standards should lead to portable web services applications and clients that can be used with any J2EE 1.4-compliant product.

The example in this chapter makes the Catalog EJB in the Plants-By-WebSphere application available as a web service so businesses everywhere can access the catalog. After that, a web services client application is developed that accesses the catalog.

Roadmap to the Specifications

Here's a roadmap to the JAX-RPC and JSR-109 specifications that highlight the sections that are of interest and relevance to you as a web services developer. You should start with JSR-109, since it places JAX-RPC in a J2EE perspective. You can think of JSR-109 as the introductory and conceptual material, and JAX-RPC as reference material for detailed information on APIs and mapping.

Web Services for J2EE (JSR-109)

The entire specification is only 74 pages long, and contains a wealth of information, so you might consider reading the entire thing. You can find it at http://www.jcp.org/en/jsr/detail?id=109. Here's an overview:

  • Chapters 1-3, Introduction, Objectives, and Overview
    These chapters describe the history, goals, conceptual architecture, benefits, and requirements for the use of web services in J2EE. They also introduce the client and server programming models for web services. The material is presented in an informal manner and is worthwhile reading.

  • Chapter 4, The Client Programming Model
    This chapter covers the use of the JAX-RPC client-programming model in a J2EE environment. Be sure to read the Initial Concepts section. The remainder of the chapter is client programming model reference material that can be read as needed while developing your web services client.

  • Chapter 5, Server Programming Model
    The Port Component Model Specification (section 5.3) is essential conceptual material for implementing a web service with a J2EE component. Components currently supported by this standard are stateless session EJBs and JavaBeans in a web container.

  • Chapter 6, Handlers
    Handlers can make transformations on messages as they pass in or out of a client or server. The concepts section explains when and why you might want to use them. The remainder discusses the handler APIs. This chapter is advanced material and can be skipped.

  • Chapter 7, Deployment Descriptors
    Describes the Developer, Assembler, and Deployer roles for providing, packaging, and interpreting JSR-109 deployment descriptors, as well as annotated DTDs for the new deployment descriptors. This is reference information that is used when developing a web services implementation in J2EE.

  • Chapter 8, Deployment
    This is information for implementers of JSR-109, and need not be read unless you need to troubleshoot your web services assembly.

  • Chapter 9, Security
    This chapter discusses the existing J2EE security mechanisms and how they apply to web services.

Java API for XML-Based RPC (JAX-RPC)

The JAX-RPC specification is twice as long as JSR-109, and much of the material it contains can be considered reference material for JSR-109. You can find it at http://java.sun.com/xml/jaxrpc/.

  • Chapters 1 and 2, Introduction and JAX-RPC Use Case
    Explains terminology and mechanisms used. The material is introductory in nature, and complements the material in this book.

  • Chapter 3, Requirements
    Captures the rationale for the specification. It is interesting, but non-essential background material.

  • Chapters 4 and 5, WSDL/XML to Java Mappings and Java to XML/WSDL Mappings
    These chapters are essential reference material when you need to understand why certain transformations were made when mapping from Java to WSDL or vice-versa, what exactly can be transformed, which transformations are covered by the specification, and which are left to the vendor.

  • Chapter 6, SOAP Binding
    Explains the mapping for encoded versus literal use and RPC versus document style. This is the reference information needed primarily when using WSDL that wasn't generated using the JAX-RPC mappings.

  • Chapters 7 and 8, SOAP Message with Attachments and JAX-RPC Core APIs
    Contain reference information.

  • Chapter 9, Service Client Endpoint Model
    Discusses the client programming model, including a summary of JSR-109 Chapter 4.

  • Chapter 10, Service Endpoint Model
    Discusses the J2SE implementation of a web service using a servlet. This model is not supported by JSR-109, so this chapter isn't relevant to WebSphere.

  • Chapters 11, 12, and 13, Service Context, Message Handlers, and JAX-RPC Runtime Services
    These chapters are largely superceded by JSR-109. Chapters 11 and 12 are useful reference information when you're trying to implement JSR-109 Handlers.

  • Chapter 14, Interoperability
    Discusses interoperability considerations with web services not hosted by JAX-RPC. This is good information to read before deploying a service for public access.

  • Chapter 15, Extensible Type Mapping
    Describes the APIs used to register and locate custom serializers and deserializers that enable the use of customer-determined mappings between Java objects and XML. Unfortunately, there is no standard API for the serializers and deserializers themselves – anything you write at this point would be proprietary to a JAX-RPC implementation. For that reason, JSR-109 does not support the use of these JAX-RPC APIs.

  • Chapter 16, Futures
    This is a one-page chapter summarizing work that remains to be done, including the specification of APIs for portable serializers, deserializers, and stubs. This will further enable vendor-independence of J2EE applications.

  • Chapter 17, References.
    This extensive list of references, mostly for Java-based XML technologies, is worth perusing.

  • Appendix 18, XML Schema Support
    Extensive tables list most XML Schema types and whether support is optional or required by JAX-RPC. If support is optional, consult the WebSphere documentation for whether that Schema type is supported, and if so, how.

  • Appendix 19, Serialization Framework
    This is an implementation case study of interest to JAX-RPC implementers only.

  • Appendix 20, Mapping of XML names
    This appendix specifies how Java identifiers are mapped to XML names and vice-versa. This identifies the rationale for a particular transformation.

Now that we've reviewed what the J2EE web services standards contain, let's look at the development steps identified by JSR-109 to create a Web service from a J2EE component.

JSR-109 Enablement Process

JSR-109 describes the required steps to make either a stateless session EJB or a JavaBean available as a Web service. These steps can be summarized as follows. Each of these steps is described in more detail in the following sections.

  1. Select an existing JavaBean or stateless session EJB you wish to enable.

  2. Create a Service Endpoint Interface exposing the desired methods of the bean. The Service Endpoint Interface is required by JAX-RPC and is very similar to an EJB remote interface. The Service Endpoint Interface defines the methods that can be invoked on the service. Each method must throw a java.rmi.RemoteException, so that a client using the Service Endpoint Interface to invoke an operation on a service can be notified of any communications faults. Also, all parameters on the interface methods must map to XML types as defined by JAX-RPC. These considerations are discussed in detail in the section Create the Service Endpoint Interface below.

  3. Using tools, generate a WSDL document from the Service Endpoint Interface.

  4. Using tools, generate templates for the developer-supplied deployment descriptors required by JSR-109 – the webservices.xml file and a mapping file.

  5. Complete the deployment descriptors by providing a link to the EJB or JavaBean being enabled.

  6. Add the Service Endpoint Interface class, WSDL file, and deployment descriptors to the assembled module (JAR or WAR).

  7. Repackage the EAR containing the module.

  8. If you are using the initial release of WAS version 5.0 with the Web services Technology Preview (see below), a separate tool called the endptEnabler is used to configure the endpoint listener (servlet) for the application. This step is only required for EJBs and will be done automatically during deployment in subsequent updates.

  9. Deploy the application. During deployment, the SOAP address in the WSDL file will be updated with the location the service is deployed to.

  10. Provide the updated WSDL file to your customers, or publish it to a service registry.

Due to the rapid changes in web services specification and technologies, as well as legal requirements, there are some limitations in the JSR-109 support in the initial release of WAS version 5.0:

  • JSR-109 web services support for WAS version 5.0 is a separately installable Web Services Technology Preview that can be downloaded from the WebSphere Developer Domain (http://www7b.software.ibm.com/wsdd/downloads/techpreviews.html).

  • The initial release of WebSphere Studio version 5.0 does not include support for JAX-RPC or JSR-109 based development.

  • Some assembly and deployment tasks are performed manually.

Due to these limitations, the development and assembly tasks in this chapter are performed from the command line. The arguments used with these tools will be changing as the Technology Preview is being productized, so consult your WebSphere documentation if you encounter differences from this chapter. A future update to WAS version 5.0 and WSAD version 5.0 will provide full support for JSR-109.




Professional IBM WebSphere 5. 0 Applicationa Server
Professional IBM WebSphere 5. 0 Applicationa Server
ISBN: N/A
EAN: N/A
Year: 2001
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net