soap. history of rpcs there are 2 dominant communication models: –message passing: allows system...

56
SOAP

Upload: kelly-perry

Post on 27-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP

Page 2: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

History of RPCs

• There are 2 dominant communication models:– Message Passing: allows system to send and

receive messages any time– Request Response: restrict systems to

request-response pairs, hence natural fit for RPC

Page 3: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

RPC Protocols (1980s)

• Dominant RPC protocols were– Sun RPC: NFS (UNIX Systems)– DCE RPC: Windows NT (System Services)

• Both were quite functional and adaptable

Page 4: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

ORPC Protocols (1990s)

• Codified mapping of communication endpoint to language level object.– Used object ID, interface ID, method ID and

in-out parameters to locate and call methods– Endpoints were named using portable Object

References

• How was earlier communication endpoint

Page 5: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• 1990s: ORPC Protocols– CORBA’s IIOP– DCOM

• They differed in– Interface ID– Format of parameter values (NDR in DCOM,

CDR in IIOP)

• Were incompatible

Page 6: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

What’s wrong?

• good for server to server communication but severe weakness for client to server communication

• Both rely on single vendor solution– DCOM, every machine runs NT– CORBA, every machine runs same ORB

product

• Rely on closely administered network• Rely on fairly hi-tech runtime environment

Page 7: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Inability to work with Internet scenarios– In case of DCOM, unable to perform domain

based authentication with servers– Firewall reduce likelihood of getting through of

IIOP or DCOM packets, due to HTTP bias– Vendors have built-in tunneling technologies,

but are very sensitive to configuration mistakes and are not interoperable

Page 8: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Server to Server Communication

• Smaller number of machines-reduced cost of management

• Common administration-consistent configuration

• Direct Connectivity-no firewall problems

Page 9: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

HTTP as a better RPC

• CORBA and DCOM for server to server and HTTP for Client to Server

• RPC Style Protocol: simple, widely deployed and likely to function in face of firewalls

• Handled by Web server software

Page 10: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Request Response over TCP/IP

• Example of HTTP Request Message

POST /foobar HTTP/1.1

Host: 209.110.197.12

Content-Type: text/plain

Content-Length: 12

Hello World

Page 11: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Example of HTTP Response200 OK

Content-Type: text/plain

Content-Length: 12

dlrow ,olleH

400 Bad Request

Content-Length: 0

Page 12: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Wide deployment of HTTP

• CGI to write HTTP server code for lowest common denominator

• Every HTTP server provides a much more efficient mechanism to get your code to process HTTP request

• IS provides ASP and ISAPI• Apache allows C or PERL modules to run• Most application server modules allow you to

write Servlets, COM components, EJB Session Beans, CORBA servants etc.

Page 13: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

XML

• XML is not a markup language. It’s a set of rules for creating a new markup language such as HTML etc.

• Subset of SGML• SGML: formalized method for capturing the

metadata for a document by using markup on the content.

• SGML defines rules for creating markups in terms of tags and tree structure which is called Data Type Definition (DTD).

Page 14: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

XML & HTML

• HTML is an application of SGML.• Extensions to HTML with growth of web were

counter productive and ill suited to general use• To provide interoperability and scalability, a

simplified version of SGML was developed by W3C which is XML

• XML is not intended to replace HTML, both are complimentary

• XML is more general and better for data sharing on web than extending HTML

Page 15: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Extending a single language to every possible case is impossible. Such domains of data can be structured and captured by XML compliant markup language

• XML specifies specific syntax and semantic rules and constraints for creating new markup language

• You create HTML, MATHXML, CML documents, which you design using rules laid out in XML specification.

Page 16: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Components of XML

• Elements: Lexical construct of a document– Contains content, either character data or other elements

• Attributes: characteristics of an element– name/value pairs

• Comments: free text description• Document Type Definition:

– Declares all legal elements– Legal attributes elements can have– Hierarchy, nesting and occurrence indicators of all elements– In order for a document to be valid, it must satisfy what DTD it

adheres to. A document declares its DTD in a document type declaration.

Page 17: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Element declaration– Every element in a valid XML document must

correspond to an element type declared in DTD

– Examples:

Page 18: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Attribute List Declaration– Example

• Syntactic Rules– An XML document is valid if

• it declares a document type definition and conforms to element and attribute declaration in DTD

• It follows all syntax rules specified in XML specification

Page 19: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• XML Examples

Page 20: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

HTTP+XML=SOAP

• SOAP – Light weight protocol for exchange of

information in a decentralized, distributed environment

– Consists of 3 parts• Envelop: defines framework for describing what is

in a message and how to process it• Encoding Rules: for expressing instances of

application defines data types• Convention for representing remote procedure

calls and responses

Page 21: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Uses XML as encoding scheme

• Request-Response structure of HTTP

• SOAP Method: – HTTP Request and Response that complies

with SOAP encoding rules

• SOAP EndPoint– HTTP based URI that identifies target for

method invocation

Page 22: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• SOAP Request:– HTTP POST request, use text/xml content-type– Must contain request URI – Server interpretation is application specific: it may

map request URI to classname, objects, may use cookies to recover state

– Request must include method name to be invoked, using SOAPMethodName HTTP header

– HTTP payload is simply an XML document that contains values for in and in,out parameters

Page 23: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• SOAP Response– Similar to request– Response payload will contain out and in, out

parameters of the method called

• XML aspects of SOAP are simply an encoding scheme for serializing instances of data types in XML

• The request-response object are serialized in a well known format. XML schema is used to define the object characteristics : Structure and Attributes

Page 24: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP

• Provides definition of XML based information which can be used for indexing structured and types information between peers in a decentralized, distributed environment.

• Formally specified as an XML Infoset which provides abstract description of its contents

• Fundamentally 1 way message exchange paradigm, but applications can create more complex interaction patterns by underlying protocol and/or application specific information

Page 25: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Silent on semantics of application-specific data, however– it provides framework by which application

specific information may be conveyed in an extensible manner.

– It provides full description of the required actions to be taken by a SOAP node on receiving SOAP message

Page 26: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Message Exchange Model

• SOAP implementation can be optimized to exploit the unique characteristics of particular network systems. e.g. – SOAP response messages can be delivered as HTTP

responses to inbound request

• Regardless of protocol used, the messages are routed along a message path which allows for processing at one or more intermediate nodes in addition to the ultimate destination

Page 27: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• A SOAP application on receiving a SOAP message must process that message by performing following actions:– Identify all parts of SOAP message intended for that application– Verify that all mandatory parts are supported by application and

process them accordingly. If not, discard the message– Optional parts may be ignored– Remove all identified parts before forwarding the message

• Processing an application requires that SOAP processor understands message exchange pattern being used, role of recipient, employment of RPC (if any)

Page 28: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Messages

• Relation to XML– Messages are encoded using XML– Message should include proper SOAP

namespace on all elements and attribtes defined by SOAP

– Application must be able to process namespaces in messages that it receives

– Applications must discard messages with incorrect namespace

Page 29: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Example

Header Block-1

Header Block-2

BODY subelement-1

BODY subelement-2

SOAP Envelop

Page 30: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

<?xml version='1.0' ?><env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> <env:Header> <m:reservation xmlns:m="http://travelcompany.example.org/reservation" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference> <m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime> </m:reservation> <n:passenger xmlns:n="http://mycompany.example.com/employees" env:role="http://www.w3.org/2003/05/soap-envelope/role/next" env:mustUnderstand="true"> <n:name>Åke Jógvan Øyvind</n:name> </n:passenger> </env:Header>

Example

Page 31: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

<env:Body> <p:itinerary xmlns:p="http://travelcompany.example.org/reservation/travel"> <p:departure> <p:departing>New York</p:departing> <p:arriving>Los Angeles</p:arriving> <p:departureDate>2001-12-14</p:departureDate> <p:departureTime>late afternoon</p:departureTime> <p:seatPreference>aisle</p:seatPreference> </p:departure> <p:return> <p:departing>Los Angeles</p:departing> <p:arriving>New York</p:arriving> <p:departureDate>2001-12-20</p:departureDate> <p:departureTime>mid-morning</p:departureTime> <p:seatPreference/> </p:return> </p:itinerary> <q:lodging xmlns:q="http://travelcompany.example.org/reservation/hotels"> <q:preference>none</q:preference> </q:lodging> </env:Body></env:Envelope>

Page 32: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Message Format

• The messages are serialized in a well known format– Every SOAP payload in an XML document which is

distinguished root element called <Envelop>– All SOAP specific elements are scoped by the SOAP

URI– Envelop contains an optional <Header> followed by

mandatory <Body>– <Body> had one distinguished root which is either a

request or response

Page 33: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• SOAP Header: Its an extension mechanism that provides a way to pass information in SOAP messages that is not application payload. – (e.g. passing directives, authentication transaction

management, payment information, contextual information)

– Header entry is identified by its fully qualified name (namespace URI + local name)

– SOAP ‘mustunderstand’ and ‘actor’ attribute may be used to indicate how to process the entry and by whom

Page 34: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– SOAP headers have been designed in anticipation of various uses for SOAP, many of which involve

• Participation of other SOAP nodes called intermediaries

• This allows intermediaries to provide value added services

Page 35: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Header Attributes

• Define how a recipient of a SOAP message should process the message

• SOAP ‘actor’ attribute– Some parts of some messages may be intended for

intermediaries and not the ultimate destination– Actor attribute is used to indicate the recipient of a

header element. The value of actor attribute is a URI– A recipient must not forward the header element to

next application in SOAP message path. It may insert a similar or modified header but in that case the contract is between that node and the recipient of the header element

Page 36: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• SOAP ‘mustunderstand’ attribute– To indicate the entry is mandatory or optional

for recipient– If = 1, recipient must obey semantics and

process correctly or must fail– Allows robust evolution

Page 37: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Body

• Provides simple mechanism for exchanging mandatory information intended for the ultimate recipient of the message

• Must be present

• Each body entry is identified by namespace URI and a local name

Page 38: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Fault

• Used to carry error and/or status information with in SOAP message

• If present, must appear as Body entry and must not appear more than once

• Defines 4 sub-elements– Fault code– Fault string– Actor– Detail

Page 39: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Processing Model

• Describes the actions taken by a SOAP node on receiving a SOAP message

• The first step is overall check that the SOAP message is syntactically correct, i.e. conforms to processing instructions and DTD

Page 40: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• “role” attribute– Further processing of header and body elements

depend on the role assumed by a SOAP node for processing a given message

– SOAP defines the (optional) role attribute that may be present in a header block

– It identifies the role played by the intended target of the header block.

– SOAP node is required to process a header block if it assumes the role identified by the value of the URI

Page 41: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– 3 standard roles have been identified• none• next• ultimateReceiver

– Example 7a– <p:oneBlock xmlns:p=“http://example.com”

env:role=“http://example.com/Log”> ….

</p:oneBlock>– Here the header block is targeted at any SOAP node

that plays the application defined role by the URI http://example.com/Log

Page 42: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– Node receiving message with header block with role=next must be capable of processing the contents of the element.

– Message having header block with role=none implies no SOAP node should process its content

– If there is no role attribute, its implied to be intended for the ultimate receiver

– Body has no role attribute but it is always targeted for the ultimate receiver

Page 43: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• “mustunderstand” attribute– To ensure that SOAP nodes do not ignore header

blocks which are important to overall purpose of the application

– If “true”, the node must process the block– Processing of a message must not start until the node

identifies all mandatory parts of the header blocks targeted to itself and understood them

– Node must be capable to process whatever is described in that block’s specification or else discard it generating SOAP fault

Page 44: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– Processing may include removing header or reinserting header with same or altered value or inserting a new header

– Inability to process a header may require all further processing of the message cease and a fault be generated. This message is not forwarded further

– Body has no mustunderstand attribute but it must be processed by the ultimate recepient

Page 45: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• “relay” attribute– Indicates whether a header block targeted at SOAP

intermediary must be relayed if not processed– If a header block is processed, the rules require that it

be removed from outbound message, however it maybe inserted changed or unaltered by the node).

– The default behavior for an unprocessed header block targeted at a a role played by SOAP intermediary is to remove it before relaying the message.

– This is to ensure that intermediary makes no assumptions about survivability past itself of a header block targeted at a role it assumes, particularly if it chooses not to process it

Page 46: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– Can be used to introduce a header block targeted at any capable intermediary which might be encountered on SOAP path.

– So the incapable intermediaries should ignore and relay it (opposite to default rule), so that it could be available for those who are capable

– This can be done by mustUnderstand=false, relay=true

Page 47: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

SOAP Encoding

• Generalization of common features found in type systems in programming languages, databases etc.

• Defines rules so that an XML schema can be defined for representing the structure and constraints on datatypes

• Instances of the schema can be developed given certain values of the datatypes

• (in what detail??)

Page 48: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• Infoset

• Namespace

• Schema

Page 49: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Rules for encoding types in XML

• XML allows flexible encoding, SOAP defines narrower set of rules

• Serialization rules

Page 50: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Using various protocol bindings

• SOAP messages can be passed using a variety of underlying protocols, including other application layer protocols

• Specification of how SOAP messages may be passed from one SOAP node to another using an underlying protocol is called SOAP Binding

• SOAP Message is described in terms of elements and attributes in an abstract document.

• This abstract document is made concrete by protocol bindings whose task is to provide a serialized representation of the infoset that can be conveyed to the next node, in such a way that message can be represented without loss of information

Page 51: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• There can be different types of bindings– Pure XML– Compressed structure – Encrypted structure

Page 52: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• In addition to providing a concrete realization, SOAP message provides a mechanism to support features by SOAP application– A request-response feature– An encrypted feature– A reliable delivery feature

Page 53: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

• If a feature is not available through binding, it may be implemented with in the SOAP envelop using header blocks (identified by some URI). This specification of features implemented is called SOAP module– Is using UDP, SOAP module itself has to provide

message correlation or directly the application should take care of it

– If using HTTP as a protocol providing the service, the application could inherit this feature provided by binding and no further support is needed

Page 54: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

– A SOAP message travels along several hops, where each hop may have a different protocol binding. So any feature that is required by an application and may not be available can be carried as a SOAP module

Page 55: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

Using SOAP with HTTP

• HTTP implicitly correlates request with response• SOAP follows the HTTP request/response

message model providing SOAP request parameters in HTTP request and response in HTTP response

• HTTP allows multiple intermediaries between client and server. However SOAP intermediaries are different from HTTP intermediaries.

Page 56: SOAP. History of RPCs There are 2 dominant communication models: –Message Passing: allows system to send and receive messages any time –Request Response:

What’s the difference and how the new one is better

• RPC– ???

• ORPC • Single vendor solution• Close administration• Hi-tech runtime environment• Inability to work with internet scenario• Good for server to server communication but bad for client to server

• HTTP• Simple, widely deployed, likely to function in firewalls, webserver support

– HTML• Difficult to extend to different cases…

– XML• hence allow user defined language by providing rules to create language

• SOAP– Protocol using HTTP and XML