Вы находитесь на странице: 1из 13

Simple Object Access Protocol

• SOAP is an XML-based messaging and remote procedure


call (RPC) specification that enables the exchange of
information among distributed systems
• SOAP has achieved its level of widespread acceptance
for several reasons:
• open specification, available for anyone to use
• simple to write and is “human-readable.”
• extensible, taking advantage of the power of XML to
enable loose coupling between remote systems
• flexible protocol that is useful both in request/response
and message passing/queuing architectures
Introduction to SOAP
• SOAP is a standard way of serializing the information
needed to invoke services located on remote systems
• the information can be sent over a network to the
remote system, in a format the remote system can
understand, regardless of what platform the remote
service runs on or what language it’s written in
• SOAP resembles the wire protocols underlying both
architectures:
– the Internet Inter-ORB Protocol (IIOP) that underlies
CORBA
– Microsoft’s Distributed Component Object Model (DCOM)
protocol
Introduction to SOAP
• With message passing, a message sender can
send a message at any time, and the
messaging infrastructure is responsible for
delivering the message - asynchronous
message delivery
• With the request/response model, the
message sender typically must wait until it
receives a response from the recipient –
synchronous message delivery
Introduction to SOAP
• Object RPC (ORPC) protocols such as CORBA’s
IIOP and DCOM became dominant in the
distributed computing arena
• CORBA/IIOP and DCOM have several problems
– CORBA and DCOM are single-vendor solutions
– CORBA and DCOM have different, proprietary
characteristics - CORBA’s payload parameter value
format is the Common Data Representation (CDR),
whereas DCOM’s is the incompatible Network Data
Representation (NDR)
– CORBA uses Interoperable Object References (IORs)
for endpoint naming, whereas DCOM uses OBJREFs
Introduction to SOAP
• SOAP addresses drawbacks to existing ORPC
architectures:
• SOAP is built with open technologies and is an open
specification - SOAP is a vendor-neutral protocol
• SOAP uses XML as its payload parameter value format
and uses URIs
• SOAP interfaces are described with the Web Services
Description Language WSDL
• SOAP is based on XML, it is a text-based protocol -
simpler than CORBA and DCOM
• SOAP messages are human-readable and firewall -
SOAP is a loosely coupled protocol
Key Building Block for Web Services
• SOAP provides three key capabilities:
– SOAP is a messaging framework, consisting of an
outer Envelope element that contains an optional
Header element and a mandatory Body element
– SOAP is an encoding format that describes how
objects are encoded, serialized, and then decoded
when received.
– SOAP is an RPC mechanism that enables objects to
call methods of remote objects
SOAP Message Structure and
Namespaces
• simple example of a message -to send a request
to the server for a person’s phone number
• client sends an XML-formatted request to the
server
– <?xml version=”1.0”?>
– <PhoneNumber>
– <getPhoneNumber>
– <name>John Doe</name>
– </getPhoneNumber>
– </PhoneNumber>
SOAP Message Structure and
Namespaces
• use client to create an HTTP request, and put the
preceding XML in the body of an HTTP POST
• a response from the server will be of the form :
– <?xml version=”1.0”?>
– <PhoneNumber>
– <getPhoneNumberResponse>
– <thenumber>
– <areacode>617</areacode>
– <numberbody>555-1234</numberbody>
– </thenumber>
– </getPhoneNumberResponse>
– </PhoneNumber>
SOAP Message Structure and
Namespaces
• The root node retains the name of the interface, but
the method name has the word “Response” appended
to it, so the client can identify the correct response by
appending “Response” to the calling method name
• limitation is that the vocabulary that the client and
server use to exchange messages must be agreed
• If there is a new method or a new parameter, both the
client and the server must reprogram their interfaces.
• In a complex message, there could be a confusion if
two methods have parameters with the same name
• To resolve these limitations with such simple message
formats, SOAP takes advantage of XML namespaces
SOAP Message Structure and
Namespaces
• the same request message recast in SOAP:
• <SOAP-ENV:Envelope xmlns: SOAP-ENV=
“http://schemas.xmlsoap.org/soap/envelope/”
• xmlns:xsi=”http://www.w3.org/1999/XMLSchema-instance”
• xmlns:xsd=”http://www.w3.org/1999/XMLSchema”
• SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
• <SOAP-ENV:Header>
• </SOAP-ENV:Header>
• <SOAP-ENV:Body>
– <ns:getPhoneNumber xmlns:ns=“PhoneNumber”>
– <name xsi:type=“xsd:string”>John Doe</name>
– </ns:getPhoneNumber>
• </SOAP-ENV:Body>
• </SOAP-ENV:Envelope>
SOAP Message Structure and
Namespaces
• root node is Envelope - has an optional
Header section and a mandatory Body section
• SOAP Envelope is then enclosed in the outer
transport envelope, which might be HTTP,
SMTP
• SOAP messages are structured like this
SOAP Message Structure and
Namespaces
• There are two forms of namespace declarations:
– default declarations and explicit declarations
• Explicit declarations are of the form:
– xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/
• The default declarations : xmlns=”SomeURI”
• Explicit declarations begin with the xmlns keyword, followed by a
colon and a shorthand designation for the namespace.
• The SOAP-ENV namespace includes the <Envelope>,<Header>, and
<Body> structural elements
• the encodingStyle attribute-
http://schemas.xmlsoap.org/soap/envelope/ - is the standard URL
for the SOAP-ENV namespace
• explicit declaration is used for a publicly available namespace-
default declarations are appropriate for custom namespaces
SOAP Message Structure and
Namespaces
• server’s response message:
• <SOAP-ENV:Envelope xmlns:SOAP-
ENV=”http://schemas.xmlsoap.org/soap/envelope/”
• xmlns:xsi=”http://www.w3.org/1999/XMLSchema-instance”
• xmlns:xsd=”http://www.w3.org/1999/XMLSchema”
• SOAP-ENV:encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”>
• <SOAP-ENV:Body>
– <getPhoneNumberResponse xmlns=”SomeURI”>
– <areacode>617</areacode>
– <numberbody>555-1234</numberbody>
– </getPhoneNumberResponse>
• </SOAP-ENV:Body>
• </SOAP-ENV:Envelope>
• The response message shows an example of a namespace with a default
declaration <getPhoneNumberResponse xmlns=”SomeURI”>

Вам также может понравиться