chapter 4 soap: simple object access protocol y : skena/classes/7818/f... · –a set of rules that...

28
Web Services: Principles & Technology Slide 4.1 Michael P. Papazoglou, Web Services, 1 st Edition, © Pearson Education Limited 2008 Mike P. Papazoglou [email protected] Chapter 4 SOAP: Simple Object Access Protocol

Upload: others

Post on 26-Jan-2021

2 views

Category:

Documents


0 download

TRANSCRIPT

  • Web

    Ser

    vice

    s:P

    rinci

    ples

    & T

    echn

    olog

    y

    Slide 4.1

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Mike P. [email protected]

    Chapter 4SOAP: Simple Object Access Protocol

  • Slide 4.2

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.3

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Inter-Application Communication

    • Conventional distributed applications use distributed communicationtechnologies, e.g., CORBA, DCOM, Java/RMI, based on object RPC(ORPC) protocols that attempted to marry object orientation andnetwork protocols.– ORPC request is an identifier or symbolic name that the server could use to

    locate the target object inside the server process.• Weaknesses

    – Both ends of the communication link would need to be implemented underthe same distributed object model (Java/RMI or CORBA/IIOP)

    – Difficulty of getting these protocols to work over firewalls or proxy servers,e.g, most firewalls are configured to allow hypertext transfer protocol(HTTP) to pass across, but not IIOP.

    • To address the problem of overcoming proprietary systems running onheterogeneous infrastructures, Web services rely on SOAP, an XML-based communication protocol for exchanging messages betweencomputers regardless of their operating systems, programmingenvironment or object model framework.

  • Slide 4.4

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.5

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    What is SOAP?

    • SOAP is the standard messaging protocol used by Web services.SOAP’s primary application is inter application communication. SOAPcodifies the use of XML as an encoding scheme for request andresponse parameters using HTTP as a means for transport.

    Service providerService requestor

    Application object(client)

    Application object(service provider)

    SOAP-basedmiddleware

    SOAP-basedmiddlewareSOAP messages

    exchanged on top of,HTTP, SMTP, or othertransport

    Converts procedure calls to/from XMLmessages sent through HTTP or otherprotocols.

  • Slide 4.6

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    What is SOAP? (continued)

    • SOAP covers the following four main areas:– A message format for one-way communication describing

    how a message can be packed into an XML document.– A description of how a SOAP message should be

    transported using HTTP (for Web-based interaction) or SMTP(for e-mail-based interaction).

    – A set of rules that must be followed when processing aSOAP message and a simple classification of the entitiesinvolved in processing a SOAP message.

    – A set of conventions on how to turn an RPC call into aSOAP message and back.

  • Slide 4.7

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    SOAP as a lightweight protocol

    • SOAP is a lightweight protocolthat allows applications to passmessages and data back andforth between disparate systemsin a distributed environmentenabling remote methodinvocation.

    • By lightweight we mean that theSOAP protocol possesses onlytwo fundamental properties. Itcan:– send and receive HTTP (or

    other) transport protocol packets,and

    – process XML messages.

    • This can be contrasted with theheavyweight protocols such asORPC protocols.

  • Slide 4.8

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Distributed messaging using SOAP

  • Slide 4.9

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.10

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    SOAP messages

    • SOAP is based on message exchanges.• Messages are seen as envelopes where

    the application encloses the data to besent.

    • A SOAP message consists of an element containing anoptional and a mandatory element.

    • The contents of these elements areapplication defined and not a part of theSOAP specification.

    • A SOAP contains blocks ofinformation relevant to how the message isto be processed. This helps passinformation in SOAP messages that is notfor the application but for the SOAP engine

    • The SOAP is where the main end-to-end information conveyed in a SOAPmessage must be carried.

    SOAP envelope

    SOAP header

    header block

    SOAP body

    body block

  • Slide 4.11

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    ……

    … 512

    GRAAL-5YF3

    ……………

    Example of SOAP envelope

    Example of SOAP header

    SOAP envelope and header

  • Slide 4.12

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    SOAP Intermediaries

    • SOAP headers have beendesigned in anticipation ofparticipation of other SOAPprocessing nodes – called SOAPintermediaries – along amessage's path from an initialSOAP sender to an ultimateSOAP receiver.

    • A SOAP message travels alongthe message path from a senderto a receiver.

    • All SOAP messages start with aninitial sender, which creates theSOAP message, and end with anultimate receiver.

  • Slide 4.13

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    uuid:0411a2daa 2004-11-8 Marvin Sanders

    Example of SOAP header withmessage routing

    The “next” role is onethat all SOAP nodes arerequired to support;

    By tagging each headerin this message with the“next” role, this messageis saying that all SOAPnodes (intermediariesand the ultimatereceiver) MUSTunderstand and be ableto process the m:orderheader and then:customer header.

  • Slide 4.14

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    The SOAP Body

    • The SOAP body is the area of the SOAP message, where theapplication specific XML data (payload) being exchanged in themessage is placed.

    • The element must be present and is an immediate child of theenvelope. It may contain a number of child elements, called bodyentries, but it may also be empty. The element contains eitherof the following:– Application-specific data: is the information that is exchanged with a Web

    service. The SOAP is where the method call information and itsrelated arguments are encoded. It is where the response to a method call isplaced, and where error information can be stored.

    – fault message: is used only when an error occurs.

    • A SOAP message may carry either application-specific data or a fault,but not both.

  • Slide 4.15

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Example SOAP Message

    57539

    ACME Softener 35

    Header

    Body

    Blocks

    Envelope

  • Slide 4.16

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.17

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    The SOAP Communication Model

    • SOAP supports two possible communication styles:– remote procedure call (RPC) and– document (or message).

    RPC-style interaction Document-style interaction

  • Slide 4.18

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    RPC-style SOAP Services

    • A remote procedure call (RPC)-style Web service appears as a remoteobject to a client application. The interaction between a client and anRPC-style Web service centers around a service-specific interface.Clients express their request as a method call with a set of arguments,which returns a response containing a return value.

    SOAP envelope

    SOAP bodyMethod nameorderGoodsInput parameter 1product item

    Input parameter 2quantity

    SOAP envelope

    SOAP body

    Method return

    Return valueorder id

  • Slide 4.19

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    512

    450R6OP

    134.32

    Example of RPC-style SOAP body

    Example of RPC-style SOAP response message

    RPC-style web services

  • Slide 4.20

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Document (Message)-style SOAP Services

    • In the document-style of messaging, the SOAP contains anXML document fragment. The element reflects no explicit XMLstructure.

    • The SOAP run-time environment accepts the SOAP elementas it stands and hands it over to the application it is destined forunchanged. There may or may not be a response associated with thismessage.

    SOAP envelope

    SOAP body

    PurchaseOrderdocument

    -product item-quantity

    SOAP envelope

    SOAP body

    Acknowledgementdocument-order id

  • Slide 4.21

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    512

    RightPlastics

    PSC-0343-02 Plastic Supplies Inc. Yara Valley Melbourne injection molder G-100T 2

    Example of document-style SOAP body

    Example of document-style SOAP body

  • Slide 4.22

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.23

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    SOAP Fault element• SOAP provides a model for handling faults arise.• It distinguishes between the conditions that result in a fault, and the ability to

    signal that fault to the originator of the faulty message or another node. TheSOAP is the place where fault information is placed.

    512

    env:Sender m:InvalidPurchaseOrder Specified product did not exist Product number contains invalid characters 129

  • Slide 4.24

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.25

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    SOAP and HTTP

    A binding of SOAP to a transport protocol isa description of how a SOAP message is tobe sent using that transport protocol.

    The typical binding for SOAP is HTTP. SOAP can use GET or POST. With GET,

    the request is not a SOAP message but theresponse is a SOAP message, with POSTboth request and response are SOAPmessages (in version 1.2, version 1.1mainly considers the use of POST).

    SOAP uses the same error and statuscodes as those used in HTTP so that HTTPresponses can be directly interpreted by aSOAP module.

    SOAP envelopeSOAP header

    Transactionalcontext

    SOAP body

    Input parameter 1

    Input parameter 2

    Name of procedure

    HTTP POST

  • Slide 4.26

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    RPC call using SOAP over HTTP

    Service provider

    SOAPengine

    Service implementation(other tiers)

    HTTPengine

    Service requestor

    HTTPengine

    Client implementation (othertiers)

    SOAPengine

    SOAP envelope

    SOAP header

    Transactional context

    SOAP body

    Name of the procedure

    Input parameter 1

    Input parameter 2

    HTTP Post

    SOAP envelope

    SOAP header

    transactional context

    SOAP body

    return parameter

    SOAP envelope

    SOAP header

    Transactional context

    SOAP body

    Return parameter

    HTTP Post

  • Slide 4.27

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Topics

    •• Inter application communicationInter application communication•• SOAP as a messaging protocolSOAP as a messaging protocol•• Structure of a SOAP messageStructure of a SOAP message•• SOAP communication modelSOAP communication model•• SOAP fault messageSOAP fault message•• SOAP over HTTPSOAP over HTTP•• Advantages and disadvantages of SOAPAdvantages and disadvantages of SOAP

  • Slide 4.28

    Michael P. Papazoglou, Web Services, 1st Edition, © Pearson Education Limited 2008

    Advantages and disadvantages of SOAP

    • Advantages of SOAP are:– Simplicity– Portability– Firewall friendliness– Use of open standards– Interoperability– Universal acceptance.

    • Disadvantages of SOAP are:– Too much reliance on HTTP– Statelessness– Serialization by value and not by reference.

    Try not to laugh too hard at this assertion!!!