Web Services

Download Report

Transcript Web Services

CIS*6650.01
Service-Oriented Computing
Qusay H. Mahmoud, Ph.D.
[email protected]
Qusay H. Mahmoud
CIS*6650.01
1
Web Services…
RPC the XML way (two ways)
– 1) XML-RPC (xml-rpc.com)
– 2) SOAP
JAX-RPC, JAX-WS, …
Document vs. RPC Style
REST
Web Services Architecture
– http://www.w3.org/TR/ws-arch
Qusay H. Mahmoud
CIS*6650.01
2
XML-RPC
A specification and implementation that enable
applications running in a heterogeneous
environment to make procedure calls over the
Internet
Defined at UserLand Software in 1998
Uses HTTP as the transport protocol and XML
for encoding
Designed to be as simple as possible, allowing
complex data structures to be transmitted,
processed, and returned
Qusay H. Mahmoud
CIS*6650.01
3
XML-RPC
Not a solution to every problem.
Simple and effective mean for exchanging
information (spec is less than 10 pages with
examples and FAQ)
"We wanted a clean, extensible format that's very
simple. It should be possible for an HTML coder to
be able to look at a file containing an XML-RPC
procedure call, understand what it's doing, and be
able to modify it and have it work on the first or
second try... We also wanted it to be an easy to
implement protocol that could quickly be adapted to
run in other environments or on other operating
systems." - xmlrpc.com
Simplicity makes it limited
Qusay H. Mahmoud
CIS*6650.01
4
Sample
XML-RPC request
testcase.getMonthName(3)
Qusay H. Mahmoud
CIS*6650.01
5
Sample
XML-RCP Response
Qusay H. Mahmoud
CIS*6650.01
6
XML-RPC to Java Mapping
Explore mapping to other languages
Qusay H. Mahmoud
CIS*6650.01
7
SOAP
A Lightweight XML-based protocol for exchanging
information in a distributed environment
More complex than XML-RPC (over 40 pages)
Makes extensive use of XML namespaces and
attribute specification tags in every element of a
message
Adds features that don’t exist in XML-RPC: userdefined data types, specify recipient, message
specific processing control, and others
Qusay H. Mahmoud
CIS*6650.01
8
Sample
See Week2 slides
Qusay H. Mahmoud
CIS*6650.01
9
Comparison
XML-RPC vs. SOAP
Qusay H. Mahmoud
CIS*6650.01
10
XML-RPC vs. SOAP
SOAP supports request routing and pre-processing of
requests via SOAP headers
XML-RPC is lighter, taking up less bandwidth, and
requiring less processing power
SOAP is namespace-aware (in fact every element
must be namespace-qualified)
SOAP has a heavy-weight, robust data typing
mechanism based on XML Schemas
XML-RPC is easily sent and consumed, and is easily
readable by humans
SOAP messages have a considerable amount of
packaging contained in the envelope, but this allows
for flexibility in the messaging paradigm used (publishsubscribe, point-to-point, etc.)
Qusay H. Mahmoud
CIS*6650.01
11
JAX-RPC
The push for Java API started in 2001 as
JSR-101 (jcp.org)
V1.0 released in 2003
Java primitives are tied to XML schema types
Supports more Java standard library objects
(e.g. BigInteger)
Architects of JAX-RPC has XML-RPC and
SOAP in mind
Qusay H. Mahmoud
CIS*6650.01
12
JAX-WS
Next version of the spec is known as JAX-WS (JSR224) Java API for XML-based Web Services
Aims to reduce the complexity of web service
development
Java WSDP 1.6 (use GlassFish)
Use JAX-RPC if:
–
–
–
–
–
Using simple requests
You control both the client/server
You don’t need to publish WSDL
Want to keep client-side parsing simple
But remember…using standards is a good thing for
interoperability (your apps need to interact with other third
party apps)
Qusay H. Mahmoud
CIS*6650.01
13
Resources
XML-RPC spec: xml-rpc.com/spec
SOAP: w3.org/TR/soap
JAX-WS (JAX-RPC 2.0): https://jaxrpc.dev.java.net/ (JSR 224:
http://www.jcp.org/en/jsr/detail?id=224)
Apache XML-RPC:
http://ws.apache.org/xmlrpc/
UserLand Frontier (frontier.userland.com)
Many others…explore on your own
Qusay H. Mahmoud
CIS*6650.01
14
Document vs. RPC Style
SOAP was originally designed to support
RPC style
Later (starting with SOAP 1.0), the spec
expanded to support RPC and unstructured
messages (document)
RPC style: SOAP Body must conform to a
structure that indicates the method name
and a set of parameters
Document style: SOAP Body can be
structured in any way you like
Qusay H. Mahmoud
CIS*6650.01
15
RPC vs. Document Style
Source: Anne Thomas Manes Blog, atmanes.blogsport.com
Message encoding: literal means Body contents conform to a specific XML
Schema, SOAP encoding uses a set of rules based on XML Schema data
types to encode the data
RPC: includes an operation name or place holder and document style
doesn’t (significant architectural style)
This document style example uses a state transfer style
See more examples: http://www128.ibm.com/developerworks/webservices/library/ws-whichwsdl/
Qusay H. Mahmoud
CIS*6650.01
16
State Transfer Style
Such as MOM (Message-Oriented
Middleware), pipe-and-filter
Architectural constraint: all components
expose the same application interface
– Through a single operation such as “process
Data”
– If a server exposes this operation, any client can
submit data to it for processing
– Since there is one operation, its use is implicit
and doesn’t need to be included in the message
Qusay H. Mahmoud
CIS*6650.01
17
REST
REpresentational State Transfer
– An architectural style
– Think of it as a design pattern
– Underlying concept for today’s Web architecture
– Every distinguishable entity is a resource
– URLs identify resources
– An approach for creating Web services
Qusay H. Mahmoud
CIS*6650.01
18
REST
See the slides from
http://www.xfront.com/REST.ppt
Qusay H. Mahmoud
CIS*6650.01
19
When to use REST or SOAP
REST
– The web services are stateless
– A caching infrastructure can be leveraged
– Service’ producer and consumer have mutual understanding of the context and
content being passed along
– Bandwidth is limited
– Web service delivery into exiting web sites can be enabled easily with a RESTful
style
SOA
– A formal contract must be established to describe the interface that the Web
service offers
– The architecture must address complex non-functional requirements
– The architecture needs to handle asynchronous processing and invocation
See details at:
http://java.sun.com/developer/technicalArticles/WebServices/restful/ (read
the section When to use REST)
Qusay H. Mahmoud
CIS*6650.01
20
Web Services Architecture
http://www.w3.org/TR/ws-arch
Provides a common definition of a Web service,
and defines its place within a larger Web
services framework to guide the community
Provides a conceptual model and a context for
understanding Web services and the
relationships between the components of this
model
Defines minimal characteristics common to all
Web services, and characteristics that are
needed by some but not all Web services
Doesn’t specify how Web services are
implemented
Qusay H. Mahmoud
CIS*6650.01
21
Web
Services
Architecture
Four models: Message-Oriented, Service-Oriented,
Resource-Oriented, Policy)
Core concepts and relationships of WS
Source: http://www.w3.org/TR/ws-arch
Qusay H. Mahmoud
CIS*6650.01
22