• It's a wire protocol.
• It's an RPC mechanism.
• It's an interoperability standard.
• It's a document exchange protocol.
• It's a universal business-to-business communications language.
• SimpleObject Access Protocol – //www.w3c.org/TR/SOAP/
• A lightweight protocol for exchange of information in a decentralized, distributed environment.
• Two different styles to use: – to encapsulate RPC calls using the extensibility and flexibility
of XML. – to deliver a whole document without any method calls encapsulated
XML messaging using SOAP
SOAP specification
• The SOAP specification describes four major components: Formatting conventions for encapsulating data. Ex: SOAP envelope, header, body etc., Routing directions in the form of an envelope, a transport or protocol binding, Ex: SOAP sender , receiver etc., Encoding rules An RPC mechanism
• The envelope defines a convention for describing the contents of a message, which in turn has implications on how it gets processed.
• A protocol binding provides a generic mechanism for sending a SOAP envelope via a lower level protocol such as HTTP.
• Encoding rules provide a convention for mapping various application data types into an XML tag-based representation.
• Finally, the RPC mechanism provides a way to represent remote procedure calls and their return values.
SOAP Message Structure
Block structure of a SOAP envelope
SOAP Request Envelope:
<soapenv:Envelope xmlns:soapenv="//schemas.xmlsoap.org/soap/envelope/" xmlns:q0="//emp" xmlns:xsd="//www.w3.org/2001/XMLSchema" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<q0:getName>
<q0:sName>Vinod Kumar</q0:sName>
</q0:getName>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response Envelope:
<soapenv:Envelope xmlns:soapenv="//schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="//www.w3.org/2001/XMLSchema" xmlns:xsi="//www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<getNameResponse xmlns="//emp">
<getNameReturn>Welcome Vinod Kumar</getNameReturn>
</getNameResponse>
</soapenv:Body>
</soapenv:Envelope>
SOAP Structure
• A SOAP message is contained in an envelop.
• The envelop element in turn contain (in order)
– An optional header with one or more child entries.
– A body element that can contain one or more child entries.
These child entries may contain arbitrary XML data.
Adding Header
<SOAP-ENV:Header>
<jaws:MessageHeader xmlns:jaws="urn:training-samples">
<From>Me</From>
<To>You</To>
<MessageId>9999</MessageId>
</jaws:MessageHeader>
</SOAP-ENV:Header>
SOAP Headers
• Headers are really just extension points where you can include elements from other namespaces.
– i.e., headers can contain arbitrary XML.
• Header entries may optionally have a “mustUnderstand” attribute.
– mustUnderstand=1 means the message recipient must process the header element.
– If mustUnderstand=0 or is missing, the header element is optional.
SOAP Body
Body entries are really just placeholders for arbitrary XML from some other namespace.
• The body contains the XML message that you are transmitting.
• The message format is not specified by SOAP.
– The <Body></Body> tag contains actual XML message.
– The recipient decides what to do with the message.
e.g:-
<soapenv:Body>
<getNameResponse xmlns="//emp">
<getNameReturn>Welcome Vinod Kumar</getNameReturn>
</getNameResponse>
</soapenv:Body>
SOAP RPC Example
A simple example
– Calls with a string public String hello(String name)
– Returns a greeting “Hi!” + name
No comments:
Post a Comment