Web Services: SOAP - PowerPoint PPT Presentation

About This Presentation
Title:

Web Services: SOAP

Description:

Title: PowerPoint Presentation Last modified by: AlinaD Created Date: 1/1/1601 12:00:00 AM Document presentation format: On-screen Show Other titles – PowerPoint PPT presentation

Number of Views:54
Avg rating:3.0/5.0
Slides: 34
Provided by: ltnLv
Category:
Tags: soap | java | services | servlet | web

less

Transcript and Presenter's Notes

Title: Web Services: SOAP


1
Web Services SOAP
2
SOAP
  • SOAP ir standarts Web servisu sazinošanas
    protokols
  • Originali SOAP nozimeja
  • Simple Object Access Protocol
  • velak ari
  • Service Oriented Architecture Protocol
  • bet sakot ar versiju 1.2 tas ir vienkarši SOAP

3
Vesture un versijas
  • SOAP 1998. gada izstradaja Dave Winer, Don Box,
    Bob Atkinson un Mohsen Al-Ghosein
  • SOAP 1.1 W3C ierosinajums 2000.gada maija
  • J2EE 1.4 standarts
  • SOAP 1.2 W3C rekomendacija sakot ar
    2003.gada juniju
  • Java EE 5 standarts

4
Kas ir SOAP?
  • SOAP is a communication protocol
  • SOAP is for communication between applications
  • SOAP is a format for sending messages
  • SOAP is designed to communicate via Internet
  • SOAP is platform independent
  • SOAP is language independent
  • SOAP is based on XML
  • SOAP is simple and extensible
  • SOAP allows you to get around firewalls
  • SOAP is developed as a W3C standard

5
Kas SOAP nav?
  • SOAP nav komponentu modelis
  • Tas neaizvietos objektus un komponentus, piemeram
    EJB, JavaBeans
  • SOAP nav programmešanas valoda
  • Tas neaizvietos Java valodu
  • SOAP nav risinajums visiem uzdevumiem
  • Tas neaizvietos citas dalitas apstrades
    tehnologijas, tadas ka, piemeram, RMI

6
Kapec SOAP?
  • Izstradajot lietojumprogrammas ir svarigi dot
    iespeju programmam sazinaties pa Internetu
  • Viens sazinašanas veids ir RPC (Remote Procedure
    Call), bet HTTP nav isti piemerots šim variantam
  • SOAP bija izveidots, lai nodrošinat iespeju
    sazinaties pa HTTP (kaut gan var tikt izmantots
    ari cits protokols, piemeram SMTP)

7
SOAP over HTTP, SMTP, and Raw TCP/IP
A SOAP XML document instance, which is called a
SOAP message, is usually carried as the payload
of some other network protocol
8
One-Way versus Request/Response
  • Web services can use
  • One-Way messaging or
  • Request/Response messaging

9
Ko SOAP define?
  • Message Envelope
  • Encoding Rules
  • RPC Convention
  • Binding with underlying protocols

10
SOAP Message
  • SOAP message is made of
  • SOAP Envelope (in XML)
  • Zero or more attachments
  • Zero or more "underlying protocol" header fields
  • SOAP Envelope is composed of
  • SOAP body
  • Main content of the message
  • Zero or more SOAP header blocks
  • Metadata
  • Data aimed at intermediaries
  • Can also contain application data for ultimate
    receiver

11
SOAP Message Format
12
SOAP in HTTP Request
Sender
Receiver
13
SOAP Message Structure
  • A SOAP message is analogous to an envelope used
    in traditional postal service
  • A SOAP message is a kind of XML document
  • SOAP has its own XML schema, namespaces, and
    processing rules

lt?xml version"1.0" encoding"UTF-8"?gt ltsoapEnvel
ope xmlnssoap"http//schemas.xmlsoap.org/soap/en
velope/"gt ltsoapHeadergt lt!-- Header blocks
go here --gt lt/soapHeadergt ltsoapBodygt
lt!-- Application data goes here --gt
lt/soapBodygt lt/soapEnvelopegt
14
SOAP Message Structure
  • A SOAP message may have a single Body element
    preceded, optionally, by one Header element
  • The Envelope element cannot contain any other
    children!
  • The Header element contains information about the
    message
  • security credentials
  • transaction IDs
  • routing instructions
  • debugging information
  • payment tokens

15
Example SOAP Header
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltsoapEnvelope
  • xmlnssoap"http//schemas.xmlsoap.org/soap/env
    elope/"
  • xmlnsmi"http//www.Monson-Haefel.com/message-
    id"gt
  • ltsoapHeadergt
  • ltmimessage-idgt
  • 11d1def534eab1c5faf3bfb4dcd7-8000
  • lt/mimessage-idgt
  • lt/soapHeadergt
  • ltsoapBodygt
  • lt!-- Application-specific data goes here --gt
    lt/soapBodygt
  • lt/soapEnvelopegt

16
SOAP Namespaces
  • XML namespaces play an important role in SOAP
    messages
  • Examples of namespace prefixes

Prefix Namespace
soap "http//schemas.xmlsoap.org/soap/envelope/"
xsi "http//www.w3.org/2001/XMLSchema-instance"
xsd "http//www.w3.org/2001/XMLSchema"
soapenc "http//schemas.xmlsoap.org/soap/encoding/"
wsdl "http//schemas.xmlsoap.org/wsdl/"
soapbind "http//schemas.xmlsoap.org/wsdl/soap/"
wsi "http//ws-i.org/schemas/conformanceClaim/"
17
Example SOAP Namespaces
  • lt?xml version"1.0" encoding"UTF-8"?gt
  • ltsoapEnvelope
  • xmlnssoap"http//schemas.xmlsoap.org/soap/envel
    ope/"
  • xmlnssec"http//schemas.xmlsoap.org/soap/securi
    ty/2000-12"
  • xmlnsds"http//www.w3.org/2000/09/xmldsig"
  • xmlnsmi"http//www.Monson-Haefel.com/jwsbook/me
    ssage-id"gt
  • ltsoapHeadergt
  • ltmimessage-idgt11d1def534eab1c5faf3bfb4dcd7
    -8000lt/mimessage-idgt
  • ltsecSignaturegt ... lt/secSignaturegt
  • lt/soapHeadergt
  • ltsoapBody secid"Body"gt
  • ltpopurchaseOrder orderDate"2003-09-22"
  • xmlnspo"http//www.Monson-Haefel.com/jwsboo
    k/PO"
  • xmlnsxsi"http//www.w3.org/2001/XMLSchema-i
    nstance"gt
  • ...
  • lt/popurchaseOrdergt
  • lt/soapBodygt
  • lt/soapEnvelopegt

18
SOAP Message Path
  • Initial sender creates message
  • Ultimate receiver executes main operation
  • Intermediaries perform additional processing

19
SOAP Nodes
  • The applications along the message path are also
    called SOAP nodes
  • Example
  • security node authenticates users and verifies
    message integrity
  • SOAP message Header blocks are intended to be
    processed in general by intermediary nodes

20
Roles and Targeting
  • Header blocks are targeted to node via "role"
    attribute (URI)
  • Role is either address of a node or role name
  • E.g. this security intermediary (address)
  • E.g. any security intermediary (role name)
  • Example
  • ltnsmyHeaderBlock role"/logging" /gt
  • The Body is always targeted to ultimate receiver

21
Roles and Targeting
  • SOAP defines three special roles
  • none
  • next
  • ultimateReceiver
  • The "mustUnderstand" attribute
  • If set to true, the node must know how to
    process the header
  • If a node doesn't understand a mandatory header
    block, it must generate a SOAP fault

22
Example Headers with Roles
lt?xml version'1.0' ?gt ltenvEnvelope
xmlnsenv"http//www.w3.org/2003/05/soap-envelope
"gt ltenvHeadergt ltmreservation
xmlnsm"" envrole "http//www.w3.org/200
3/05/soap-envelope/role/next" envmustUnderstand
"true"gt ltmreferencegtuuid093a2da1-q345-73
9r-ba5d-pqff98fe8j7d lt/mreferencegt
ltmdateAndTimegt2001-11-29T132000.000-0500lt/mda
teAndTimegt lt/mreservationgt
ltnpassenger xmlnsn" envrole" http//ww
w.w3.org/2003/05/soap-envelope/role/next"
envmustUnderstand"true"gt ltnnamegtÅke Jógvan
Øyvindlt/nnamegt lt/npassengergt
lt/envHeadergt
23
Intermediary Node Algorithm
  • Receive message
  • Determine roles played
  • Verify all mandatory blocks targeted to node are
    understood
  • Process appropriate header blocks
  • Processing possibly produces a fault
  • Remove processed headers
  • Add new headers if necessary
  • Forward message to next node

24
Ultimate Receiver Algorithm
  • Receive message
  • Process appropriate header blocks
  • Processing possibly produces a fault
  • Process all body blocks
  • Processing possibly produces a fault

25
SOAP Messaging Modes
  • SOAP supports four modes of messaging
  • RPC/Literal
  • Document/Literal
  • RPC/Encoded
  • Document/Encoded
  • However, RPC/Encoded and Document/Encoded modes
    are explicitly prohibited

26
Document/Literal Mode
  • In the Document/Literal mode of messaging, a SOAP
    Body element contains an XML document fragment
  • A well-formed XML element that contains arbitrary
    application data (text and other elements) that
    belongs to some XML schema and namespace

27
Example Document/Literal Body
  • ltsoapBodygt
  • ltpopurchaseOrder orderDate"2003-09-22"
  • xmlnspohttp//www.Monson-Haefel.com/jwsbook/P
    O"gt
  • ltpoaccountNamegtAmazon.comlt/poaccountNamegt
  • ltpoaccountNumbergt923lt/poaccountNumbergt
  • ...
  • ltpobookgt
  • ltpotitlegtJ2EE Web Serviceslt/potitlegt
  • ltpoquantitygt300lt/poquantitygt
  • ltpowholesale-pricegt24.99lt/powholesale-pri
    cegt
  • lt/pobookgt
  • lt/popurchaseOrdergt
  • lt/soapBodygt

28
RPC/Literal Mode
  • The RPC/Literal mode of messaging enables SOAP
    messages to model calls to procedures or method
    calls with parameters and return values
  • The contents of the Body are always formatted as
    a struct
  • In many cases is used to expose traditional
    components (servlet, EJB, RMI) as Web services

29
Example RPC/Literal
  • public interface BookQuote extends
    java.rmi.Remote
  • public float getBookPrice(String ISBN)
  • throws RemoteException, InvalidISBNException

ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/" xmlnsmh"http//www.Monson-H
aefel.com/jwsbook/BookQuote"gt ltsoapBodygt
ltmhgetBookPricegtltisbngt0321146182lt/isbngtlt/mhgetB
ookPricegt lt/soapBodygt lt/soapEnvelopegt
ltsoapEnvelope xmlnssoap"http//schemas.xmlsoap.
org/soap/envelope/" xmlnsmh"http//www.Monson-H
aefel.com/jwsbook/BookQuote" gt ltsoapBodygt
ltmhgetBookPriceResponsegtltresultgt24.99lt/resultgt
lt/mhgetBookPriceResponsegt
lt/soapBodygt lt/soapEnvelopegt
30
SOAP Faults
  • SOAP fault messages are the mechanism by which
    SOAP applications report errors to nodes earlier
    in the message path
  • SOAP faults are returned to the receiver's
    immediate sender only
  • Fault element information items
  • faultcode
  • Client, Server, VersionMismatch, MustUnderstand
  • faultstring
  • faultactor
  • detail

31
Example SOAP Fault
  • ltsoapFaultgt
  • ltfaultcodegtsoapClientlt/faultcodegt
  • ltfaultstringgt
  • The ISBN value contains invalid characters
  • lt/faultstringgt
  • ltfaultactorgthttp//www.xyzcorp.comlt/faultactorgt
  • ltdetailgt
  • ltmhInvalidIsbnFaultDetailgt
  • ltoffending-valuegt19318224-Dlt/offending-value
    gt
  • ltconformance-rulesgt
  • The first nine characters must be
    digits. The last
  • character may be a digit or the letter
    'X'. Case is
  • not important.
  • lt/conformance-rulesgt
  • lt/mhInvalidIsbnFaultDetailgt
  • lt/detailgt
  • lt/soapFaultgt

32
SOAP over HTTP
  • SOAP messages sent over HTTP are placed in the
    payload of an HTTP request or response

POST /jwsbook/BookQuote HTTP/1.1 Host
www.Monson-Haefel.com Content-Type text/xml
charset"utf-8" Content-Length
295 SOAPAction"" lt?xml version"1.0"
encoding"UTF-8"?gt ltsoapEnvelope
xmlnssoap"http//schemas.xmlsoap.org/soap/envelo
pe/" xmlnsmh"http//www.Monson-Haefel.com/jwsbo
ok/BookQuote"gt ltsoapBodygt
ltmhgetBookPricegt ltisbngt0321146182lt/isbn
gt lt/mhgetBookPricegt lt/soapBodygt lt/soap
Envelopegt
33
References
  • SOAP Tutorial (W3C Schools) http//www.w3schools.c
    om/soap/default.asp
  • SOAP-1.2 Primer http//www.w3.org/TR/soap12-p
    art0/
  • SOAP Version 1.2 W3C Specification
    http//www.w3.org/TR/soap12-part1/
  • Book J2EE Web Services by Richard
    Monson-Haefel
  • http//www.amazon.ca/J2EE-Web-Services-Richard-Mo
    nson-Haefel/dp/0321146182
Write a Comment
User Comments (0)
About PowerShow.com