Topic6 Basic Web Services Technology


Published on

Published in: Business, Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Topic6 Basic Web Services Technology

  1. 1. Basic Web Services Technology Sanjoy Sanyal (Tech for NonGeek)
  2. 2. Basic Technology Components <ul><li>XML </li></ul><ul><li>SOAP </li></ul><ul><li>WSDL </li></ul><ul><li>UDDI </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  3. 3. SOAP Sanjoy Sanyal (Tech for NonGeek) Application Object (client) SOAP-based middleware Service requestor Application Object (service provider) SOAP-based middleware Service provider SOAP messages exchanged on top of HTTP, SMTP or other transport protocol Converts procedure calls to/from XML messages sent through HTTP or other protocols Clients can invoke Web Services by exchanging SOAP messages Services can exchange messages by means of standardized conventions to turn a service invocation into an XML message, to exchange the message and to turn the XML message back into an actual service invocation
  4. 4. WSDL Sanjoy Sanyal (Tech for NonGeek) Application Object (client) SOAP-based middleware Service requestor WSDL of service provider WSDL compiler (client side) WSDL compiler (server side) Application Object (service provider) SOAP-based middleware Service provider stub skeleton The programming interface of a Web service can be specified using WSDL. The interface is specified in terms of methods supported by the Web service, and the corresponding input and output messages WSDL specifications can be compiled into stubs and skeletons, analogous to IDL in conventional middleware. Dashed lines denote steps performed at development time, solid line to those performed at run-time SOAP messages
  5. 5. UDDI Sanjoy Sanyal (Tech for NonGeek) Application Object (client) SOAP-based middleware Service requestor Application Object (service provider) SOAP-based middleware stub skeleton SOAP messages (to look for services) Service provider SOAP-based middleware Service descriptions SOAP messages SOAP messages (to publish service descriptions) UDDI standardizes the Web services registry Providers advertise their services in a UDDI registry. Clients (at development or run-time) look for services in the registry, thereby statically or dynamically binding to a service. Then clients can invoke the service
  6. 6. SOAP Sanjoy Sanyal (Tech for NonGeek)
  7. 7. SOAP specifications <ul><li>A message format for one-way communication, describing how information can be packaged into XML </li></ul><ul><li>Conventions to implement RPC interaction pattern, defining how remote services can be invoked </li></ul><ul><li>Set of rules that any entity that processes a SOAP message must follow </li></ul><ul><li>Description of how a SOAP message should be transported on top of HTTP and SMTP </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  8. 8. SOAP message Sanjoy Sanyal (Tech for NonGeek) SOAP envelope SOAP header header block SOAP body body block Applications enclose information in a SOAP envelope Each envelope has a header and a body . Both can have multiple sub-parts in the form of blocks . The header is not mandatory The core of the information that is to be transmitted to the receiver is in the body Any additional information for intermediate processing or value added services (transactional interaction, security) goes into the header
  9. 9. SOAP messages: interaction styles Sanjoy Sanyal (Tech for NonGeek) SOAP body PurchaseOrderDocument -product item-quantity SOAP envelope SOAP body Acknowldge document -orderid SOAP envelope Document style interaction The two interacting applications agree upon the structure of the documents to be exchanged SOAP body Methodname OrderGoods SOAP envelope Input parameter 1 Product item Input parameter 1 Quantity SOAP body Method return SOAP envelope Return value Order id RPC style interaction The two interacting applications agree upon the RPC method signature The body of the requesting message includes the name of the procedure being invoked and the input parameters. The body of the response message contains the output parameters
  10. 10. SOAP messages: encoding rules <ul><li>SOAP does not impose any specific form of encoding </li></ul><ul><ul><li>SOAP 1.2 does specify SOAP encoding which defines how data structures can be serialized into XML </li></ul></ul><ul><ul><li>Applications are free to agree on other encoding (literal encoding) </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  11. 11. SOAP message processing <ul><li>Every message has: A sender, An ultimate receiver and a number of intermediary nodes that process and route </li></ul><ul><li>Nodes are typically the middleware architecture: </li></ul><ul><ul><li>They process the header of the SOAP message </li></ul></ul><ul><li>A Header block can be assigned to following roles: </li></ul><ul><ul><li>None: will not be processed by a node (can be read) </li></ul></ul><ul><ul><li>UltimateReceiver: block is solely meant for the ultimate receiver </li></ul></ul><ul><ul><li>Next: every node can process the message </li></ul></ul><ul><li>Header block can have a mustUnderstand flag: </li></ul><ul><ul><li>A node playing that role must process the block and if it cannot raise a fault </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  12. 12. SOAP: Binding to a Transport protocol <ul><li>SOAP does not impose any transport protocol </li></ul><ul><li>Typically associated with HTTP or SMTP </li></ul><ul><li>The specification of which protocol to use is called a binding </li></ul><ul><li>Functions of the binding: </li></ul><ul><ul><li>Defines how the message has to be treated using the primitives of the transport protocol (GET/POST etc. for HTTP) </li></ul></ul><ul><ul><li>Addressing (since the identification of the ultimate receiver is not part of a SOAP message) </li></ul></ul><ul><ul><li>Routing (since there is no mechanism to describe a SOAP path as a part of a SOAP message) </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  13. 13. Simple SOAP implementation Sanjoy Sanyal (Tech for NonGeek) Client implementation SOAP engine Service requestor Client stub HTTP Engine Invokes the service as a local call Invokes SOAP engine to prepare SOAP message Packages SOAP into HTTP and passes it to an HTTP client that sends it to provider Service implementation SOAP router Service requestor server stub HTTP server Invokes the local procedure of the service implementation Router parses the message, identifies the appropriate stub and delivers the parsed message Passes the content of the HTTP message to the router SOAP supports asynchronous interaction of loosely coupled interactions Any further complications such as two-way synchronous messaging or transactions requires SOAP to be associated with an underlying protocol or middleware that has additional properties
  14. 14. WSDL <ul><li>Web Services Description Language </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  15. 15. WSDL Goals <ul><li>Specifications as XML documents that describe Web services and service interfaces </li></ul><ul><li>Role and purpose similar to IDLs with differences: </li></ul><ul><ul><li>Also needs to define the protocols to access the services </li></ul></ul><ul><ul><li>Also needs to define the locations at which the service is available </li></ul></ul><ul><ul><li>Also needs to handle the cope with the complexity of several asynchronous messages used in Web Services </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  16. 16. WSDL Interface Structure Sanjoy Sanyal (Tech for NonGeek) abstract part types WSDL specification messages operations port types concrete part bindings Services & ports Each port type is a logical collection of related operations Each operation defines an exchange of messages The type system allows the data that is being exchanged to be correctly interpreted. By default WSDL uses the same type system as XML Schemas, although a different type system can be specified in necessary <ul><li>InterfaceBindings specifies the message encoding and protocol bindings (for example: </li></ul><ul><li>interaction style: (RPC style operation/document style) -transport bindings (SOAP/SOAP is typical but not mandatory, HTTP/SMTP given SOAP,) </li></ul><ul><li>encoding rules) (SOAP encoding/literal encoding) </li></ul><ul><li>Ports: also called EndPoints combine the InterfaceBinding information to a network address (specified by a URI) </li></ul><ul><li>Services : logical grouping of Ports </li></ul>
  17. 17. Defining a WSDL Interface: Steps Sanjoy Sanyal (Tech for NonGeek) Step 1: Identify and Define all the data structures that will be exchanged as parts of messages between applications Step 2: Define messages that build on data structures. In WSDL each message is divided into parts Step 3: Define operations (also called transmission primitives or interactions). Four basic operations: one-way, request-response, solicit-response, notification One-way and notification operations require a single message . Asynchronous interactions are defined using one-way and notification operations Request-Response and Solicit-Response requires two messages. The former is initiated outside the service and the latter by the service. Synchronous interactions are defined using these operations. Step 4: Group operations into port types Step 5: Define a concrete service by specifying concrete binding, encoding, locations ….
  18. 18. WSDL Implications <ul><li>Solicit-response operation: </li></ul><ul><ul><li>A service can proactively initiate the interaction </li></ul></ul><ul><li>Separation of abstract and concrete: </li></ul><ul><ul><li>Different services could combine different interfaces using different bindings and make them available at different addresses </li></ul></ul><ul><li>Both SOAP with WSDL are generic standards </li></ul><ul><ul><li>SOAP is a generic envelope to wrap invocations that the applications may make using other tools </li></ul></ul><ul><ul><li>WSDL is a generic service description for services built using other languages </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  19. 19. Using WSDL Sanjoy Sanyal (Tech for NonGeek) Application Object (client) SOAP-based middleware Service requestor WSDL of service provider WSDL compiler (client side) WSDL compiler (server side) Application Object (service provider) SOAP-based middleware Service provider stub skeleton WSDL documents can be automatically generated thru APIs Dashed lines indicate compile-time activities First, WSDL is generated. Next, stubs and skeletons are generated. SOAP messages WSDL generator 1 2
  20. 20. UDDI: Universal Description Discovery Integration Sanjoy Sanyal (Tech for NonGeek)
  21. 21. UDDI Goals <ul><li>Specifies a framework for describing and discovering Web services </li></ul><ul><ul><li>Business registry : sophisticated naming and directory service </li></ul></ul><ul><ul><li>Defines data structures and APIs for publishing service descriptions in the registry and for querying the registry </li></ul></ul><ul><li>Universal Business Registry: </li></ul><ul><ul><li>Worldwide directory for services was the original goal </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  22. 22. Information in a UDDI registry <ul><li>White pages: </li></ul><ul><ul><li>Listing of organizations, their contact information and the services they provide </li></ul></ul><ul><ul><li>To find Web services provided by a given business </li></ul></ul><ul><li>Yellow pages: </li></ul><ul><ul><li>Classification of both organizations and Web services </li></ul></ul><ul><ul><li>To find Web services according to a category </li></ul></ul><ul><li>Green pages: </li></ul><ul><ul><li>Describes how a given Web service can be invoked </li></ul></ul><ul><ul><li>Points to description documents stored outside the registry </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek)
  23. 23. UDDI Data Sanjoy Sanyal (Tech for NonGeek) Type of Data Description businessEntity Describes an organization that provides Web services businessService Describes a group of related Web services offered by a businessEntity,. businessService may correspond to one type of service but provided at multiple addresses, versions, technologies (protocols, bindings) bindingTemplate Describes the technical information necessary to use a particular Web service tModel Stands for “technical model”-generic container for any kind of specification. (for e.g.: WSDL service interface, interaction model…)
  24. 24. UDDI Data Sanjoy Sanyal (Tech for NonGeek) businessEntity name contacts description identifiers categories businessService service key name description categories bindingTemplate binding key description address detailed info references to tModels tModel key name description overviewDoc identifiers categories tModel key name description overviewDoc identifiers categories Specs stored at the provider’s site One businessEntity can include One businessService can include Multiple businessServices Multiple bindingTemplates
  25. 25. tModel Structure <ul><li>The actual content (Service Description) </li></ul><ul><ul><li>Resides within an overviewDoc to which the tModel points but which is stored outside the registry </li></ul></ul><ul><ul><li>overviewDoc can be in any structure and written in any language </li></ul></ul><ul><li>A tModel once published is assigned a unique key </li></ul>Sanjoy Sanyal (Tech for NonGeek)
  26. 26. UDDI Registry API Sanjoy Sanyal (Tech for NonGeek) UDDI registries have three main types of users: service providers, service requestors, other registries that need to exchange information UDDI API Description UDDI Inquiry API To find registry entries ( find_business,find_binding,find_tModel) To get details about a specific entity ( get_businessDetail,get_serviceDetail, get_bindingDetail,get_tModelDetail ) UDDI Publishers API Add, Modify, delete entries in the registry ( save_business,save_ service,save_binding,save_tModel,delete_business,delete_service ….) UDDI Security API Get and discard authentication tokens ( get_authToken, discard_authToken ) UDDI Subscription API Monitors changes in a registry by subscribing to track new, modified and deleted entries ( delete_subscription,get_subscriptionResults,get_subscriptions, save_subscriptions ) UDDI Replication API Supports replication of information between registries, so that different registries can be kept synchronized.
  27. 27. UDDI Access Points & APIs Sanjoy Sanyal (Tech for NonGeek) Service Requestor Service Provider Web service interface Service descriptions Web service interface Service descriptions Subscription, Replication and Custody transfer APIs SOAP/HTTP SOAP/HTTPS Inquiry API Publishers API UDDI registers maintain different access points (URIs) for requestors, publishers and other registries to separate inquiries that do not require authentication from those they do. Registries interact to transfer the custody of an entity and replicate information. Each entity is owned by a single registry
  28. 28. UDDI & WSDL <ul><li>WSDL interface definitions (specifically port types and protocol bindings) are registered as tModels: </li></ul><ul><ul><li>whose overviewDoc will point to the corresponding WSDL document </li></ul></ul>Sanjoy Sanyal (Tech for NonGeek) businessEntity businessService bindingTemplate tModel WSDL Service descriptions Service provider
  29. 29. Public and Private Registries Sanjoy Sanyal (Tech for NonGeek) Registry Description Public Provides Open and public access to registry data Private Internal registry isolated behind a firewall Used by organizations to support integration of internal applications Shared/Semi-private Deployed within a controlled environment and shared with trusted partners
  30. 30. Web Services at Work Sanjoy Sanyal (Tech for NonGeek) Service implementation SOAP router Service provider server stub HTTP Engine WSDL generator WSDL service descriptions WSDL compiler UDDI publisher 1 2 3 businessEntity businessService bindingTemplate tModel UDDI publisher Inquiry API Publishers API Exposing an internal service as a Web Service Step 1: Generation of WSDL Step 2: Generation of servlet and registration with SOAP router Step 3: Registration in UDDI registry
  31. 31. Web Services @ work - Steps Sanjoy Sanyal (Tech for NonGeek) Exposing an internal service as a Web Service Step 1: The interface of the procedure is translated into a description of the Web service by mapping the information into the corresponding WSDL structure Step 2: The generated WSDL is stored at the providers site. A WSDL compiler can then create a server stub (in the form of a servlet in the Java world) and register the servlet with the SOAP router so that the router knows it has to invoke the servlet whenever a certain URI is invoked. Step 3: A tModel is published that refers to the generated WSDL in a UDDI registry accessible to clients. Next, new businessService and a bindingTemplate entities are published providing the address at which the service is available and referencing the tModel. Scenario: WSDL specification has been provided and the service provider wants to offer a service compliant with the standardised interface Step 1: WSDL is retrieved from the UDDI registry, following the pointer in the tModel Step 2: The WSDL compiler generates the code required on the server side. The servlet (in the Java world) is registered with the SOAP router Step 3: Publication of the UDDI registry as above. This time there is no need to register the tModel sine it has already been regsitered.
  32. 32. Related Standards Sanjoy Sanyal (Tech for NonGeek) Standard Description WS – Addressing Proposes a protocol-neutral mechanism for specifying endpoint references of services within SOAP messages I mplementation Example : Creating one stateful persistent object for each new client, which manages all the interactions with the client. WS – Routing Allows a way of specifying which intermediaries should be visited by a SOAP message WS - Security Extension to SOAP that defines a SOAP header block (called Security) which is where security information can be included WS - Policy Framework thru which clients and services can express their policies (requirements, capabilities, preferences) WSIF Web Services Invocation Framework – a pluggable framework that allows providers to be added to an existing Web Services infrastructure. This allows a service to be invoked thru a WSDL binding
  33. 33. Summary <ul><li>SOAP </li></ul><ul><ul><li>Interactions in Web Services happens thru SOAP </li></ul></ul><ul><ul><li>Provides standardized way to encode interaction mechanisms into XML documents </li></ul></ul><ul><ul><li>Defines transport bindings </li></ul></ul><ul><li>WSDL </li></ul><ul><ul><li>Defines interface to a Web Service </li></ul></ul><ul><ul><li>The interface is specified in terms of methods supported by the Web service, and the corresponding input and output messages </li></ul></ul><ul><li>UDDI </li></ul><ul><ul><ul><li>Defines data structures and APIs for publishing service descriptions in the registry and for querying the registry </li></ul></ul></ul><ul><li>(the material in this topic is based on Web Services: Concepts, Architectures and Applications by Alonso, Casati, Kuno, Machiraju) </li></ul>Sanjoy Sanyal (Tech for NonGeek)