Introduction to Web Services Steve Graham

advertisement
1
Introduction
to
Web Services
Steve Graham
sggraham@us.ibm.com
OGSA Early Adopters Meeting
05/29/02
2
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
3
Distributed Computing
• First
– We linked all the machines together
– Internet, TCP/IP
• Second
– We linked all the documents together
– WWW, HTTP, HTML, XML
• Third
– We linked all the applications together
– Web services: SOAP, WSDL, UDDI, etc.
• Now
– We are linking everything else together
– Grid: OGSA
4
What is a Web Service for?
ƒ A Web service is about integration
ƒ Application integration
ƒ Independent of platform, programming language
etc.
ƒ Think of Web services in terms of
Service-Orientation:
ƒ A set of standards and techniques
ƒ For distributed application integration
ƒ Emphasizing the role of
service description and discovery
ƒ Using a collection of XML-based standards
5
Service Oriented Architecture
(SOA)
Service
Registry
Find
Service
Requestor
Publish
Bind
Service
Provider
6
Web Services Properties
•
•
•
•
•
Loose-coupling
Dynamic binding of collaborators
Programming-language-neutral
Platform-neutral
Built on existing technologies
– XML
– HTTP, FTP, SMTP, etc.
• Focus on the Interface
– Minimal shared understanding between service
requestor and service provider
7
A Web Service is…
• Interface that describes a collection of network accessible
operations.
•
•
•
•
•
•
•
Modular by design because inherently interface oriented
Described using a service description language
Published by making its service description available to potential
users
Found by sending queries to a registry and finding matching service
descriptions
Bound by using the information contained in the service description
to customize the connection
Invoked over a network by using the information contained in the
binding details of the service description
Composed with other services into new services
8
Making Web services
Interface
Bindings
Implementation
Execution Container
Separate interface from access and implementation
Service Provider Components
Service
Impl.
Adapter
Service
Impl.
SOAP
Dispatcher
Web
App.
Server
Service
Skeleton
SOAP
Dispatcher
SOAP
Server RT
SOAP
Dispatcher
Web
Server
Protocol
Termination
Message from
Service Requestor
Adapter
Connector
Service
Impl.
9
10
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
11
XML
• The basis of Web services
– The base type definition language
– The base messaging mechanism
– The basis of the description language
• What is it?
• How is it processed?
12
XML Document
document
prolog
<?xml version=”1.0” encoding=”UTF-8”?>
<!– Sample Comment -->
comment
<po id=”43871” submitted=”2001-10-05”>
<billTo>
<company>The Skateboard Warehouse</company>
…
</billTo>
root
attribute
…
element
</po>
subelement
end tag
13
XML Rules
• Well formed
– Follows XML rules
• Valid
– Matches a defined schema
• Schemas define:
– the elements that can be in a document
– the order and relation between elements
– the attributes of every element
– ie the structure of the document!!!
14
Simple Types
•
•
•
•
•
•
•
•
•
•
string
Base64Binary
hexBinary
integer
positiveInteger
negativeInteger
nonNegativeInteger
nonPositiveInteger
decimal
boolean
•
•
•
•
•
•
•
•
•
•
time
dateTime
duration
date
Name
QName
anyURI
ID
IDREF
and about 24 others
15
User-defined (Complex Types)
<complexType name=”addressType”>
<sequence>
<element name=”name” type=”string” minOccurs=”0”/>
<element name=”company” type=”string” minOccurs=”0”/>
<element name=”street” type=”string”
maxOccurs=”unbounded”/>
<element name=”city” type=”string”/>
<element name=”state” type=”string” minOccurs=”0”/>
<element name=”postalCode” type=”string”
minOccurs=”0”/>
<element name=”country” type=”string”
minOccurs=”0”/>
</sequence>
<attribute name=”id” type=”ID”/>
<attribute name=”href” type=”IDREF”/>
</complexType>
16
Patterns, Ranges &
Enumerations
<simpleType name=”skuType”>
<restriction base=”string”>
<pattern value=”\d{3}-[A-Z
]{2}”/>
</restriction>
</simpleType>
<simpleType name=”poIdType ”>
<restriction base=”integer”>
<minExclusive
value=”10000”/>
<maxExclusive
value=”100000”/>
</restriction>
</simpleType>
<simpleType name=”stateType”>
<restriction base=”string”>
<enumeration value=”AK”/>
<enumeration value=”AL”/>
...
<restriction>
<simpleType>
17
XML Namespaces
• Mechanism to combine/reuse XML
• Avoids element name collision
Default
Namespace
declaration
<message from=”bj@bjskates.com”
xmlns=”http://www.commmsg.com/ns/message”
xmlns:poNS=”http://www.skatestown.com/ns/po”>
<text>
Hi,here is what I need this time.Thx,BJ.
Namespace
<text>
declaration
<attachment>
<item>
<poNS:po id=”43871” submitted=”2001-10-05”>
…
Qualified
name
18
Naming
• Qualified name (a.k.a. QName)
– Namespace identifier : Local name
– poNS:po
• Uniform Resource Identifiers (URIs) (RFC 2396)
– Locators and Names
– http://www.commmsg.com/ns/message
• Uniform Resource Locators (URLs)
– www.globalgridforum.org
• Uniform Resource Names (URNs)
– URIs that are globally unique and persistent
• Universally Unique Identifiers (UUIDs)
– 128-bit identifiers that are globally unique
– urn:uuid:2FAC1234-31F8-11B4-A222-08002B34C003
Defining an XML Schema
(.xsd)
<?xml version=”1.0 ” encoding==”UTF-8 ”?>
<xsd:schema
xmlns=”http://www.skatestown.com/ns/po”
xmlns:xsd=”http://www.w3.org/2001/XMLSchema”
targetNamespace=”http://www.skatestown.com/ns/po”>
<xsd:annotation>
<xsd:documentation xml:lang=”en”>
Address type schema for SkatesTown.
</xsd:documentation>
</xsd:annotation>
<xsd:complexType name=”addressType ”>
<xsd:sequence>
…
</xsd:complexType>
</xsd:schema>
19
20
Associating Schemas and
Instances
<?xml version=”1.0” encoding=”UTF-8”?>
<poNS:po
xmlns:poNS=”http://www.skatestown.com/ns/po”
xmlns:xsi=
”http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=
”http://www.skatestown.com/ns/po
http://www.skatestown.com/schema/po.xsd”
id=”43871” submitted=”2001-10-05”>
...
</poNS:po>
21
Advanced XML Schema
• ##any, ##other Î generic extensibility
<message from=”bj@bjskates.com”…
…
<attachment>
<item>
<poNS:po id=”43871” submitted=”2001-10-05”>
…
<complexType name=“item">
<sequence>
<any namespace="##other" minOccurs="0"/>
</sequence>
</complexType>
22
XML Processing
• SAX
• DOM
• JDOM
• JAX-P
23
More info on XML
• XML intro
– http://www.w3.org/XML/1999/XML-in-10-points
• high level explanations
– http://www.w3.org/XML/Schema
• lots of useful links
– http://www.w3.org/TR/xmlschema-0/
• good read
• Xpath
– http://www.w3.org/TR/xpath
• XML Query
– http://www.w3.org/XML/Query
• Misc. XML
– http://www.w3.org/
• links off the home page
24
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
25
Where does it start?
• Answer:
Web services starts with XML messaging
<SOAP-ENV:Envelope xmlns:SOAP-ENV…
SOAP-ENV:encodingStyle=“…/>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<po:PlacePurchaseOrder xmlns:po=…>
<OrderDate>02/06/01</OrderDate>
<Ship_To>
…
</po: PlacePurchaseOrder >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
buyer.com sends
http to seller.com
26
Where does it start?
• Answer:
Web services starts with XML messaging
seller.com’s
http response to
buyer.com
<SOAP-ENV:Envelope xmlns:SOAP-ENV…
SOAP-ENV:encodingStyle=“…/>
<SOAP-ENV:Header>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<po:PlacePurchaseOrderResponse xmlns:po=…>
<Order>2021</Order>
<ReceivedDate>02/06/01
…
</po: PlacePurchaseOrderResponse >
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
27
XML Messaging
Service Requestor
Service Provider
Application
web service
Application
1
4
3
SOAP
Network Protocol
2
SOAP
Response
Request
(service invocation)
Network Protocol
28
What is SOAP?
• Simple Object Access Protocol
• Simple enveloping mechanism independent
of transport layer
• Payload=Body + Headers
– Body = {RPC | Document}
– Headers = other things
• (security, authorization, payment, etc.)
29
Web services Myth #1
• You have to use SOAP to access a
Web services
• Response:
– Web Services Invocation Framework
(WSIF)
• http://www.alphaworks.ibm.com/tech/wsif
30
The Wire Stack
XML Messaging
XML and
SOAP
Data Encoding
HTTP(R)(S),
SMTP, FTP etc.
Network Protocol
Quality of Service
SOAP
Manageability
Envelope Extensions
Security
SOAP
Headers
31
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
How does buyer.com know
what message to send?
• Answer: by the Service Description
<definitions name="PurchaseOrder"…/">
<types>
<schema targetNamespace=“http://foo.com/PurchaseOrder.xsd” …>
<element name = …
</schema>
</types>
<message name="POInput">
<part name="body" element="po:PORequest"/>
</message>
<message name="POOutput"> …
<portType name="POPortType">
<operation name="PlacePO">
<input message="tns:POInput"/>
<output message="tns:POOutput"/>
</operation>
</portType>
<binding name="POSOAPBinding" type="tns:POPortType">
<soap:binding style="RPC" …
</binding>
<service name="POService">
<port name="POPort" binding="tns:POSOAPBinding">
<soap:address location="http://seller.com/PlacePO"/>
</port>
</service>
</definitions>
32
33
What is
Web Services Definition Language?
Service
Implementation
Definition
Service
Port
Binding
Service
Interface
Definition
PortType
Message
Types
34
What is
Web Services Definition Language?
part
types
abstract interface
portType
(concrete)
(abstract)
message
message
(abstract)
operation
concrete implementation
binding
(concrete)
operation
(concrete)
(concrete)
message
message
made concrete by
service
contains zero or more
concrete endpoint
port
35
Web Services Myth #2
ƒ WSDL is the only thing required to
describe a service
ƒ Response:
ƒ WSDL is basis
ƒ ?WSEL? and WSFL to follow
36
Service Description Stack
WSFL / XLANG
Service Orchestration
?WSEL?
Endpoint Description
WSDL
Service Interface
WSDL
Service Implementation
XML Schema
XML
37
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
38
How does buyer.com know what kind
of service seller.com provides?
ƒ Answer: the service description was found in
a service registry
<Envelope xmlns="http://sch …">
<Body>
<find_business generic="1.0"
xmlns="urn:uddi-org:api">
<name>seller.com</name>
</find_business>
</Body>
</Envelope
>
39
Web Services Myth #3
• UDDI is the only Services Registry standard
• Response:
– WS-Inspection
– http://www.ibm.com/developerworks/webservices/l
ibrary/ws-wsilover/
40
WS-Inspection
• An http GET way to find service descriptions
• Provider does publish:
– Edit one or more .wsil files
– Gives a URL to these .wsil resources to one or
more requestors
• Requestor does find:
– A simple http GET
– Parse the result according to WSIL
– Follow the links and URLs
41
WS-Inspection
<?xml version="1.0"?>
<inspection xmlns="http://schemas.xmlsoap.org/ws/2001/10/inspection/"
xmlns:wsiluddi="http://schemas.xmlsoap.org/ws/2001/10/inspection/uddi/">
<service>
<description referencedNamespace="http://schemas.xmlsoap.org/wsdl/"
location="http://example.com/stockquote.wsdl"/>
<description referencedNamespace="urn:uddi-org:api">
<wsiluddi:serviceDescription location="http://www.example.com/uddi/inquiryapi">
<wsiluddi:serviceKey>4FA28580-5C39-11D5-9FCF-BB3200333F79</wsiluddi:serviceKey>
</wsiluddi:serviceDescription>
</description>
</service>
<service>
<description referencedNamespace="http://schemas.xmlsoap.org/wsdl/"
location="ftp://anotherexample.com/tools/calculator.wsdl"/>
</service>
<link referencedNamespace="http://schemas.xmlsoap.org/ws/2001/10/inspection/"
location="http://example.com/moreservices.wsil"/>
</inspection>
42
The Discovery Stack
UDDI
Directory
WS-Inspection
(WSIL)
Inspection
43
So, What is a Web Service?
• Interface that describes a collection of network accessible
operations.
ƒ
ƒ
ƒ
ƒ
ƒ
ƒ
Described
Published
Found
Bound
Invoked
Composed
¾ Using WSDL & description stack
¾ To UDDI or WSIL
¾ In UDDI or WSIL
¾ Using SOAP
¾ Using SOAP
¾ Using WSFL
44
For More Information
• IBM Web Services
– www.ibm.com/webservices
• IBM developerWorks Web Services Zone
– www.ibm.com/developerworks/webservices
• IBM alphaWorks
– www.alphaworks.ibm.com
• Web Services ToolKit (WSTK)
– www.alphaworks.ibm.com/tech/webservicestoolkit
• Other good sites
– www.salcentral.com, www.xmethods.net
– www.webservices.org
– www.gotdotnet.com
45
This Presentation
•
•
•
•
•
•
Intro to Web services & SOA
XML
Messaging (SOAP, etc)
Description (WSDL, etc)
Registry (WSIL, UDDI)
Current Trends
46
Web Services Standards
• The standards are still evolving
• So are the implementations
DON’T PANIC
47
Wire Protocols
• Base:
– SOAP 1.1
• http://www.w3.org/TR/SOAP
• Recent:
– SOAP 1.2
• http://www.w3.org/TR/soap12/
• Soon:
– JSR 109 (Web services and J2EE)
• http://www.jcp.org/jsr/detail/109.jsp
– Continued W3C evolution of SOAP
• http://www.w3.org/2000/xp/Group/
48
WS-Security
WS-Federation
WS-Authorization
WS-Policy
WS-Trust
WS-Privacy
WS-Security
SOAP Foundation
This is a
composable
Architecture
“only use what
you need”
today
time
WS-Secure
Conversation
http://www.ibm.com/developerworks/security/library/ws-secmap/
49
Implementations & Tooling
•
Base:
– Apache SOAP 2.2
• http://xml.apache.org/soap/index.html
– WebSphere Studio Application Developer
– WSTK 3.1
• http://www.alphaworks.ibm.com/tech/webservicestoolkit
•
Recent:
– WSIF (still evolving)
• http://www.alphaworks.ibm.com/tech/wsif
• http://www.ibm.com/developerworks/library/ws-wsif.html
– JAX-RPC
• http://java.sun.com/xml/jaxrpc/index.html
– Apache Axis (Apache SOAP v 3.0)
• http://xml.apache.org/axis/index.html
•
Soon:
– Next revision of WSTK
50
Service Description
• Base:
– WSDL 1.1
• http://www.w3.org/TR/wsdl
– WSDL4J
• http://www-124.ibm.com/developerworks/projects/wsdl4j/
• Recent:
• Soon:
– WSDL 1.2
• http://www.w3.org/2002/ws/desc
– Refresh of WSFL
51
Service Registry
• Base:
– UDDI (www.uddi.org)
• Recent:
– WS-Inspection
• http://www.ibm.com/developerworks/webservices/library/ws-wsilover/
– UDDI 4J
• http://www.ibm.com/developerworks/projects/uddi4j/
– UDDI Search Engine
• http://www.alphaworks.ibm.com/tech/be4ws
• Soon:
– UDDI v2.0 beta implementations
– UDDI v3.0 specification
52
WS-Interoperability
• WS-I is:
– open, industry organization
– chartered to promote Web services interoperability
across platforms
– provides guidance, best practices, and resources
for developing Web services solutions
• Deliverables:
– Profiles for interoperability
– Implementation scenarios
– Test suites
53
OGSA and Web services
• Stateful Web services instances
– Modifications to WSDL
– Service References
– Lifecycle conventions
• Conventional PortTypes
– Notification mechanisms
• Drive as much of this into Web services
community
– First Step: WSDL extensions from GS Spec
54
Summary
9Intro to Web services & SOA
9XML
9Messaging (SOAP, etc)
9Description (WSDL, etc)
9Registry (WSIL, UDDI)
9Current Trends
55
Questions?
sggraham@us.ibm.com
Download