April 16, 2008 1
Web Services Development
In a Java Environment
SWE 642, Spring 2008
Nick Duan
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
4/16/2008 3
Services Process Architecture
Nick Duan
The implementation of WS today is not much different from the traditional distributed computing architecture (e.g. RMI, CORBA) Service Implementation Service Skeleton SOAP Transport Client Implementation Client Stub SOAP Transport
XML Data Binding XML Data Binding Parsing or XML Generation (Marshalling or Un-marshalling Parsing or XML Generation (Marshalling or Un-marshalling
Information Processing Model
April 16, 2008 Nick Duan 4
Applies to both client and server side
SAX or StAX <?XML Version=“1 .0”?>…. SOAP Doc Tokens Tokens Tokens Tokens Tokens Stream Parser XML data binding Data binding PaymentOrder Sender Name DueDate Addr Amount Application-specific Object Structure <?XML Version=“1 .0”?>…. Input Output XML data binding Message Generator
4/16/2008 Nick Duan 5
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 6
Web Services Environment with
Infrastructure Services
Web Services discovery via UDDI Web Services invocation via SOAP calls
UDDI Service Registry Service Consumer Service Provider
Discover Service Publish Service
4/16/2008 Nick Duan 7
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 8
Axis2 Components
Axis services are bundled in .aar files and
deployed within the service container
Servlet Container
Axis2 Service Container (war)
Service Instance (.aar)
Service.xml
WSDL files Service
implementation WSDL files Service
Se
rvic
e
Implem
en
tati
on
4/16/2008 Nick Duan 9Axis2 SOAP Processing Model
Transport Listener Transport Sender Transport Listener Transport Sender SOAP SOAP
Clien
t Ap
plic
ation
Inbound msg handler Outbound msg handler M sg Sen de r M sg Receiver M sg Sen de r M sg Receiver Inbound msg handler Outbound msg handlerAxis2 Programming Model
April 16, 2008 Nick Duan 10
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
4/16/2008 Nick Duan 11
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 12
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
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
Representing businessService
April 16, 2008 Nick Duan 15
4/16/2008 Nick Duan 16
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
April 16, 2008 Nick Duan 17
Online References
Apache Axis2
http://ws.apache.org/axis2/Apache AIOXM
http://ws.apache.org/commons/axiom/index.htmlXMLBeans
http://xmlbeans.apache.orgUDDI standard specification
http://www.oasis-open.org/specs/index.php#uddiv3.0.2
Apache jUDDI
http://ws.apache.org/juddi
February 6, 2008 Nick Duan 18