grid computing, b. wilkinson, 20043b.1 web services part ii

Post on 28-Dec-2015

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Grid Computing, B. Wilkinson, 2004 3b.1

Web ServicesPart II

Grid Computing, B. Wilkinson, 2004 3b.2

Web Services

From http://www.globus.org

Grid Computing, B. Wilkinson, 2004 3b.3

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.4

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.5

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.6

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.7

Web Service Application

Grid Computing, B. Wilkinson, 2004 3b.8

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.9

Web Service Application

Call client stubSOAP

requestRequest service

Result returnedSOAP

responseClient receives result

Grid Computing, B. Wilkinson, 2004 3b.10

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.11

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.12

Elements of a WSDL document

Grid Computing, B. Wilkinson, 2004 3b.13

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.14

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.15

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.16

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.17

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.18

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.19

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.20

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.21

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.22

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.23

Building a ServicePreliminary 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.24

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.25

• 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.26

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.27

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.28

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.

top related