Transcript slides3b

Web Services
Part II
Grid Computing, B. Wilkinson, 2004
3b.1
Web Services
From http://www.globus.org
Grid Computing, B. Wilkinson, 2004
3b.2
Address of a Web Service
• URIs
Example (URL)
http://www.cs.wcu.edu/webservices/math1
This does not exist, and if did, would only
be meaningful to software.
Grid Computing, B. Wilkinson, 2004
3b.3
Client-Service Implementation
• Suppose we have found the service and
have its WSDL description, i.e. got past
step 4.
• In the implementation, it is convenient to
use stubs - java classes suitable for
web services defined with WSDL.
Grid Computing, B. Wilkinson, 2004
3b.4
Client Stub
• Between the client code and the network is a
client stub, sometimes called client proxy.
• The client stub is responsible for taking a request
from the client and converting the request into a
SOAP request on the network - marshalling.
• Also responsible for receiving SOAP responses
on network and converting to a suitable form for
client.
Grid Computing, B. Wilkinson, 2004
3b.5
Server Stub
• Between the service and the network is a server
stub, sometimes called a skeleton.
• Responsible for receiving a SOAP request from
the client stub and converting it into a suitable
form for the service -unmarshalling.
• Also converts the response from the service into a
SOAP message for the client stub.
Grid Computing, B. Wilkinson, 2004
3b.6
Web Service Application
Grid Computing, B. Wilkinson, 2004
3b.7
Steps
• Client calls client stub.
• SOAP request sent across network
• Server stub receives request and sends
request to service
• Service send result to serve stub
• Server stub sends result across network
to client stub.
• Client stub sends result to client.
Grid Computing, B. Wilkinson, 2004
3b.8
Web Service Application
Request service
SOAP
request
Result returned
SOAP
Client receives result
response
Grid Computing, B. Wilkinson, 2004
Call client stub
3b.9
Web Service Description
• Need a way of formally describing a
service, what is does, how it is
accessed, etc.
• An Interface Description language (IDL)
Grid Computing, B. Wilkinson, 2004
3b.10
Web Service Definition
Language (WSDL)
A W3C standard XML document that
describes three fundamental properties of a
service:
• What it is - operations (methods) it provides.
• How it is accessed - data format, protocols.
• Where it is located - protocol specific
network address.
Grid Computing, B. Wilkinson, 2004
3b.11
Elements of a WSDL
document
Grid Computing, B. Wilkinson, 2004
3b.12
Parts of a WSDL Document
Parts of an WSDL document::
•
•
•
•
•
•
Root definitions - namespaces
portType definitions - abstract definition of service
Message definitions - parameters in method signature
Type definitions - data types
Binding definitions - to protocols I.e. SOAP over HTTP
Service definitions - where service is, ports
Grid Computing, B. Wilkinson, 2004
3b.13
portType
Describes “What” - an abstract definition
of service operation. Uses the elements:
• message definitions - a set of
parameters referred to by method
signature, decomposed into parts
• type definitions - defines all data types
used
Grid Computing, B. Wilkinson, 2004
3b.14
Binding
Describes “how” the elements in
abstract interface (portType) are
converted in actual data representations
and protocols e.g. SOAP over HTTP.
Grid Computing, B. Wilkinson, 2004
3b.15
port and service
• Describes “where” service is.
• port - describes how a binding is
deployed at the endpoint of a network
• service - a named collection of ports
Grid Computing, B. Wilkinson, 2004
3b.16
Root definitions
<?xml version=“1.0”?>
<definitions name=“PriceCheck”
targetNamespace=“http://www.skatestown.com/services/PriceCheck”
xmlns:pc=“http://www.skatestown.com/services/PriceCheck”
xmlns:avail=“http://www.skatestown.com/ns/availability”
xmlns:xsd=“http://www.w3.org/2001/XMLSchema”
xmlns:soap=“http://schemas.xmlsoap.org/wsdl/”>
.
<!-- other definitions -->
.
</definitions>
Grid Computing, B. Wilkinson, 2004
3b.17
portType definitions
<!-- Port type definitions -->
<portType name=“PriceCheckPortType”>
<operation name=“checkPrice”>
<input message=“PriceCheckRequest”/>
<output message=“PriceCheckResponse”/>
</operation>
</portType>
Grid Computing, B. Wilkinson, 2004
3b.18
Message definitions
<!-- Message definitions -->
<message name=“PriceCheckRequest”>
<part name=“sku” type=“xsd:string”/>
</message>
<message name=“PriceCheckResponse”>
<part name=“result” type=“avail:availabilityType”/>
</message>
Grid Computing, B. Wilkinson, 2004
3b.19
Type definitions
<!-- Type definitions -->
<types>
<xsd:schema targetNamespace=“http://www.skatestown.com/ns/availability”
xmlns:xsd=“http://www.w3.org/23001/XMLSchema”>
<xmlns:complexType name=“availabilityType”>
<xsd:sequence>
<xsd:element name=”sku” type=“xsd:string”/>
<xsd:element name=“price” type=“xsd:double”/>
<xsd:element name=“quantityAvailable” type=“xsd:integer”/>
</xsd:sequence>
</xmlns:complexType>
</xsd:schema>
</types>
Grid Computing, B. Wilkinson, 2004
3b.20
Binding definitions
<!-- Binding definitions -->
<binding name=“PriceCheckSOAPBinding” type=“pc:PriceCheckPortType”>
<soap:binding style=“rpc”
transport=“http://schemas.xmlsoap.org/soap/http”/>
<operation name=“checkPrice”>
<soap:operation soapAction=“”/>
<input>
<soap:body use=“encoded”
namespace=“http://www.skatestown.com/services/PriceCheck”
encodingStype=“http://schemas/xmlas.xmlsoap.org/soap/encoding?”/>
</input>
<output>
<soap:body use=“encoded”
namespace=“http://www.skatestpwn.com/services/PriceCheck”
encodingStype=“http://schemas/xmlas.xmlsoap.org/soap/encoding?”/>
</output>
</operation>
Grid Computing, B. Wilkinson, 2004
3b.21
Service definitions
<!-- Service definitions -->
<service name=“PriceCheckService”>
<port name=“PriceCheck” binding=“pc:PriceCheckSOAPBinding”>
<soap:address
location=
“http://localhost:8-8-/axis/services/PriceCheck”/>
</port>
</service>
</definitions>
Grid Computing, B. Wilkinson, 2004
3b.22
Building a Service
Preliminary to Assignment 1
To build (deploy) a service one has to
create:
• a WSDL document for the service
• the client stub
• the server stub
and test with a client.
Grid Computing, B. Wilkinson, 2004
3b.23
Java Web Service (JWS)
(The easy way to deploy a service)
• With JWS facility, service code with jws
extension in the Axis-enabled web
application is interpreted a web service.
• .jws file automatically compiled if
necessary when service called.
• Simple and used in assignment 1 but
has limitations.
Grid Computing, B. Wilkinson, 2004
3b.24
• Could actually use the web service after
deployment with JWS without using a
WSDL file nor stubs!
• Just use the service URL which would
have a .jws extension - need some code
in client and service to make SOAP
calls.
Grid Computing, B. Wilkinson, 2004
3b.25
WSDL from Code
• One can write the service code (as a
class or interface) and then use tools to
generate the WSDL document.
– Axis Java2WSDL program generates
WSDL file (and its scheme).
Grid Computing, B. Wilkinson, 2004
3b.26
WSDL from Running Service
• Another Axis tool can generate the
WSDL document.directly from a
running deployed service.
• add ?wsdl onto service URL.
• Example of this in assignment 1
Grid Computing, B. Wilkinson, 2004
3b.27
Stubs from WSDL
• If we have the WSDL document for the
service, can use tools to generate client
and server stubs:
– Axis WSDL2Java program generates stubs
for use on client and server
– Example of this in assignment 1.
Grid Computing, B. Wilkinson, 2004
3b.28