SOAP (Simple Object Access Protocol) Service Compu-ng Wilfred Blight 2013-01-27 1
Underlying Standards The basic standards for web services are: XML (Extensible Markup Language) SOAP (simple object access protocol) WSDL (web services descrip-on language) UDDI (universal descrip-on, discovery and integra-on) 2
What is a Web Service? Web services are a distributed compu-ng technology. Web services are accessed by sonware only. They are not viewable through a web browser like a website. They are not meant for direct access by a human. They are strictly meant for access by client sonware. 3
Web Services Concept service requestor applica<on object (client) service provider applica<on object (service provider) SOAP- based middleware SOAP messages exchanged on top of, HTTP, SMTP, or other transport SOAP- based middleware converts procedure calls to/from XML messages sent through HTTP or other protocols. Clients invoke web services by exchanging messages. Copyright Springer Verlag Berlin Heidelberg 2004 4
What is a Web Service? A web service is an interface to an applica-on program accessible through a network or the internet. Web services are built using standard internet technologies. 5
<operation name="ordergoods"> <input message = "OrderMsg"/> </operation> WSDL of service provider WSDL compiler (client side) WSDL compiler (server side) service requestor service provider applica<on object (client) stub applica<on object (service provider) skeleton SOAP- based middleware SOAP messages SOAP- based middleware WSDL specifica-on can be compiled into stubs and skeletons. Copyright Springer Verlag Berlin Heidelberg 2004 6
service requestor service provider applica<on object (client) stub applica<on object (service provider) skeleton SOAP- based middleware SOAP messages SOAP- based middleware Copyright Springer Verlag Berlin Heidelberg 2004 SOAP messages (to look for services) SOAP- based middleware service descrip-ons UDDI registry SOAP messages (to publish service descrip<on) Providers adver-se their services in a UDDI registry.
The Problem It is difficult to integrate applica-ons across the internet. Ø Firewalls Ø Lack of standardised protocols Ø Need for loosely coupled interac-ons Ø Interoperability between plasorms Ø Interoperability between programming languages 8
Mo<va<on In the past many distributed applica-ons communicated using remote procedure calls (RPC) between distributed objects like DCOM and CORBA. HTTP is not designed for objects, so RPC calls are not easily adapted to the Internet. Security problems exist so most firewalls block RPC traffic. HTTP is supported by all Internet browsers and servers, so SOAP presents a nice protocol for providing RPC func-onality. 9
SOAP SOAP (simple object access protocol) PlaSorm independent HTTP is used for transport (Passes through firewall) Provides a standard way to structure XML messages. Uses XML as encoding scheme Endpoint HTTP based URL for the target Object mapping: implementa-on specific 10
Why XML Simple text markup language Easily extensible Capable of solving interoperability problem 11
SOAP Messages Web Services are invoked by SOAP Messages. SOAP envelope SOAP header header block SOAP body body block Envelope Defines the content of the message Header (op-onal) contains header informa-on used for intermediate processing. Body Contains call and response informa-on. Contains the core informa-on to be transmiwed to the receiver. Payload 2 aspects affect the construc-on of the header & body. 1 Interac-on style (document or RPC) 2 Encoding rules 12
SOAP envelope SOAP body PurchaseOrder document - product item - quan<ty SOAP envelope SOAP body Acknowledgement document - order id (a) Document- style interac<on SOAP envelope SOAP body method name ordergoods input parameter 1 product item SOAP envelope SOAP body method return return value order id input parameter 2 quan<ty Copyright Springer Verlag Berlin Heidelberg 2004 (b) RPC- style interac<on
Encoding Data can be encoded in different ways in a SOAP message. <ProductItem> <name> </name> <type> </type> <make> </make> </ProductItem> <ProductItem name= type= make= /> <ProductItem name= <type> </type> <make> </make> </ProductItem> The consumer and provider must agree on the encoding. SOAP doesn t impose any specific encoding. SOAP uses XML structures which provides data types for simple types, integer, strings. Complex data types must be serialized into XML. 14
Encoding <?xml version='1.0'?> <env:envelope xmlns:env="http://www.w3.org/2002/06/soap-envelope" > <env:header> <t:transactionid xmlns:t="http://intermediary.example.com/procurement" env:role="http://www.w3.org/2002/06/soap-envelope/role/next" env:mustunderstand="true" > 57539 </t:transactionid> </env:header> <env:body> <m:ordergoods env:encodingstyle="http://www.w3.org/2002/06/soap-encoding" xmlns:m="http://example.com/procurement"> <m:productitem> <name>acme Softener</name> </m:productitem> <m:quantity> 35 </m:quantity> </m:ordergoods> </env:body> envelope header blocks body </env:envelope> Copyright Springer Verlag Berlin Heidelberg 2004
RPC Style call using SOAP over HTTP Both POST and GET are used to transport SOAP messages. service requestor HTTP Post SOAP envelope SOAP header transactional context SOAP body name of the procedure input parameter 1 service provider SOAP engine HTTP engine input parameter 2 HTTP engine SOAP engine client implementa<on (other <ers) HTTP Post SOAP envelope SOAP header transactional context service implementa<on (other <ers) Copyright Springer Verlag Berlin Heidelberg 2004 SOAP body return parameter
Simple SOAP Implementa<on service requestor service provider client implementa<on invokes the service as a local call client stub service implementa<on invokes the local procedure of the service implementa-on server stub invoke SOAP engine to prepare SOAP message SOAP engine packages SOAP into HTTP and passes it to an HTTP client that sends it to the provider HTTP engine the router parses the message, iden-fies the appropriate stub, and delivers the parsed message SOAP router passes the content of the HTTP message to the router HTTP server
WSDL Web Services Descrip-on Language Describes the Web Service and defines the func-ons that are exposed in the Web Service (interface). Defines the XML grammar to be used in the messages Uses the W3C Schema language WSDL is wriwen in XML WSDL is an XML document 18
WSDL specifica<on abstract part types messages opera<ons port types concrete part bindings services and ports Types - Defines the data type that are used by the web service. Uses XML Schema syntax to define data types. Message Is a typed document divided into parts. Each part is characterized by a name and type. The parts can be compared to the parameters of a func-on call in a tradi-onal programming language. Opera<on 1 of 4 transmission primi-ves or interac-ons. One- way, request- response, solicit- response and no-fica-on. Port Type - Defines a web service, the opera-ons that can be performed, and the messages that are involved. [2] Binding Defines the message encoding and the protocol bindings. 2. Source www.w3schools.com/wsdl/wsdl_ports.asp
WSDL specifica<on abstract part types Ports Also known as EndPoints combine the interface binding informa-on with a network address (URL). Services - are logical groupings of ports. messages opera<ons port types concrete part bindings services and ports
<?xml version="1.0"?> <definitions name="procurement" targetnamespace="http://example.com/procurement/definitions" xmlns:tns="http://example.com/procurement/definitions" xmlns:xs="http://www.w3.org/2001/xmlschema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/" > <message name="ordermsg"> <part name="productname" type="xs:string"/> <part name="quantity" type="xs:integer"/> </message> WSDL service specifica<on abstract part messages <porttype name="procurementporttype"> <operation name="ordergoods"> <input message = "OrderMsg"/> </operation> </porttype> opera-on and port type <binding name="procurementsoapbinding" type="tns:procurementporttype"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="ordergoods"> <soap:operation soapaction="http://example.com/ordergoods"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding> <service name="procurementservice"> <port name="procurementport" binding="tns:procurementsoapbinding"> <soap:address location="http://example.com/procurement"/> </port> </service> </definitions> concrete part binding port and service
1. WSDL documents can be generated from server API. 2. Stubs and skeletons are created by WSDL compiler. WSDL of service provider WSDL compiler (client side) 2 WSDL compiler (server side) 1 WSDL generator service requestor service provider applica<on object (client) stub applica<on object (service provider) skeleton SOAP- based middleware SOAP messages SOAP- based middleware
UDDI Universal Descrip-on, Discovery and Integra-on A UDDI Server acts as a registry for Web Services. UDDI provides the ability to search for Web Services. UDDI can be referred to as the yellow- pages for web services. 23
businessen<ty name contacts descrip-on iden-fiers categories businessservice service key name descrip-on categories bindingtemplate binding key descrip-on address detailed info references to tmodels tmodel tmodel key tmodel key name key name descrip-on name descrip-on overviewdoc descrip-on overviewdoc iden-fiers overviewdoc iden-fiers categories iden-fiers categories categories tmodel tmodel key key name name descrip-on descrip-on overviewdoc overviewdoc iden-fiers iden-fiers categories categories Specs stored at the provider s site Copyright Springer Verlag Berlin Heidelberg 2004 Stored in the UDDI registry
tmodel Techincal model. A generic container for any kind of specifica-on. Could represent a WSDL service interface A classifica-on Interac-on protocol 25
Sec-on for human reading. overviewdoc (refer to WSDL specs and to API specs) <tmodel tmodelkey= uddi:uddi.org:v3_publication > <name>uddi-org:publication_v3</name> <description>uddi Publication API V3.0</description> <overviewdoc> <overviewurl usetype= wsdlinterface > http://uddi.org/wsdl/uddi_api_v3_binding.wsdl#uddi_publication_soapbinding </overviewurl> </overviewdoc> <overviewdoc> <overviewurl usetype= text > http://uddi.org/pubs/uddi_v3.htm#pubv3 </overviewurl> </overviewdoc> classifica-on informa-on (specifies that this tmodel is about XML, WSDL, and SOAP specs) <categorybag> <keyedreference keyname= uddi-org:types:wsdl keyvalue="wsdlspec" tmodelkey="uddi:uddi.org:categorization:types /> <keyedreference keyname= uddi-org:types:soap keyvalue="soapspec" tmodelkey="uddi:uddi.org:categorization:types /> <keyedreference keyname= uddi-org:types:xml keyvalue="xmlspec" tmodelkey="uddi:uddi.org:categorization:types /> <keyedreference keyname= uddi-org:types:specification keyvalue="specification" tmodelkey="uddi:uddi.org:categorization:types /> </categorybag> </tmodel> Example of a UDDI tmodel describing the UDDI API
Publishing There are mul-ple UDDI registries. The UDDI registry used to register a web service is said to have custody over the service. Registries replicate their informa-on between registries. This allows clients to search for web services from any UDDI registry. 27
service requestor service provider SOAP/HTTP SOAP/HTTPS Inquiry API Publishers API Inquiry API Publishers API Web service interface Web service interface service descrip-ons UDDI registry A Subscrip<on, Replica<on, and Custody transfer APIs (SOAP/HTTPS) service descrip-ons UDDI registry B Interac<on with and between UDDI registries for replica<on and custody transfer.
service requestor service provider WSDL service descrip-ons SOAP/HTTP Inquiry API SOAP/HTTPS Publishers API Web service interface tmodel service descrip-ons businessen<ty businessservice bindingtemplate UDDI registry Schematic view of the relation between UDDI and WSDL
Searching for WSDL Service Interface Service Type <?xml version="1.0"?> <find_tmodel generic="1.0" xmlns="urn:uddi-org:api"> <categorybag> <keyedreference tmodelkey="uuid:c25893af-1977-3528-36b5-4192c2ab9e2c" keyname="uddi-org:types" keyvalue="wsdlspec"/> <keyedreference tmodelkey="uuid:a15019c5-ae14-236c-331c-650857ae0221" keyname="book pricing" keyvalue="36611349"/> </categorybag> Locate all of the book pricing services, defined using WSDL. Copyright Springer Verlag Berlin Heidelberg 2004
service provider service implementa<on WSDL generator 1 Database stored procedure interface has: server stub WSDL service descrip-ons Procedure name Defined Parameters SOAP router WSDL compiler 2 Known output. HTTP engine UDDI publisher 3 Web service easily created using SOAP. businessen<ty businessservice bindingtemplate tmodel Inquiry API Publishers API UDDI registry
Demo
hwp://www.w3.org References