Sei sulla pagina 1di 20

Slides for Chapter 9

Web Services

From Coulouris, Dollimore, Kindberg and Blair


Distributed Systems:
Concepts and Design
Edition 5, Addison-Wesley 2012
Figure 9.1
Web services infrastructure and components

Applications
Directory service Security Choreography

Web Services Service descriptions (in WSDL)

SOAP

URIs (URLs or URNs) XML HTTP, SMTP or other transport

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.2
The travel agent service combines other web services

flight bookinga
flight booking
b

Travel Agent
Client
Service hire car bookinga

hire car bookingb


hotel bookinga hotel bookingb

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.3
SOAP message in an envelope

envelope

header

header element header element

body
body element body element

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.4
Example of a simple request without headers

env:envelope xmlns:env =namespace URI for SOAP envelopes


env:body

m:exchange
xmlns:m = namespace URI of the service description
m:arg1 m:arg2
Hello World

In this figure and the next, each XML element is represented by a shaded
box with its name in italic followed by any attributes and its content

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.5
Example of a reply corresponding to the request in Figure 9.4

env:envelope xmlns:env = namespace URI for SOAP envelope


env:body
m:exchangeResponse
xmlns:m = namespace URI for the service description
m:res1 m:res2
World Hello

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.6
Use of HTTP POST Request in SOAP client-server communication

POST/examples/stringer endpoint address

header
Host:www.cdk4.net

HTTP
ContentType:application/soap+xml
Action:http://www.cdk4.net/examples/stringer#exchange action

<env:envelopexmlns:env= namespaceURIforSOAPenvelope
<env:header></env:header>

message
<env:body></env:body>

Soap
</env:Envelope>

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.7
Java web service interface ShapeList

importjava.rmi.*;
publicinterfaceShapeListextendsRemote{
intnewShape(GraphicalObjectg)throwsRemoteException;1
intnumberOfShapes()throwsRemoteException;
intgetVersion()throwsRemoteException;
intgetGOVersion(inti)throwsRemoteException;
GraphicalObjectgetAllState(inti)throwsRemoteException;
}

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.8
Java implementation of the ShapeList server

importjava.util.Vector;
publicclassShapeListImplimplementsShapeList{
privateVectortheList=newVector();
privateintversion=0;
privateVectortheVersions=newVector();
publicintnewShape(GraphicalObjectg)throwsRemoteException{
version++;
theList.addElement(g);
theVersions.addElement(newInteger(version));
returntheList.size();
}
publicintnumberOfShapes(){}
publicintgetVersion(){}
publicintgetGOVersion(inti){}
publicGraphicalObjectgetAllState(inti){}
}
InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.9
Java implementation of the ShapeList client

packagestaticstub;
importjavax.xml.rpc.Stub;
publicclassShapeListClient{
publicstaticvoidmain(String[]args){/*passURLofservice*/
try{
Stubproxy=createProxy();1
proxy._setProperty2
(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY,args[0]);
ShapeListaShapeList=(ShapeList)proxy;3
GraphicalObjectg=aShapeList.getAllState(0);4
}catch(Exceptionex){ex.printStackTrace();}
}
privatestaticStubcreateProxy(){5
return
(Stub)(newMyShapeListService_Impl().getShapeListPort());6
}
}
InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.10
The main elements in a WSDL description

definitions
types message interface bindings services

target namespace document style request-reply style how where


abstract concrete

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.11
WSDL request and reply messages for the newShape operation

message name = "ShapeList_newShape" message name = "ShapeList_newShapeResponse"

part name ="GraphicalObject_1" part name= "result"


type = "ns:GraphicalObject " type = "xsd:int"

tns target namespace xsd XML schema definitions

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.12
Message exchange patterns for WSDL operations

Name Messagessentby

Client Server Delivery Faultmessage


Request Reply mayreplaceReply
InOut
Request nofaultmessage
InOnly
RobustInOnly Request guaranteed maybesent

OutIn Reply Request mayreplace Reply

OutOnly Request nofaultmessage


RobustOutOnly Request guaranteed maysendfault

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.13
WSDL operation newShape

operation name = "newShape"


pattern = In-Out
input message = tns:ShapeList_newShape

output message = "tns:ShapeList_newShapeResponse"

tns target namespace xsd XML schema definitions


The names operation, pattern, input and output are defined in the XML schema for WSDL

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.14
SOAP binding and service definitions

binding service
name = ShapeListBinding name = "MyShapeListService"
type = tns:ShapeList
soap:binding transport = URI endpoint
for schemas for soap/http
style= "rpc" name = "ShapeListPort"
binding = "tns:ShapeListBinding"
operation
name= "newShape"
input soap:address
soap:body location = service URI
encoding, namespace

output
soap:body
encoding, namespace

soap:operation the service URI is:


soapAction http://localhost:8080/ShapeList-jaxrpc/ShapeList

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.15
The main UDDI data structures

businessEntity businessServices
human readable businessServices
information
businessServices bindingTemplate
about the publisher
human readable
bindingTemplate
information URL
about a bindingTemplate tModel
family of services information tModel
about the
URL
serviceinterfaces
service interfaces
tModel
key URL
key service descriptions
key

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.16
Algorithms required for XML signature

Typeofalgorithm Nameofalgorithm Required reference

Messagedigest SHA1 Required Section7.4.3

Encoding base64 Required [FreedandBorenstein1996]

Signature DSAwithSHA1 Required [NIST1994]

(asymmetric) RSAwithSHA1 Recommended Section7.3.2

MACsignature HMACSHA1 Required Section7.4.2andKrawczyk


(symmetric) etal. [1997]

Canonicalization CanonicalXML Required Page810

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.17
Algorithms required for encryption(in Figure 9.16 are also required)

Typeofalgorithm Nameofalgorithm Required reference

Blockcipher TRIPLEDES, required Section7.3.1


AES128
AES256
AES192 optional

Encoding base64 required [FreedandBorenstein1996]

Keytransport RSAv1.5, required Section7.3.2


RSAOAEP [KaliskiandStaddon1998]

Symmetrickey TRIPLEDES required [Housley2002]


wrap(signature KeyWrap,
bysharedkey) AES128KeyWrap,
AES256KeyWrap
AES192KeyWrap optional

Keyagreement DiffieHellman optional [Rescorla,1999]

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.18
Travel agent scenario

1.Theclientasksthetravelagentserviceforinformationaboutasetofservices;forexample,flights,car
hireandhotelbookings.
2.Thetravelagentservicecollectspricesandavailabilityinformationandsendsittotheclient,which
choosesoneofthefollowingonbehalfoftheuser:
(a)refinethequery,possiblyinvolvingmoreproviderstogetmoreinformation,thenrepeatstep2;
(b)makereservations;
(c)quit.
3.Theclientrequestsareservationandthetravelagentservicechecksavailability.
4.Eitherallareavailable;
orforservicesthatarenotavailable;
eitheralternativesareofferedtotheclientwhogoesbacktostep3;
ortheclientgoesbacktostep1.
5.Takedeposit.
6.Givetheclientareservationnumberasaconfirmation.
7.Duringtheperioduntilthefinalpayment,theclientmaymodifyorcancelreservations

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012
Figure 9.19
A selection of Amazon Web Services

InstructorsGuideforCoulouris,Dollimore,KindbergandBlair,DistributedSystems:ConceptsandDesignEdn.5
PearsonEducation2012

Potrebbero piacerti anche