You are on page 1of 101

Web Services

Overview

1
Sang Shin
sang.shin@sun.com
Java™ Technology Evangelist
Sun Microsystems, Inc.
www.javapassion.com/webservices
2
Disclaimer
● Even though Sang Shin is a full-time employee of Sun
Microsystems, the contents here are created as his
own personal endeavor and thus does not reflect any
official stance of Sun Microsystems.
● Sun Microsystems is not responsible for any
inaccuracies in the contents.

3
Agenda
● Evolution of network computing
● What is Web Services?
● Why Web Services?
● Where is Web Services?
● Web Services Architecture
● Web Services Standards
● Java™ APIs for Web Services
● J2EE as platform of choice for Web Services
● Web Services Tools
● Roadmap and Summary
4
Evolution of
Network Computing

5
Things - 1014
Waves of Embedded Computers
1011
Network Computing Thermostats
Cars
Switches
Computers TVs
Packages
108 Phones
Games Clothes
Desktops
Clients
Functions Transfers Transactions Content Telemetry Control
IP v4 IP Layer IP v6
Protocols

Organization
Waves of Embedded Computers
Things - 1014
1011
Network Computing Thermostats
Cars
Switches
Computers TVs
Packages
108 Phones
Games Clothes
Desktops
Clients
Functions Transfers Transactions Content Telemetry Control
IP v4 IP Layer IP v6
Protocols FTP SMTP
Telnet RPC/XDR
X RMI/IIOP
LDAP SOAP Identity
Organization HTTP
Client/Server Jini
UDDI JXTA
N-tier Web Applications

Web Polyarchical
Services
Fractal
The New Software
Payment
Developer X1
Locater X106

6
New User’s
X10 Service Device

Calendar
Authentication

Shrink Wrap Software-as-a-Service


History of
Distributed Computing

9
Platform Evolution
The Network The Computer Network of
Catch Is the Legacy to Is the Embedded Network
Phrase Computer Objects the Web Network Things of Things

Scale 100s 1,000s 1,000,000s 10,000,000s 100,000,000s 100,000,000s

When/Peak 1984/1987 1990/1993 1996/1999 2001/2003 1998/2004 2004/2007

Leaf X X +HTTP +XML +RM Unknown


Protocol(s) (+JVM) Portal

Directory(s) NS, NS+ +CDS +LDAP(*) +UDDI +Jini +?

Session RPC, XDR +CORBA +CORBA, +SOAP, +RM/Jini +?


RM XML

Schematic
Communication Patterns

Client- Web Web Hybrid


Server 3-Tier Application Services P2P Fractal
Communication Patterns:
TM
Java 2

Business Systems

DB Server
App Server J2EE
Web Server
Browser J2SE/
Client J2ME
Web
Application
Communication Patterns: Sun
ONE

Bus.
Sys. XML
DB (UDDI,
SOAP)
App J2EE
Web
J2SE/
Browser J2ME

Context and Identity


(LDAP, Policy, Liberty)
Web
Service
What is
Web Services?

14
Web Services Definition by W3C
● A Web service is a software application
● identified by a URI,
● whose interfaces and binding are capable of
being defined, described and discovered by
XML artifacts and
● supports direct interactions with other
software applications
● using XML based messages
● via internet-based protocols
15
Distributed Computing
Evolution

Servers Servers

Clients PDA Cell


Internet Phone

Client-Server(C/S)
silos
Clients Workstation Server
Web-based computing
Kiosk Laptop

Web Services/Peer-to-Peer
16
Traditional C/S vs. Web Services

Traditional C/S Web Service


● Within enterprise ● Between enterprises
● Tied to a set of ● Program language
programming languages independent
● Procedural ● Message-driven
● Usually bound to a ● Easily bound to different
particular transport transports
● Tightly-coupled ● Loosely-coupled
● Efficient processing ● Relatively not efficient
(space/time) processing

17
Web Application vs. Web Services

Web Application Web Service


● User-to-program ● Program-to-program
interaction interaction
● Static integration of ● Possibility of dynamic
components integration of
● Monolithic service components (in the
future)
● Possibility of service
aggregation (in the
future)

18
Characteristics of Web
Services
● XML based everywhere
● Message-based
● Programming language independent
● Could be dynamically located
● Could be dynamically assembled or
aggregated
● Accessed over the internet
● Loosely coupled
● Based on industry standards
19
Web Services
The Service Grid
Service Service registration
Registry

Service
Service invocation Service
discovery delivery

20
Service Assembly

Macro
Service Micro
Service
Business
Process
Management

Micro
Service
Micro
Service

21
Service
Nasdaq
Aggregation Input: Symbol
Output: Price

News feed 1
Stock Service Input: Symbol
Output: News links
Portal
User Input: Symbol
Output: Price, News,
Trade

News feed n
Input: Symbol
Output: News links

Brokerage 1 Brokerage n
Input: Symbol, Price, Input: Symbol, Price,
Qty Qty

22
Why Web Services?

23
Why Web Services?
Web Services:
● Are platform neutral
● Are accessible in a
standard way
● Are accessible in an
interoperable way
● Use simple and
ubiquitous plumbing
● Are relatively cheap
● Simplify enterprise
integration

24
Why Web Services?
● Interoperable – Connect across heterogeneous
networks using ubiquitous web-based standards
● Economical – Recycle components, no installation and
tight integration of software
● Automatic – No human intervention required even for
highly complex transactions
● Accessible – Legacy assets & internal apps are exposed
and accessible on the web
● Available – Services on any device, anywhere, anytime
● Scalable – No limits on scope of applications and
amount of heterogeneous applications
25
Web Services Usage Example
Distributor

XML

XML
Manufacturing
Supplier Internet Facility
XML

XML

Logistics

“Growing need for a standard lightweight infrastructure


for data exchange in e-business applications.”
26
Impact of Web Services on Software:
“Application Dis-Integration”
Web Services

Monolithic App App App


Software Service Service Service

Application

System Software System System System


Service Service Service

A Computer

The Network

27
Macro web services – Virtual
Systems
Web Services
A web service is accessed
programmatically by Bank Balance
applications or other
web services
Net worth Stock Position

Insurance
Portfolio Cash Value

Stock ticker
Biz News
“Portfolio” can be an News
application, a portal
channel, or a web World News
service itself 28
Micro web services – Virtual Apps
A web service is accessed Web Services
programmatically by
applications or other Bank balance
Spell Check
web services
Grammar Dictionary

Thesaurus
Word Processing

Media
“Word processing” c:\...
can be an Publishing
application, a
capability, or a web http://...
service itself 29
Three Laws of Computing
● Moore's Law
– Computing power doubles every 18 months
● Gilder's Law
– Network bandwidth capacity doubles every 12
months
● Metcalfe's Law (Net Effect)
– Value of network increases exponentially as
number of participants increases

30
Impact on Integration:
Trigger the Network Effect

Custom
Integration Web Services

Metcalfe’s Law: The value of the network is proportional


to the square of the number of participants
31
Myth: Web Services is a New
Concept
● Web services is distributed computing all over
again – only now it is based on the web

Distributed Computing ala CORBA /


Concept Java Basic Web Services
Interface Description CORBA IDL, Java interface WSDL
RPC support ORBs, Idl2java compilers, rmic SOAP, compilers for WSDL
Service Registry CORBA naming service, JNDI UDDI
Messaging support CORBA Event/Notification service, JMS ?
Transaction support CORBA Transaction service, JTS ?
Secuity support CORBA Security service, Java security ?

32
Other Popular Myths
Surrounding Web Services
● Web services require only SOAP, WSDL, UDDI:
We need more high-level semantics
● Web services are based on the RPC paradigm:
Document-driven model would be more
popular communication model
● Web services must be based on HTTP: Other
transports such as SMTP can be also used

33
Where is &
Where is Web Services
going?

34
Myths about Web Services
● Web Services cure cancer: Not for a
very very long time!
● Web Services are something
completely new: Not True!
● You have to write Web Services from
scratch: Not True!
● J2EE Platform does not support web
services: Not True!
35
State of Web Services
● Technology/Standards are still evolving
– SOAP, WSDL, UDDI are not enough
● Business web services is the next big thing,
but more works are needed in
– Quality of Service, management
– Security, transaction, state and user context
– Work flow, Identity management,
– Provisioning, Accounting
● Will be adopted in phases
36
Web Services Adoption Phases
● 1st phase (current state)
– Concerted deployment internally within an organization
mainly for interoperability
– SOAP over HTTP/S
nd
● 2 phase (1 to 2 years)
– Selective and non-aggregate deployment with trusted
outside business partners
– Private registry deployment
● 3rd phase (at least 3 to 4 years away)
– Wider, more dynamic and aggregate deployment with
outside business partners
– Public registry deployment
37
Web Services Adoption Phases
st
● 1 Phase – Simple Web Services (Now)
● Consumer-focused, stateless, SOAP over HTTP/S
● 2nd Phase – EAI Web Services (Begun)
● Deployed within organization boundaries to
enable internal integration
● 3rd Phase – Business Web Services (2004?)
● Deployed on extranets to enable business
transactions with trading partners, suppliers, and
customers, ebXML & UBL
38
Business Web Services
● J2EETM
● Service implementation platform standard
● ebXML and UBL
● Business web services standards
● More than 16 vendors and several open source
projects support ebXML
● ex) Australian gas industry uses ebXML NOW!
● Liberty Project

Identity system standard
39
Business Web Services (B2B)
Architectural Components (ebXML)

● B2B collaboration
● Secure and reliable message delivery
● Non-repudiation
● Partner profile
● Repository for business data objects

40
Simple Web Services (WUS) vs.
B2B Collaboration (ebXML)
Simple Web Services B2B Collaboration
 Simple interaction  Complex interaction
 Consumer oriented  Business oriented
 Short-living process  Long-running process
 No business  Supports business
collaboration collaboration
 No partner profile  Supports partner profile
 Not secure, not  Secure and reliable and
reliable non-repudiation
 Does not support  Supports non-
non-repudiation repudiation
 No repository support  Registry and repository
 No legal binding  Supports legal binding
41
EAI vs. B2B Collaboration (ebXML)

EAI B2B Collaboration

 Within a business  Between business


organization organizations
 Centralized  Distributed
control control
 Implicit contract  Explicit contract
 Small number of  Potentially large
business number of
processes and business
participants processes and
participants
42
Trends Towards Service Orientation
● Evolution of EAI to web service standards
● XML RPC => Asynchronous XML Messaging
● Towards de-centralization
● Componentized services
– Composable and composite services
– Data encapsulated within component
– Data ownership follows component ownership
● Brokered web services
● Flexible relationships => Adaptive businesses
43
Simple Web Services Architectural
Components (WUS)

● Service Description
● Service Registration (Publication) and
Discovery
● Service Invocation

44
Core Web Services
Standards

45
(Simplified) Web Service
Architecture

Registry

2. Client Request
1. Service Registers
Service Location
PUBLISH
FIND
3. Client calls
Service
Web BIND
Service
Service Client
46
SOAP
(Simple Object
Access Protocol)

47
SOAP
● Simple Object Access Protocol
● Wire protocol similar to
– IIOP for CORBA
– JRMP for RMI
● XML is used for data encoding
– “text” based protocol vs. “binary” protocol
● Supports XML-based RPC

48
What SOAP is Not
● Not a component model
– So it will not replace objects and components,
i.e. EJB, JavaBeans
● Not a programming language
– So it will not replace Java
● Not a solution for all
– So it will not replace other distributed
computing technologies such as RMI

49
What does SOAP Define?
● Message Envelope
● Encoding Rules
● RPC Convention
● Binding with underlying protocols

50
SOAP Message Format
SOAP Message SOAP Envelope

SOAP Header
Primary MIME part Header Entry
(text/xml)

Header Entry
Attachment
SOAP Body
Attachment
Body Entry

Body Entry
Attachment

51
SOAP Message Envelope
● Encoding information
● Header
– Optional
– Could contain context knowledge
● Security
● Transaction
● Body
– RPC methods and parameters
– Contains application data
52
SOAP Encoding
• Rules of expressing application-defined
data types in XML
• Based on W3C XML Schema
• Simple values
– Built-in types from XML Schema, Part 2 (simple
types, enumerations, arrays of bytes)
• Compound values
– Structs, arrays, complex types

53
SOAP RPC Request Example
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="… "
SOAP-ENV:encodingStyle="…">
<SOAP-ENV:Header>
<!-- Optional context information -->
</SOAP-ENV:Header>
<SOAP-ENV:Body>
   <m:GetLastTradePrice xmlns:m=“some_URI ">
     < tickerSymbol> SUNW</tickerSymbol >
   </m:GetLa stTradePric e>
</SOA P-ENV:Body>
</SOAP-ENV:Envelope>
54
SOAP RPC Response Example
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="…"
SOAP-ENV:encodingStyle= "…">
<SOAP-ENV:Header>
<!-- Optional context information -->
</SOAP-ENV:Header>
<SOAP-ENV:Body>
  <m:GetLastTradePriceResponse xmlns:m=“some_URI">
     <price>30 .5</price>
  </m:GetLa stTradePric eResponse>
</SOA P-ENV:Body>
</SOAP-ENV:Envelope>
55
SOAP RPC
● Information needed for a method call:
– The URI of the target object

<SOAP-ENV:Body>
<m:GetLastTradePrice
xmlns:m=“http://stocks.com/StockQuotes">
<tickerSymbol>SUNW</tickerSymbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>

56
SOAP RPC
● Information needed for a method call:
– The URI of the target object
– Method name

<SOAP-ENV:Body>
<m:GetLastTradePrice
xmlns:m=“http://stocks.com/StockQuotes">
<tickerSymbol>SUNW</tickerSymbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>

57
SOAP RPC
● Information needed for a method call:
– The URI of the target object
– Method name
– Parameters

<SOAP-ENV:Body>
<m:GetLastTradePrice
xmlns:m=“http://stocks.com/StockQuotes">
<tickerSymbol>SUNW</tickerSymbol>
</m:GetLastTradePrice>
</SOAP-ENV:Body>

58
Quick WSDL Tutorial

59
What is WSDL?
• XML language for describing web services
• Web service is described as
– A set of communication endpoints (ports)
• Endpoint is made of two parts
– Abstract definitions of operations and messages
– Concrete binding to networking protocol (and
corresponding endpoint address) and message format
• Why this separation?
– Enhance reusability (as we will see in UDDI reference
to WSDL document)
60
Why WSDL?
• Enables automation of communication details
between communicating partners
– Machines can read WSDL
– Machines can invoke a service defined in WSDL
• Discoverable through registry
• Arbitration
– 3rd party can verify if communication conforms to
WSDL

61
WSDL Document Example
● Simple service providing stock quotes
● A single operation called GetLastTradePrice
● Deployed using SOAP 1.1 over HTTP
● Request takes a ticker symbol of type string
● Response returns price as a float

62
WSDL Elements
● Types
● Message
● Operation
● Port Type
● Binding
● Port
● Service
63
WSDL Elements
● Types
– Data type definitions
– Used to describe exchanged messages
– Uses W3C XML Schema as canonical type
system

64
WSDL Example: Types
<definitions name="StockQuote"
targetNamespace="http://example.com/stockquote.wsdl"
xmlns:tns="http://example.com/stockquote.wsdl"
xmlns:xsd1="http://example.com/stockquote.xsd"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/”>
<types>
<schema targetNamespace="http://example.com/stockquote.xsd"
xmlns="http://www.w3.org/2000/10/XMLSchema">
<element name="TradePriceRequest">
<complexType>
<all>
<element name=”tickerSymbol" type="string"/>
</all>
</complexType>
</element>
<element name="TradePrice">
<complexType>
<all>
<element name="price" type="float"/>
</all>
</complexType>
</element>
</schema>
</types> 65
WSDL Elements
● Messages
– Abstract, typed definitions of data being
exchanged
● Operations
– Abstract description of an action
– Refers to an input and/or output messages
● Port type
– Collection of operations
– Abstract definition of a service

66
Example:
Messages, Operation, Port type
<message name="GetLastTradePriceInput">
<part name="body" element="xsd1:TradePriceRequest"/>
</message>

<message name="GetLastTradePriceOutput">
<part name="body" element="xsd1:TradePrice"/>
</message>

<portType name="StockQuotePortType">
<operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput"/>
<output message="tns:GetLastTradePriceOutput"/>
</operation>
<!-- More operations -->
</portType>
67
WSDL Elements
● Binding
– Concrete protocol and data format for a particular
Port type
– Protocol example: SOAP 1.1 over HTTP or SOAP 1.1
over SMTP
● Port
– Defines a single communication endpoint
– Endpoint address for binding
– URL for HTTP, email address for SMTP
● Service
– Aggregate set of related ports 68
Example: Binding, Port, Service
<binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetLastTradePrice">
<soap:operation
soapAction="http://example.com/GetLastTradePrice"/>
<input> <soap:body use="literal" />
</input>
<output> <soap:body use="literal" />
</output>
</operation>
</binding>

<service name="StockQuoteService">
<documentation>My first service</documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://example.com/stockquote"/>
</port>
</service>
69
UDDI

70
Service Architecture

UDDI
Registry
2. Client Request
1. Service Registers Service Location
PUBLISH FIND

Web Service
3. Client calls Client
Service Service
BIND

UDDI defines a way to publish and find


information about Web services.
71
UDDI (Universal Description,
Discovery and Integration)
● “White pages”
– address, contact, and known identifiers
● “Yellow pages”
– industrial categorizations
● Industry: NAICS (Industry codes - US Govt.)
● Product/Services: UN/SPSC (ECMA)
● Location: Geographical taxonomy
● “Green pages”
– technical information about services
72
Other
Web Services
Standards

73
ebXML

A global electronic market place where


enterprises of any size, anywhere can:
– Find each other electronically
– Conduct business through exchange of XML
based business messages
74
More Web Services Standards
● Security
– XML Signature, XML Encryption, XKMS, XACML, SAML,
Liberty, WS-Security
● Transaction
– BTP, WS-Transaction
● Business collaboration and choreography
– ebXML BPSS, ebXML CPP/CPA, BPML, WSFL, XLANG,
WSCI, BPEL4WS

75
More Web Services Standards
● Business Language
– UBL (Universal Business Language)
● Component model
– WSIA (Web Services for Interactive Application)
● Portal
– WSRP (Web Services for Remote Portals)

76
Java APIs
for Web Services
77
Java APIs for SOAP, WSDL,
UDDI
● SOAP Messaging
– JAXM (JSR 67), SAAJ, JAX-RPC (JSR 101), JMS
● WSDL
– Java API for WSDL (JSR 110)
– JAX-RPC (JSR 101)
● UDDI
– JAXR (JSR 67)

78
Java APIs for ebXML
● ebXML Message Service (TR&P)
– JAXM (JSR 67) with ebXML Message Service profile
● ebXML Registry/Repository
– JAXR (JSR 93)
● CPP/CPA
– Java API for ebXML CPP/CPA (JSR 157)

79
J2EE Web Services Framework
● J2EE 1.4 (JSR 151)
● Web services for J2EE (JSR 109)
● JAX-RPC (JSR 101)
● JAXR
● SAAJ
● EJB 2.1

80
Java APIs for XML
Document Management
● JAXP (Java API for XML processing, JSR 05)
– Assembly language for XML document processing
● JAXB (Java API for XML data-binding, JSR 31)
– Higher level language for XML document processing
● Streaming API for XML (JSR 173)
– Pull-parsing API based on Iterator
– Gives parsing control to programmers
81
Java APIs for XML Security
● XML Digital Signature (JSR 105)
● XML Encryption (JSR 106)
● XML Trust Service (JSR 104)
● Secure Assertion Markup Language
(SAML, JSR 155)
● WS-Security (JSR 183)

82
More Java APIs for Web
Services
● XML Transactioning API for Java (JSR 156)
– Java API for OASIS BTP
● Web Services for J2ME (JSR 172)
– SOAP messaging for J2ME devices
● Web Services Metadata for J2EE (JSR 181)
– Metadata based Web services

83
Web Services Framework
for J2EE

84
J2EE Platform& Web Services
B2B
Applications

Existing
Applications
B2C
Applications

Web
Services
Application Server
Wireless Enterprise
Applications Information
Systems

85
Why J2EE for Web Services?
● Web services is just one of many
service delivery channels of J2EE
– No architectural change is needed
– Existing J2EE components can be easily
exposed as Web services
● Many benefits of J2EE are preserved
for Web services
– Portability, Scalability, Reliability
– No single-vendor lock-in
86
Where Are We Now?
● Java APIs for Web Services are being
developed very rapidly
● Tools are available now for exposing
existing J2EE components as Web
services
● J2EE community has defined overall
framework for Web Services (J2EE 1.4,
JSR 109)
87
Design Goals J2EE Web Services
Framework
● Portability of Web services component
– Over different vendor platform
– Over different operational environment
● Leveraging existing J2EE programming
models for service implementation
● Easy to program and deploy
– High-level Java APIs
– Use existing deployment model
88
J2EE Web Services Framework
● J2EE 1.4
– Umbrella framework for Web services
– JSR 109, JAX-RPC, JAXR, EJB 2.1, Servlet 2.4,
● JAX-RPC
– Defines client programming model
– Defines Servlet-based Web services endpoint
model

89
J2EE Web Services Framework

● EJB 2.1
– Defines Stateless Session Bean-based Web services
endpoint model
● Servlet 2.4
– Will be aligned with JAX-RPC
● JSR 109
– Defines standard Web services packaging and
deployment model

90
Web Services Architecture
over J2EE

91
What Is a Web Service?
● A set of endpoints (ports) operating on
messages
● Ports are operating within a container
– Container provides runtime environment
– Contract for runtime environment are specified in JAX-
RPC, EJB 2.1, JSR 109
● Service is described in WSDL document and
published to a registry
– WSDL specifies a contract between service provider
and client
92
Web Service Component
and Container
● Container vs. Component model
– Web services components get executed within a
container
– Components are portable (under J2EE 1.4)
● Web service components
– Web-tier (Servlet-based endpoint)
– EJB-tier (Stateless session bean-based endpoint)

93
Web Service Components
Web services
components

Source: Web Services for J2EE (JSR 109), V1.0 94


Java Technology-based
Web Services Tools

95
Web Services Tools for Java
Platform
● Web Services Tools (Available Now!)
– Tools that come with reference implementations of Java
APIs for Web services (JAX-RPC RI)
– Systinet (Idoox), Iopsys, Cape Clear, Apach SOAP
● IDE's (Now!)
– Sun Java Enterprise Studio 7
– JBuilder™ from Borland
– JDeveloper™ from Oracle
– WebGain™ from WebGain
96
J2EE 1.4
● Focus is Web services
– Umbrella JSR for all Java APIs for Web services
● JSR 109, JAX-RPC, JAXR, EJB 2.1
– Web services framework for J2EE
– J2EE component model, deployment,
packaging, and container requirements
● Released in Nov. 2003
– http://java.sun.com/j2ee/1.4/download-
dr.html

97
J2EE 1.4 SDK
● Web services APIs are well integrated
● Contains
– JAXP, SAAJ, JAX-RPC, JAXR
– Sun Java App Server PE 8
– Extensive tutorial

98
Summary

99
Summary
● Web services provides a new paradigm for
program to program communication
● Comprehensive set of Java APIs for Web
Services are now available!
● J2EE is the platform of choice for Web services

100
Passion!

101