CP3024 Lecture 10
description
Transcript of CP3024 Lecture 10
![Page 1: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/1.jpg)
CP3024 Lecture 10
Web Services
![Page 2: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/2.jpg)
What are Web Services?
“encapsulated, loosely coupled, contracted software objects offered via standard protocols”
ZapThink Research
![Page 3: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/3.jpg)
Web Services
Encapsulated– Web Service implementation is invisible to
entities outside the service– Exposes an interface but hides details
Loosely Coupled– Service and consumer software can be
redesigned independently
![Page 4: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/4.jpg)
Web Services
Contracted– Description of service is available to consumer
Standard Protocols– TCP/IP
– HTTP
– XML
– SOAP
– WSDL
– UDDI
![Page 5: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/5.jpg)
Self-describing
Every web service has a published public interface– Minimum of human readable documentation– SOAP services should have interfaces written
in XML
![Page 6: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/6.jpg)
Discoverable
Simple mechanism for publishing details about a web service
Simple mechanism for finding a service and its interface
Mechanism could be completely decentralised or centralised registry
![Page 7: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/7.jpg)
A Web Service ..
Is available over networkUses standardised XML messagingIs independent of any given OS or
languageIs self describing via XMLIs easily discoverable
![Page 8: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/8.jpg)
Web Usage Shift
Human-centric Web– Majority of web transactions initiated by a
human
Application-centric Web– Inter-application interchanges– E.g. credit card approval
![Page 9: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/9.jpg)
A Web Service In Action
XML
XML
![Page 10: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/10.jpg)
Possible Protocols
HTTP POST/GETXML-RPCSOAP
– Simple Object Access Protocol
![Page 11: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/11.jpg)
Example Service
Return a set of keys given a set of functional dependencies
Service called keyserviceMethod called getCandidateKeysString argument fdSetArgument sent “{{a}->{b}}”
![Page 12: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/12.jpg)
XML-RPC Service Invocation
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodCall>
<methodName>
keyservice.getCandidateKeys
</methodName>
<params>
<param>
<value>{{a}->{b}}</value>
</param>
</params>
</methodCall>
![Page 13: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/13.jpg)
XML-RPC Response
<?xml version="1.0" encoding="ISO-8859-1"?>
<methodResponse>
<params>
<param>
<value>
{{a}}
</value>
</param>
</params>
</methodResponse>
![Page 14: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/14.jpg)
SOAP
SOAP envelope specification– Rules for encapsulating the data being
transferred
Data encoding rules– Rules for encoding data types
RPC conventions– Rules for invoking remote methods
![Page 15: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/15.jpg)
Example Service Request
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=
http://schemas.xmlsoap.org/soap/envelope/xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body> <ns1:getCandidateKeys
xmlns:ns1="urn:examples:keyservice" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<fdSet xsi:type="xsd:string">{{a}->{b}}</fdSet></ns1:getCandidateKeys> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 16: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/16.jpg)
Example Service Reply
<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <SOAP-ENV:Body> <ns1:getCandidateKeysResponse
xmlns:ns1="urn:examples:keyservice" SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/"> <return xsi:type="xsd:string">{{a}}</return></ns1:getCandidateKeysResponse></SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 17: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/17.jpg)
Soap Message
Structure of SOAP Messages
Envelope (required)
Header (optional)
Body (required)
Fault (optional)
![Page 18: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/18.jpg)
Fault Response
<?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope xmlns:SOAP-ENV=
"http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode>SOAP-ENV:Server</faultcode><faultstring>Exception from service object: FD:
Unexpected end of input</faultstring><faultactor>/soap/servlet/rpcrouter</faultactor></SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 19: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/19.jpg)
Web Services Definition Language (WSDL)
Uses XML to describe a web service– Describes the interface of available functions– Specifies data type information for all requests
and responses– Holds binding information about the transport
protocol– Contains address information to locate the
service
![Page 20: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/20.jpg)
Major Elements
definitions– types– message– portType– binding– ports– service
![Page 21: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/21.jpg)
WSDL definitions
<definitions name="KeyService"targetNamespace=
"http://localhost:8080/wsdl/Lucchesi.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"xmlns:soap=
"http://schemas.xmlsoap.org/wsdl/soap/"xmlns:tns=
"http://localhost:8080/wsdl/Lucchesi.wsdl"xmlns:xsd="http://www.w3.org/2001/XMLSchema">
![Page 22: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/22.jpg)
WSDL types
Optional elementDefines complex types e.g. arrays and
structuresNot used in the example
![Page 23: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/23.jpg)
WSDL message
<message name="CandidateKeyRequest">
<part name="FDSet" type="xsd:string"/>
</message>
<message name="getKeys">
<part name="return" type="xsd:string"/>
</message>
![Page 24: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/24.jpg)
WSDL portType
<portType name="Key_PortType">
<operation name="getCandidateKeys">
<input message="tns:CandidateKeyRequest" name="Request"/>
<output message="tns:getKeys“
name="Response"/>
</operation>
</portType>
![Page 25: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/25.jpg)
WSDL binding
<binding name="Key_Binding" type="tns:Key_PortType"><soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/><operation name="getCandidateKeys">
<soap:operation soapAction="Generate keys"/> <input name="Request"> <soap:body
encodingStyle=
http://schemas.xmlsoap.org/soap/encoding/ namespace="urn:examples:keyservice"
use="encoded"/> </input>
![Page 26: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/26.jpg)
WSDL Binding
<output> <soap:body encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/" namespace="urn:examples:keyservice" use="encoded"/>
</output> </operation></binding>
![Page 27: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/27.jpg)
WSDL Service
<service name="Key_Service"> <documentation> WSDL File for KeyService </documentation> <port binding="tns:Key_Binding" name="Key_Port"> <soap:address location= “http://localhost:8080/soap/servlet/rpcrouter” /> </port></service>
![Page 28: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/28.jpg)
WSDL In Action
Can use WSDL description to generate client code
Can use WSDL description to automatically invoke a service
Can generate WSDL from server code
![Page 29: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/29.jpg)
Available WSDL Services
![Page 30: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/30.jpg)
Generic Soap Client
![Page 31: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/31.jpg)
UDDI
Universal Description, Discovery and Integration
Specification for distributed directory of businesses– Data stored in an XML format
UDDI business registry– Launched May 2001 by IBM and Microsoft
![Page 32: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/32.jpg)
UDDI Development
Developed by IBM, Microsoft and Ariba– Ariba/IBM collaboration on B2B– IBM/Microsoft collaboration on SOAP– Microsoft/Ariba collaboration on BizTalk and
cXMLThree revisions and then transfer to
standards bodyLaunched September 2000
![Page 33: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/33.jpg)
UDDI Development
Version 2.0 announced July 2001– Internationalisation
– Complex organisations
– Better searching mechanisms
Version 3.0 announced July 2002– Increased security
– Improved WSDL support
– Multi-registry topologies
– Proactive notifications
![Page 34: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/34.jpg)
UDDI Technical Architecture
UDDI data model– XML schema describing businesses and web services
UDDI API– SOAP based API for publishing and searching UDDI
data
UDDI cloud services– Sites implementing UDDI which synchronise
regularly
![Page 35: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/35.jpg)
UDDI Data Model
businessEntity– Information about a business
businessService– Information about a web service
bindingTemplate– Information about accessing a service
tModel– Pointer to external technical specification
![Page 36: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/36.jpg)
businessService
Relationships
businessEntity
bindingTemplate
tModel
![Page 37: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/37.jpg)
UDDI Inquiry API
find_binding find_business find_service find_tModel
get_bindingDetailget_businessDetailget_serviceDetailget_tModelDetail
![Page 38: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/38.jpg)
UDDI Publishing API
get_authTokendiscard_authToken save_binding save_business save_service save_tModel
delete_bindingdelete_businessdelete_servicedelete_tModel
![Page 39: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/39.jpg)
Use Of UDDI
Publishing– Advertise services– Allow discovery of standards in use
Searching– Locate details about electronic services of
business partners– Search for suppliers
![Page 40: CP3024 Lecture 10](https://reader035.fdocuments.us/reader035/viewer/2022062408/56813b46550346895da42325/html5/thumbnails/40.jpg)
Summary
Web Services– Mechanism for electronic business on the Web
Based on XMLSOAPWSDLUDDI