Web Services Development In a Java Environment SWE 642, Spring 2008 Nick Duan April 16, 2008 1 Overview Services Process Architecture XML-based info processing model Extending the Java EE Platform Interface-driven development (vs. Model-driven) Web Services Development using Apache Axis2 Axis2 features and tools Development steps: from WSDL to application Axis WS examples Universal Discovery, Description and Integration UDDI concepts and Protocols juddi Summary April 16, 2008 Nick Duan 2 1
Services Process Architecture The implementation of WS today is not much different from the traditional distributed computing architecture (e.g. RMI, CORBA) Client Implementation Client Stub XML Data Binding Parsing or XML Generation (Marshalling or Un-marshalling SOAP Transport Service Implementation Service Skeleton XML Data Binding Parsing or XML Generation (Marshalling or Un-marshalling SOAP Transport 4/16/2008 Nick Duan 3 Information Processing Model Applies to both client and server side Input SOAP Doc <?XML Version= 1.0?>. Stream Parser SAX or StAX Tokens Tokens Tokens Tokens Tokens Data binding XML data binding Applicationspecific Object Structure PaymentOrder Amount Sender DueDate <?XML Version= 1.0?>. Message Generator XML data binding Name Addr Output April 16, 2008 Nick Duan 4 2
Interface-Driven Development Model-drive development Start from defining object models of the application servers Develop the client/server interfaces based on server application model Works in a small environment with limited number of clients/consumers Interface-driven development Define the interfaces (in WSDL format) first without referring to a specific object model (only a conceptual, logical model) Standardize the interfaces Should not change it often (why) Change should be made through an configuration change process Use tools (such as WSDL2Java) to generate the initial development template for both client and server Register the service (once developed) with standard service registry (e.g. UDDI registry) 4/16/2008 Nick Duan 5 Web Services Environment with Infrastructure Services Web Services discovery via UDDI Web Services invocation via SOAP calls UDDI Service Registry Discover Service Publish Service Service Consumer Invoke Service Service Provider 4/16/2008 Nick Duan 6 3
Apache Axis2 The most popular open source SOAP engine available, based on standard Java EE servlet container platform Support common Web Services standards SOAP 1.1 and 1.2 WSDL 1.1 and 2.0 WS-Addressing, WS-Policy Support REST-style service invocation Support POJO-style service implementation Better performance and extensibility 4/16/2008 Nick Duan 7 Axis2 Components Axis services are bundled in.aar files and deployed within the service container Service Instance (.aar) WSDL files files Service Service implementation Service.xml Axis2 Service Container (war) Servlet Container 4/16/2008 Nick Duan 8 4
Msg Receiver Msg Sender Service Implementation Axis2 SOAP Processing Model Outbound msg handler Inbound msg handler Client Application Msg Sender Transport Sender Transport Listener SOAP SOAP Transport Listener Transport Sender Msg Receiver Inbound msg handler Outbound msg handler 4/16/2008 Nick Duan 9 Axis2 Programming Model Five ways in Axis2 to create and deploy web services applications POJO (Plain Old Java Object) AXIOM (AXIs Object Model) Axis2 Data Binding (ADB) XMLBeans (Apache Open Source project) JiBX (an API framework for XML-Java data binding, not a JCP standard) Two types programming styles From server code to WSDL From WSDL to server/client implementation April 16, 2008 Nick Duan 10 5
Two different programming styles WSDL-driven development steps (applicable to ADB, XMLBeans and JiBX based service development) Define WSDL first Generate Service Skeleton using WSDL2Java tool Define service.xml file Generate Axis archive file (.aar) and deploy the service to service container Code-driven development steps (applicable to POJO and AXIOM based service development) Create service implementation Generate WSDL using Java2WSDL tool Define service.xml file Generate Axis archive file (.aar) and deploy the service to service container Client development steps Create client stubs using WSDL2Java tool Integrate stubs to client application Make sure axis2.jar and supporting libs in the classpath 4/16/2008 Nick Duan 11 UDDI Universal Discovery, Description and Integration, an OASIS standard for registry of web services. Initially introduced by Microsoft, IBM and Ariba in 2000 (version 1.0) for B2B services. The current latest specification is UDDI v. 3 The spec defines the following entities A data model defining the registry components A set of Web Services APIs for interacting with the registry as a web service, including inquiry and publishing, replication, security, and registry content management 4/16/2008 Nick Duan 12 6
UDDI Data Model Four main data objects businessentity Info about the publisher of services businessservice Info about a family of services bindingtemplate Info about service end point and implementation details (e.g. WSDL) tmodels (technical models) Used to represent unique concepts or constructs for identifying and characterizing services (e.g. taxonomy/categories, security and operation requirements needed for accessing the services, etc.) and to enable interoperability across multiple services April 16, 2008 Nick Duan 13 Representing businessentity All data structures are represented in UDDI in XML Schema April 16, 2008 Nick Duan 14 7
Representing businessservice April 16, 2008 Nick Duan 15 UDDI Reference Implementations Commercial Products HP Systinet Registry product IBM WebSphere UDDI Registry Microsoft UDDI Registry (Bundled with Windows 2003 server) BEA WebLogic UDDI server (part of the WebLogic server) Software AG CentraSite Open Source juddi (Apache Open Source) Most vendors are integrating UDDI registry with vendor-specific repository products to provide design-time SOA governance functions 4/16/2008 Nick Duan 16 8
Online References Apache Axis2 http://ws.apache.org/axis2/ Apache AIOXM http://ws.apache.org/commons/axiom/index.html XMLBeans http://xmlbeans.apache.org UDDI standard specification http://www.oasis-open.org/specs/index.php#uddiv3.0.2 Apache juddi http://ws.apache.org/juddi April 16, 2008 Nick Duan 17 Summary Web Services development can take multiple forms based on a wide-range of tools (e.g. Axis, JAX-WS, etc.) Interface-driven approach provides better reusability and maintainability then the model/code-driven approach in large scale Web Services implementation As a core infrastructure service, a UDDI registry provides dynamic service discovery and is essential part for enabling service interactions in an enterprise The concept of UDDI is the same as a yellow page or a directory service on the internet February 6, 2008 Nick Duan 18 9
Quiz Install Apache Axis2 and run the userguide samples in the sample directory Modify the StockQuoteService WSDL by adding a new operation called getallprices which returns a list of quotes with symbols (you may design your own list structure), and implement the service April 16, 2008 Nick Duan 19 10