SOAP - PowerPoint PPT Presentation

About This Presentation
Title:

SOAP

Description:

Title: Introduction to XML Author: Kanda Runapongsa Last modified by: Kanda Runapongsa Created Date: 11/6/2003 4:23:27 PM Document presentation format – PowerPoint PPT presentation

Number of Views:90
Avg rating:3.0/5.0
Slides: 55
Provided by: KandaRun
Category:
Tags: soap

less

Transcript and Presenter's Notes

Title: SOAP


1
SOAP
  • Kanda Runapongsa
  • (krunapon_at_kku.ac.th)
  • Dept. of Computer Engineering
  • Khon Kaen University

2
Web Services Interaction Diagram
UDDI Registry
1
Request WSDL location
2
Download WSDL
WSDL
Send SOAP messages With XML documents
Web Services
3
3
Why Do We Need SOAP?
  • An acceptable standard for routing and packaging
    XML data exchanged between two applications on a
    network
  • No need to define our own networking, addressing,
    and routing protocols

4
What is SOAP?
  • Simple Object Access Protocol
  • It defines a standard packaging format for
    transmitting XML data between applications on a
    network
  • It is not specific to any programming language,
    product, or hardware platform

5
What is SOAP?
  • SOAP is not a programming language or a business
    application component for building business
    applications
  • SOAP is intended for use as a portable
    communication protocol to deliver SOAP messages,
    which have to be created and processed by an
    application

6
A SOAP Message
  • A SOAP message is just an XML document
  • The message might be sent from one application to
    another to synchronize contact information on two
    different systems
  • SOAP takes advantages of XML namespaces and XML
    schemas

7
Anatomy of a SOAP Message
  • The structural format of a SOAP message contains
    the following elements
  • Envelope
  • Header (optional)
  • Body
  • Attachments (optional)

8
SOAP Envelope
  • The SOAP envelope is the primary container of a
    SOAP messages structure
  • It is the mandatory element of a SOAP message
  • It is represented as the root element of the
    message as Envelope

9
SOAP Envelope Example
  • ltSOAP-ENVEnvelope
  • xmlnsSOAP-ENVhttp//schemas.xmlsoap.org/soap/e
    nvelope/
  • xmlnsxsihttp//www.w3c.org/2001/XMLSchema-inst
    ance
  • xmlnsxsdhttp//www.w3.org/2001/XMLSchema
  • SOAP-ENVencodinghttp//schemas.xmlsoap.org/
    soap/encoding/gt
  • lt! SOAP Header element --gt
  • lt! SOAP Body element ---/gt
  • lt/SOAP-ENVEnvelopegt

10
SOAP Header
  • The SOAP header is represented as the first
    immediate child element of a SOAP envelope
  • The Header element can also contain other
    attributes, such as
  • mustUnderstand
  • actor

11
SOAP Header Example
  • ltSOAP-ENVHeadergt
  • ltwileyTransaction
  • xmlnswileyhttp//jws.wiley.com/2002/booktx
  • SOAP-ENVmustUnderstand1gt
  • ltkeyValuegt5lt/keyValuegt
  • lt/wileyTransactiongt
  • lt/SOAP-ENVHeadergt

12
SOAP Fault Example1
  • ltSOAP-ENVFaultgt
  • ltfaultcodegtSOAP-EnvMustUnderstandlt/faultcodegt
  • ltfaultstringgtHeader element missinglt/faultstringgt
  • ltfaultactorgthttp//jws.wiley.com/GetBookPricelt/fa
    ultactorgt
  • ltdetailgtlt/detailgt
  • lt/SOAP-ENVFaultgt

13
SOAP Body
  • A SOAP envelope contains a SOAP body as its child
    element
  • A Body block of a SOAP message can contain any of
    the following
  • RPC method and its parameters
  • Target application (receiver) specific data
  • SOAP fault for reporting errors and status
    information

14
SOAP Body Example
  • ltSOAP-ENVBodygt
  • ltmGetBookPrice
  • xmlnsmhttp//www.wiley.com/jws.book.priceList
    /gt
  • ltbookname xsitypexsdstringgt
  • Developing Java Web Serviceslt/booknamegt
  • lt/mgetBookPricegt
  • lt/SOAP

15
SOAP Fault
  • In a SOAP message, the SOAP Fault element is used
    to handle errors and to find out status
    information.
  • This element provides the error and /or status
    information
  • It can be used within a Body element or as a Body
    entry

16
SOAP Fault
  • It provides the following elements to define the
    error and status of the SOAP message
  • Faultcode The faultcode element defines the
    algorithmic mechanism for the SOAP application to
    identify the fault
  • Faultstring The faultstring element provides a
    readable description of the SOAP fault
  • Faultactor The faultactor element provides the
    information about the ultimate SOAP actor
  • Detail The detail element

17
SOAP Fault Example1
  • ltSOAP-ENVFaultgt
  • ltfaultcodegtSOAP-ENVServerlt/faultcodegt
  • ltfaultstringgtServer OS Internal Failure Reboot
    serverlt/faultstringgt
  • ltfaultactorgthttp//abzdnet.net/keysoap.asplt/fault
    actorgt
  • lt/SOAP-ENVFaultgt

18
SOAP Fault Example2
  • ltSOAP-ENVFaultgt
  • ltfaultcodegtClientlt/faultcodegt
  • ltfaultstringgtInvalide Requestlt/faultstringgt
  • ltfaultactorgthttp//jws.wiley.com/GetCataloglt/faul
    tactorgt
  • lt/SOAP-ENVFaultgt

19
SOAP mustUnderstand
  • The SOAP understand attribute indicates that the
    processing of a SOAP header block is mandatory
    (the attribute value is 1) or optional (the
    attribute value is 0) at the target SOAP node
  • ltSOAP-ENVHeadergt
  • ltwileyCatalog SOAP-ENVmustUnderstand1/gt
  • lt/SOAP-ENVHeadergt

20
SOAP Fault Example3
  • ltSOAP-ENVBodygt
  • ltSOAP-ENVFaultgt
  • ltfaultcodegtSOAP- EnvMustUnderstandlt/faultcodegt
  • ltfaultstringgtCould not understand Header
    elementlt/faultstringgt
  • lt/SOAP-ENVFaultgt
  • lt/SOAP-ENVFaultgt

21
SOAP Attachments
  • A SOAP message contains the primary SOAP envelope
    in an XML format and SOAP attachments in any data
    format that can be ASCII or binary
  • SOAP attachments are not part of the SOAP
    envelope but are related to the message

22
SOAP Attachments
  • The SOAP attachment part of the message is
    contained to a MIME boundary (defined in the
    Context-Type header)
  • Each MIME part in the structure of the SOAP
    message is referenced using either Content-ID or
    Content-Location as labels for the part

23
SOAP Attachments
  • Both the SOAP header and body of the SOAP message
    also can refer to these labels in the message
  • Each attachment of the message is identified with
    a Content-ID (typically an href attribute using a
    URL scheme) or Content-Location (a URI reference
    associated to the attachment)

24
SOAP Attachment in a MIME Structure
  • MIME-Version 1.0
  • Content-Type Multipart/Related
  • boundaryMIME_boundary typetext/xml
  • Content-Description SOAP message description

25
SOAP Attachment in a MIME Structure
  • --MIME_boundary --
  • Content-Type text/xml charsetUTF-8
  • Content-Transfer-Encoding 8bit
  • Content-ID lthttp//jws.wiley.com/coverpagedetails
    .xmlgt
  • Content-Location http//jws.wiley.com/coverpagede
    tails.xml

26
SOAP Attachment in a MIME Structure
  • lt?xml version1.0?gt
  • ltSOAP-ENVEnvelope
  • xmlnsSOAP-ENVhttp//schemas.xmlsoap.org/soap/e
    nvelope/gt
  • ltSOAP-ENVBodygt
  • lt/SOAP-ENVBodygt
  • lt/SOAP-ENVEnvelopegt

27
SOAP Attachment in a MIME Structure
  • -- MIME_boundary --
  • Content-Type image/gif
  • Content-Transfer-Encoding binary
  • Content-ID lthttp//jws.wiley.com/DevelopingWebSer
    vices.gifgt
  • Content-Location http//jws.wiley.com/Developing
    WebServices.gif
  • lt!-- binary GIF image --gt
  • --MIME_boundary --

28
What is MIME?
  • MIME Multipurpose Internet Mail Extension
  • A standard system for identifying the type of
    data contained in a file based on its extension.
  • MIME is an Internet protocol that allows you to
    send binary files across the Internet as
    attachments to e-mail messages. This includes
    graphics, photos, sound and video files, and
    formatted text documents.

29
SOAP Encoding
  • The SOAP Encoding defines a set of rules for
    exposing its data types
  • SOAP encoding also defines serialization rules
    for its data model using an encodingStyle
    attribute
  • SOAP encoding supports both simple- and
    compound-type values

30
SOAP Encoding Example
  • Simple Type Values
  • The definition of simple type values is based on
    the W3C XML Schema specification
  • Examples
  • ltintgt98765lt/intgt
  • ltdecimalgt98675.43lt/decimalgt
  • ltstringgtJava Ruleslt/stringgt

31
SOAP Encoding Example
  • Array Types example
  • ltMyPortfolio xmlnshttp//www.w3.org/2001/XMLSchem
    a xmlsenchttp//schemas.xmlsoap.org/soap/encodi
    ng encarrayTypexsstring2gt
  • ltsymbolgtSUNWlt/symbolgt
  • ltsymbolgtIBMlt/symbolgt
  • lt/MyPortfoliogt

32
SOAP Message Exchange Model
  • SOAP is a stateless protocol used to exchange
    messages between SOAP applications on a network,
    usually an intranet or the Internet
  • A SOAP application is simply any piece of
    software that generates or processes SOAP
    messages

33
SOAP Message Exchange Model
  • For example, any Java application or J2EE
    component that uses JAX-RPC would be considered a
    SOAP application
  • Because JAX-RPC is used to generate and process
    SOAP message
  • The application sending a SOAP message is called
    the sender and the application receiving it is
    called the receiver

34
SOAP Message Exchange Model
  • As a SOAP message travels along the message path,
    its header blocks may be intercepted and
    processed by any number of SOAP intermediaries
    along the way
  • A SOAP intermediary is both a receiver and a
    sender

35
SOAP Message Exchange Model
  • The applications along the message path (the
    initial sender, intermediaries, and ultimate
    receiver) are called SOAP nodes

Initial Sender
Sender
Intermediaries
36
SOAP Message Exchange Model
Intermediaries
Ultimate receiver
Initial Sender
SOAP
SOAP
SOAP
Customer Node
Sales Node
Inventory Node
Shipping Node
37
SOAP Actor
  • The SOAP actor global attribute with a URI value
    can be used in the Header element
  • SOAP defines an actor with a URI value, which
    identifies the name of the SOAP receiver node as
    an ultimate destination

38
SOAP Actor Example
  • ltSOAP-ENVHeadergt
  • ltbName xmlnsbhttp//www.wiley.com/BookService
    / SOAP-ENVactorhttp//www.wiley.com/jws/
    SOAP-ENVmustUnderstand1gtWebServiceslt/bNamegt
  • lt/SOAP-ENVHeadergt

39
SOAP Communication
  • To enable communication between SOAP nodes, SOAP
    supports the following two types of communication
    models
  • SOAP RPC It defines a remote procedural
    call-based synchronous communication
  • SOAP Messaging It defines a document-driven
    communication where SOAP nodes send and receive
    XML-based documents using synchronous and
    asynchronous messaging

40
SOAP RPC
  • The SOAP RPC representation defines a tightly
    coupled communication model based on requests and
    responses
  • Using RPC conventions, the SOAP message is
    represented by method names with zero or more
    parameters and return values

41
SOAP Request RPC-Based
  • ltSOAP-ENVBodygt
  • ltmGetBookPrice
  • xmlnsmhttp//www.wiley.com/jws.book.priceList
    gt
  • ltbookname xsitypexsdstringgtDeveloping Java
    Web Serviceslt/booknamegt
  • lt/mgetBookPricegt
  • lt/SOAP-ENVBodygt

42
SOAP Response RPC-Based
  • ltSOAP-ENVBodygt
  • ltmGetBookPriceResponse xmlnsmhttp//www.wiley
    .com/jws.book.priceListgt
  • ltpricegt50.00lt/pricegt
  • lt/mGetBookPriceResponsegt
  • lt/SOAP-ENVBodygt

43
SOAP Messaging
  • SOAP Messaging represents a loosely coupled
    communication model based on message notification
    and the exchange of XML documents
  • The SOAP sender node sends a message with an XML
    document as its body message and the SOAP
    receiver node processes it

44
SOAP Message-Based
  • ltenvEnvelope xmlnsenvhttp//www.w3.org/2001/12
    /soap-envelopegt
  • ltenvHeadergt
  • ltnInventoryNotice xmlnsnhttp//jws.wiley.com/
    Inventorygt
  • ltnproductCodegtJ687lt/nproductCodegt
  • lt/nInventoryNoticegt
  • lt/enveHeadergt

45
SOAP Message-Based
  • ltenvBodygt
  • ltmproduct xmlnsmhttp//jws.wiley.com/product
    gt
  • ltmnamegtDeveloping Java Web Serviceslt/mnamegt
  • ltmquantitygt25000lt/mquantitygt
  • ltmdategt2002-07-01lt/mdategt
  • lt/envBodygt
  • lt/envEnvelopegt

46
SOAP Bindings for Transport Protocols
  • The SOAP specifications do not specify and
    mandate any underlying protocols between the SOAP
    nodes
  • SOAP can be used over a variety of transport
    protocols, such as HTTP, SMTP, POP3 and FTP

47
SOAP Request Message Using HTTP
  • POST /GetBookPrice HTTP/1.1
  • User Agent Mozilla/4.0 (Linux)
  • Host krunapon8080
  • Content-Type text/xml charsetutf-8
  • Content-length 546
  • SOAPAction /GetBookPrice
  • lt?xml version1.0?gtltSOAP-ENVEnvelopegt....
  • lt/SOAP-ENVEnvelopegt

48
SOAP Response Message Using HTTP
  • HTTP/1.1 200 OK
  • Connection close
  • Content-Length 524
  • Content-Type text/xml charsetutf-8
  • Date Fri, 3 May 2002 050504 GMT
  • Server Apache/1.3.0
  • lt?xml version1.0?gt
  • ltSOAP-ENVEnvelopegt
  • lt/SOAP-ENVEnvelopegt

49
SOAP Message Exchange Patterns
  • The most common SOAP messaging patterns are as
    follows
  • One-way message. The SOAP client application
    sends SOAP messages to its SOAP server without
    any response being returned
  • Request/response exchange. In this pattern, the
    SOAP client sends a request message that results
    in a response message from the SOAP server to the
    client

50
SOAP Message Exchange Patterns
  • Common SOAP messaging patterns
  • Request/NResponse pattern. It is similar to a
    request/response pattern, except the SOAP client
    sends a request that results in zero to many
    response messages from the SOAP server to the
    client
  • Notification pattern. The SOAP server sends
    messages to the SOAP client like an event
    notification, without regard to a response

51
SOAP Message Exchange Patterns
  • Common SOAP messaging patterns
  • Solicit-response pattern. The SOAP server sends
    a request message to the SOAP client like a
    status checking or an audit and the client sends
    out a response message

52
SOAP Message Exchange Patterns
SOAP Client
SOAP Client
SOAP Client
Request/Response pattern
53
SOAP Message Exchange Patterns
SOAP Request Message
SOAP Response Message
SOAP Client
SOAP Server
SOAP Response Message
Request/NResponse pattern
54
SOAP Message Exchange Patterns
SOAP Message(s)
SOAP Server
SOAP Client
Notification pattern
SOAP Message
SOAP Server
SOAP Response Message
Solicit-response pattern
Write a Comment
User Comments (0)
About PowerShow.com