Comments
Patrick Collands wrote: collands (AT) gmail com I'd be very grateful for an invitation. Thank you.
Cloud Expo on Google News

SYS-CON.TV

2009 East
PLATINUM SPONSORS:
IBM
Smarter Business Solutions Through Dynamic Infrastructure
IBM
Smarter Insights: How the CIO Becomes a Hero Again
Microsoft
Windows Azure
GOLD SPONSORS:
Appsense
Why VDI?
CA
Maximizing the Business Value of Virtualization in Enterprise and Cloud Computing Environments
ExactTarget
Messaging in the Cloud - Email, SMS and Voice
Freedom OSS
Stairway to the Cloud
Sun
Sun's Incubation Platform: Helping Startups Serve the Enterprise
POWER PANELS:
Click For 2008 West
Event Webcasts
Web Services Standards
Web Services Standards

If you follow the latest trends in the software industry, you will have noticed that Web services technology is getting a lot of attention. While it is not a completely new thing anymore, more companies are getting serious about Web services today and putting solutions into production that provide and/or consume Web services interfaces. One crucial aspect of this is standardization. The promise of Web services technology is to allow you to connect applications that were developed on different platforms and in different programming languages. This can only work if vendors can agree on common standards. And a lot of standardization has taken place in the XML space with the creation of specifications such as SOAP, WSDL, and UDDI.

However, until recently there was no common approach to implementing Web services technology in Java. This has changed with the advent of two new standard API definitions that will go into the next J2EE specification. Both were handled in the Java Community Process as JSRs (Java Specification Requests), namely JSR-101 (JAX-RPC) and JSR-109 (Enterprise Web Services). In short, JSR-101 defines the mapping of WSDL to Java and vice versa. It also defines a client API to invoke a remote Web service and a runtime environment on the server to host a Web service. JSR-109 conceptually enhances JSR-101 by defining the packaging of Web services into standard J2EE modules, including a new deployment descriptor. It also defines Web services that are implemented as Enterprise JavaBeans.

IBM provides an early implementation for both JSR-101 and JSR-109 in the Web Services Technology Preview for WebSphere Application Server 5, giving you a head start on using the new APIs. We will cover this technology preview in detail in a later article.

In this article, we will describe the key concepts of the new standards. This will help you understand how you can integrate Web services technology into your J2EE-based application development efforts, and which new APIs and deployment descriptor formats are defined.

We will assume that you are familiar with the basic Web services technologies such as SOAP and WSDL. (See the Resources section at the end for pointers to more material on those topics.)

JAX-RPC (JSR-101)
JAX-RPC stands for Java API for XML-based RPC. As we mentioned earlier, it defines how Java classes can be described in a WSDL document and how an existing WSDL document can be implemented in Java. Which way you go depends on your development approach. In the "top-down" approach, you start with an existing interface definition that is described in WSDL and derive Java classes from that. In the "bottom-up" approach, you start developing your Java implementation and then generate a WSDL description from that.

WSDL/Java Mapping
We cannot cover all of the rules that apply for the mapping between WSDL and Java, but here are some of the core ones:

  • Each WSDL <portType> element is mapped to a Java interface. This interface must extend java.rmi.Remote and is called the service endpoint interface. Its package name can be derived from the namespace of the <portType> element and vice versa.
  • Each <operation> within the <portType> is mapped to a Java method in the service endpoint interface. Every method must throw a java.rmi.RemoteException.
  • The <message> elements of the <operation> are mapped to parameters and return types of the methods of the service endpoint interface. The mapping works like this (note that in actual usage this mapping can be quite complex, and we only list the basic concepts here):
    -Basic Java types are mapped to basic XML Schema types. For example, a java.lang. String is mapped to an xsd:string type.
    -Nonbasic Java types (i.e., regular Java classes) must implement java.io.Serializable. They are mapped to XML structures described in the form of XML Schema complex types. The process of turning a Java object into an XML document, and vice versa, is handled by serializers and deserializers.
    -Support for XML attributes is optional; enumerations are mapped to a new Java class in a particular way; and arrays are handled as described in the SOAP 1.1 specification. It is beyond the scope of this article to describe all of this in detail.

    The second article in this series will describe tools offered by the WAS 5 Web Services Technology Preview that can generate the Java interface from an existing WSDL file, and generate WSDL from an existing Java interface - so you don't need to be an expert on all of these rules.

    Client-Side Service Invocation
    On top of the Java-WSDL mapping, the JAX-RPC specification defines a client interface for the invocation of a Web service. The most important interface here is the javax.xml.rpc. Service interface. It defines methods to retrieve a local stub to a Web service, which then forwards each request to the actual service implementation. These stub classes are also generated by tools, so you don't have to worry too much about their internals. There is also a way to invoke a service completely dynamically, without a generated stub.

    Server-Side Runtime Model
    On the server side, it is assumed that the service implementation class exists in a servlet container. But the service implementation class is not the servlet that handles the SOAP request; that servlet is provided by the JAX-RPC implementation. The service implementation class will be a JavaBean that implements the service endpoint interface we mentioned earlier.

    The model for EJBs is defined in JSR-109, which we will explain a little further on.

    In case you are wondering now about the supported protocols for the actual communication between a service requester and a service provider, JAX-RPC is meant to be protocol-neutral but requires support for SOAP over HTTP. In other words, transport of SOAP messages over JMS is not (yet) defined.

    By the way, the JAX-RPC specification requires that an implementation support both RPC-style invocations with encoded SOAP messages, and document-style invocations with literal encoding. Other combinations are optional. The Web Services Interoperability Organization (www.WS-I.org) currently leans toward the use of literal encoding (some may describe this as no encoding at all), so you can expect literal encoding to become dominant (plus, it was recently decided that the WS-I Basic Profile will become part of the J2EE 1.4 specification).

    JSR-109 (Enterprise Web Services)
    In order to make Web services usable within a J2EE environment, the JAX-RPC specification is not enough. For example, it does not define how a Web service is packaged and deployed, or how an EJB can be exposed through a Web service interface. This is where JSR-109, describing "Enterprise Web Services," comes in. It is basically filling the gaps that the JAX-RPC specification left open for use of Web services in a J2EE application server. And again, we will just cover the main concepts here.

    Client Service Invocation
    Besides using the javax.xml.rpc. Service interface from within a standard Java application, you can also use it from within a J2EE client container. In this case, the JSR-109 specification defines how a service reference can be obtained from a JNDI naming context, similar to the way an EJB Home reference is retrieved.

    The specification also defines a client Web services deployment descriptor, Webservicesclient.xml, for this purpose. It consists mainly of a service reference that contains the name and location of the WSDL file for the invoked service, its service endpoint interface, and the name under which the service can be found in JNDI. And like many of the other artifacts that the JSR-101 and JSR-109 specifications define, it is normally generated by tools, so you don't have to deal with creating it manually.

    Server Service Deployment
    In addition to the servlet-based runtime model described in the JAX-RPC specification, JSR-109 also allows a service to be implemented by means of a stateless session EJB. By the way, this indeed means that entity EJBs or stateful session EJBs cannot be exposed as Web services. The EJB's remote interface in this case acts as the service endpoint interface. If you create a separate service endpoint interface, it must contain a subset of the methods in the remote interface.

    The application server must ensure during deployment that an incoming SOAP over HTTP request is routed to the appropriate EJB. If the service implementation is a JavaBean, it must also make sure that incoming requests are handled properly. To create the needed artifacts for this, a Web service deployment descriptor is defined that contains information about the service and how it should be deployed.

    But before we take a closer look at the deployment descriptor, let us focus for a moment on the packaging. Web services are packaged in their respective J2EE modules, i.e., an EJB goes into an EJB module, and a JavaBean goes into a Web module (or a dependent Java JAR file). Both are packaged into an enterprise archive (EAR) file for deployment into the application server.

    The Web services deployment descriptor, webservices.xml, goes into either the META-INF directory of the EJB module, or the WEB-INF directory of the Web module. This deployment descriptor contains a description of each service that is to be deployed. It contains a pointer to the WSDL document for the service, as well as a pointer to a particular <port> within this document. Finally, it defines the service endpoint interface and has a link to the element (EJB or JavaBean) that implements the actual service. This is done via a link to either the web.xml deployment descriptor (in case the service is implemented as a bean) or the ejb-jar.xml deployment descriptor (in case it is a stateless session EJB).

    When the application that includes the service is installed on the application server, the server generates all of the items necessary to make the service accessible for clients. One important aspect is that it updates the address of the service in the WSDL file (contained in the <port> element) to the actual endpoint where the service resides. The resulting updated WSDL document can then be published to a file location or even to a UDDI registry.

    Outlook
    At this point you may have noticed that one important aspect of Web services technology is missing: asynchronous, message-based communication as a means to implement and access a Web service. Speaking in J2EE terms, it has not yet been defined how JMS can be leveraged as a transport protocol API in Web services scenarios. Some support for this exists today in various application servers, but nothing has been standardized yet. Thus, it is probably fair to assume that the next set of Web services-related J2EE specifications will address that. Moreover, we can expect that the WS-Security standard will be mapped into the J2EE security model.

    Summary
    With the advent of standard APIs for Web services, this technology finally becomes a core part of the J2EE specification. This will help developers create portable and interoperable Web service providers and consumers across a variety of application servers. JAX-RPC defines the basic mapping of Java to and from WSDL, including some basic APIs for consuming Web services, while JSR-109 contains the definition for packaging Web services and making them a standard component of every J2EE-compliant application server.

    Resources

  • The JAX-RPC home page: http://java.sun.com/xml/jaxrpc
  • The JSR-109 page: http://jcp.org/en/jsr/detail?id=109
  • The WAS 5 Web Services Technology Preview: www7b.boulder.ibm.com/wsdd/downloads/web_services.html
  • "WebSphere Version 5 Web Services Handbook," a recently published draft redbook, discusses all aspects of Web services in WebSphere 5: http://publib-b.boulder.ibm.com/Redbooks.nsf/ RedpieceAbstracts/sg246891.html?Open
  • High, R., et al. (2003). Professional IBM WebSphere 5.0 Application Server. Wrox: www.wrox.com/books/1861005814.htm
  • The IBM developerWorks Web services zone: www.ibm.com/developerworks/webservices
    About Andre Tost
    André Tost is a Senior Technical Staff Member in the WebSphere Business Development group where he helps IBM?s Strategic Alliance partners integrate their applications with WebSphere. His special focus is on Web services technology throughout the WebSphere product family. Before his current assignment, he spent ten years in various development and architecture roles in IBM software development, most recently for the WebSphere Business Components product. Originally from Germany, he now lives and works in Rochester, Minnesota.

    About Denise Gabardo


  • In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1

    Latest Cloud Developer Stories
    CloudBench Applications, Inc. announced its financial results for the three months and nine months ending September 30, 2009. All amounts are stated in Canadian dollars unless otherwise noted. Revenues from BasicGov, the Company's cloud computing solution for local government, gr...
    The new contract is an industry first, with CSC being the first Microsoft partner to lead and win a cloud computing services agreement of this scale. Under terms of the contract, CSC will provide Royal Mail Group's 30,000 employees with access to new IT services using Microsoft's...
    Operates in over 170 countries and is one of the world’s leading providers of communications solutions and services. Richard Tarboton talks for MeettheBoss.TV on his role as Head of Energy & Carbon for BT and what they are doing towards reducing carbon emissions.
    CA is going to put its Agile Planner software on salesforce.com’s Force.com platform in the first half to accelerate development time and give users visibility over their development initiatives to reduce time-to-market. Customers are supposed to be able to accelerate the deploym...
    Despite its uncertain fate Sun soldiers on. Monday it trotted out a cloud-based multiplatform desktop as a service for K-12 and community colleges that can run Windows, the Mac OS, Linux and Solaris applications to nearly any client device, including its own Sun Ray thin clients....
    Subscribe to the World's Most Powerful Newsletters
    Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

    SYS-CON Featured Whitepapers
    ADS BY GOOGLE

    Breaking Cloud Computing News
    CloudBench Applications, Inc. announced its financial results for the three months and nine months e...