Simple Object Access Protocol - PowerPoint PPT Presentation

About This Presentation
Title:

Simple Object Access Protocol

Description:

SOAP is not restricted to port 80. Web Services: SOAP. 5. POST /Temperature HTTP/1.1 ... 'http://www.w3.org/2001/06/soap-envelope' s:Body /s:Body /s: ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 30
Provided by: bbsW3
Learn more at: http://bbs.w3china.org
Category:

less

Transcript and Presenter's Notes

Title: Simple Object Access Protocol


1
Simple Object Access Protocol
2
Why Simple Object Access Protocol
  • Light weight replacement for complicated
    distributed object technology
  • Originally for BizTalk (Microsoft/UserLand/Develop
    mentor)
  • Now a W3C standard
  • Based on XML and HTTP

3
Port vs Web Server
External Application
Internal Service
External Application
Internal Service
TCP
External Application
Internal Service
4
Port vs Web Server
External Application
Internal Service
Web Server
External Application
Internal Service
XML payload
TCP
External Application
Internal Service
  • XML-RPC
  • Port 80?
  • SOAP is not restricted to port 80

5
SOAP over HTTP
  • Request example

POST /Temperature HTTP/1.1 Host
www.weather.com Content-Type text/xml Content-Len
gth ltwhatevergt SOAPAction urnStockQuoteGetQuo
te ltsEnvelope xmlnsshttp//www.w3.org/2001/
06/soap-envelope"gt ltsBodygt
lt/sBodygt lt/sEnvelopegt
HTTP Header
Soap Extensions
XML Payload (SOAP request)
6
SOAP over HTTP
  • Response example

HTTP Header
  • HTTP/1.1 200 OK
  • Content-Type text/xml
  • Content-Length ltwhatevergt
  • ltsEnvelope xmlnsshttp//www.w3.org/2001/06/soa
    p-envelope"gt
  • ltsBodygt
  • lt/sBodygt
  • lt/sEnvelopegt

XML Payload (SOAP response)
7
SOAP Example Request
  • ltsoapEnvelopegt
  • ltsoapBodygt
  • ltxmlnsm "http//www.amzn.org/books" /gt   
  • ltmGetBookPricegt
  • ltmBookNamegtFast Food
  • Nationlt/mBookNamegt  
  •     lt/mGetBookPricegt
  • lt/soapBodygt
  • lt/soapEnvelopegt

8
SOAP Example Response
  • ltsoapEnvelopegt
  • ltsoapBodygt
  • ltxmlnsm"http//www.amzn.org/books" /gt
  • ltmGetBookPriceResponsegt
  • ltmPricegt34.5lt/mPricegt
  • lt/mGetBookPriceResponsegt
  • lt/soapBodygt
  • lt/soapEnvelopegt

9
SOAP Example Error
  • ltsoapFaultgt
  • ltfaultcodegt0x800700Elt/faultcodegt
  • ltfaulstringgtUnknown booklt/faultstringgt
  • lt/soapFaultgt

10
SOAP Message
  • A SOAP message is contained within an XML
    envelope, complete with a Header and Body

SOAP Envelope
SOAP Header (optional)
SOAP Body payload
11
SOAP Message with Binary Attachments
  • A SOAP message can also contain binary
    attachments using MIME encoding

MIME Header
MIME Boundary
Root Body Part
SOAP Envelope
SOAP Header (optional)
SOAP Body payload
MIME Boundary
Body Part
Attachment
12
SOAP Structure
  • Envelope contains
  • Header
  • Body
  • Header is optional
  • Out-of-band information such as
  • Authentication information
  • Message routes
  • Logging
  • Transaction flow
  • Body contains XML body of RPC call

13
SOAP Example
  • lt?xml version"1.0" encoding"UTF-8" ?gt
  • ltenvEnvelopexmlnsenv"http//www.w3.org/2001/09
    /soap-envelope"gt
  • ltenvHeadergt
  • ltnalertcontrol
  • xmlnsn"http//example.org/alertcontro
    l"gt
  • ltnprioritygt1lt/nprioritygt
  • ltnexpiresgt2001-06-22T140000-0500lt/nexp
    iresgt
  • lt/nalertcontrolgt
  • lt/envHeadergt
  • ltenvBodygt
  • ltmalert xmlnsm"http//example.org/alert"gt
  • ltmmsggtPick up Mary at school at
    2pmlt/mmsggt
  • lt/malertgt
  • lt/envBodygt
  • lt/envEnvelopegt

14
XML Messaging in SOAP
  • EDI Electronic Document Interchange
  • SOAP with EDI XML documentsDocument style
    SOAP
  • RPC distributed computing, web services
  • RPC-style SOAP parameters and return values

15
Purchase Order in Document-Style SOAP
ltsEnvelope xmlnsshttp//www.w3.org/2001/06/soa
p-envelopegt ltsHeadergt ltmtransaction
xmlnsmsoap-transaction smustUnderstand
truegt lttransactionIDgt1234lt/transactionIDgt lt
/transactiongt lt/sHeadergt ltsBodygt ltnpurchase
Order xmlnsnurnOrderServicegt ltfromgtltperson
gtChristopher Robinlt/persongt ltdeptgtAccountinglt
/deptgt lt/fromgt lttogtltpersongtPooh
Bearlt/persongt ltdeptgtHoneygtlt/deptgt lt/togt
ltordergtltquantitygt1lt/quantitygt ltitemgtPooh
Sticklt/itemgt lt/ordergt lt/npurchaseOrdergt lt/s
Bodygt lt/sEnvelopegt
16
RPC Messages
  • Typically two messages

Request Message
SOAP Client
SOAP Server
Response Message
17
An RPC-style SOAP Message
public Float getQuote (String symbol) ltsEnvelop
e xmlnsshttp//www.w3.org/2001/06/soap-envelope
gt ltsHeadergt ltmtransaction
xmlnsmsoap-transaction smustUndersta
ndtruegt lttransactionIDgt1234lt/transactionIDgt
lt/mtransactiongt lt/sHeadergt ltsBodygt ltnget
Quote xmlnsnurnQuoteServicegt ltsymbol
xsitypexsdstringgt IBM lt/symbolgt lt/n
getQuotegt lt/sBodygt lt/sEnvelopegt
18
SOAP Response
ltsEnvelope xmlnsshttp//www.w3.org/2001/06/soap
-envelopegt ltsBodygt ltngetQuoteResponse
xmnlsnurnQuoteServicegt ltvalue
xsitypexsdfloatgt 98.06 lt/valuegt lt/n
getQuoteResponsegt lt/sBodygt lt/sEnvelopegt
19
SOAP Faults
ltsEnvelope xmlnsshttp//www.w3.org/2001/06/soa
p-envelope gt ltsBodygt ltsFaultgt ltfaultcodegt
Client.Authenticationlt/faultcodegt ltfaultstringgt
Invalid credentialslt/faultstringgt ltfaultactorgth
ttp//acme.com/lt/faultactorgt ltdetailsgt lt!--
application specific detailsgtlt/detailsgt lt/sFaul
tgt lt/sBodygt lt/sEnvelopegt
20
Standard SOAP Fault Codes
  • Version Mismatch
  • MustUnderstand specify which header blocks were
    not understood
  • Server error cant be directly linked to the
    processing of the message
  • Client there is a problem in the message (e.g.
    invalid authentication credentials)

21
SOAP Data Encoding
  • One possible method of serializing data and
    encode them into XML
  • Section 5 of the SOAP standard
  • General rules

22
Compound Values
  • A compound value represents a combination of two
    or more accessors grouped as children of a single
    accessor
  • Each accessor has a different name (structs)

ltnamegt ltfirstnamegtJoelt/firstnamegt ltlastnamegtSmit
hlt/lastnamegt lt/namegt
23
Arrays
  • An array is a compound value in which the
    accessors have the same name

ltpeoplegt ltperson namejoe smith /gt ltperson
namejohn doe /gt lt/peoplegt
24
Multi-Referenced Accessor
  • ltpeoplegt
  • ltperson namejoe smithgt
  • ltaddress hrefaddress-1gt
  • lt/persongt
  • ltperson namejohn doegt
  • ltaddress hrefaddress-1gt
  • lt/persongt
  • lt/peoplegt
  • ltaddress idaddress-1gt
  • ltstreetgt111 First Streetlt/streetgt
  • ltcitygtNew Yorklt/citygt
  • ltstategtNew Yorklt/stategt
  • lt/addressgt

25
Express the Data Type of an Accessor
  • Use the xsitype attribute on each accessor,
    explicitly referencing the data type according to
    the XML Schema specification
  • ltpersongtltname xsitypexsdstringgtJohn
    Doelt/namegt
  • Reference an XML Schema document that defines the
    exact data type of a particular element within
    its definition
  • ltperson xmlnspersonschema.xsdgt
  • ltnamegtJohn Doelt/namegtlt/persongt
  • Reference some other type of schema document that
    defines the data type of a particular element
    within its definition
  • ltperson xmlnsurnsome_namespacegt
  • ltnamegtJohn Doelt/namegt

26
SOAP Data Types
  • Two alternate syntaxes for expressing instances
    of data types
  • Anonymous accessor
  • ltSOAP-ENCintgt36lt/SOAP-ENCintgt
  • Anonymous because its name is its type rather
    than a meaningful id for the value
  • Named accessor
  • ltvalue xsitypexsdintgt36lt/valuegt

27
Arrays
  • Arrays

int a3 1, 2, 3 b Add(ina)
ltmAdd xmlnsmhttp//a.com/Calculator
xmlnsSOAP-ENC "http//schemas.xmlsoap.org/soap/e
ncoding/gt lta SOAP-ENCarrayTypexsdint3gt
ltSOAP-ENCintgt1lt/SOAP-ENCintgt
ltSOAP-ENCintgt2lt/SOAP-ENCintgt
ltSOAP-ENCintgt3lt/SOAP-ENCintgt lt/agt lt/mAddgt
28
Values and References
  • By value Add(in int a, in int b)
  • By reference Square(in, out int a)

ltmAdd xmlnsmhttp//a.com/Calculatorgt lta
xsitypeintegergt3lt/agt ltb xsitypeintegergt4lt
/bgt lt/mAddgt
ltmAdd xmlnsmhttp//a.com/Calculatorgt lta
hrefarg /gt lt/mAddgt lta idarg
xsitypeintegergt8lt/agt
29
Summary
  • SOAP protocol an XML encoding scheme to exchange
    information between web processes
  • Document style XML documents
  • RPC style packing parameters in XML format
  • Typically SOAP/HTTP, others are possible
  • Low level in terms of process/service modeling
Write a Comment
User Comments (0)
About PowerShow.com