SOAP Protocol in Web Services
SOAP Protocol in Web Services
1. XML-Based:
○ SOAP messages are formatted in XML, which makes them
platform-independent. This allows different systems, regardless of their
underlying technology or programming language, to communicate seamlessly.
2. Transport-Independent:
○ SOAP can be transported over a variety of protocols, such as HTTP, SMTP,
TCP, and more. However, HTTP is the most commonly used transport
protocol for SOAP in web services.
○ Since it is transport-independent, SOAP can be used in a wide variety of
network environments, including those that use email or message queues.
3. Envelope Structure:
○ SOAP messages are contained in an envelope, which defines the structure of
the message and contains important metadata about the message. The
envelope is the root element of a SOAP message and consists of two main
parts:
1. Header (optional): Contains information about the message itself, such
as security tokens, routing data, or transaction information.
2. Body: Contains the actual message or call (request/response) in XML
format.
4. Standardized Messaging:
○ SOAP defines a set of rules for sending and receiving messages between
services, including how to format requests and responses. This standardization
ensures that services can communicate without ambiguity.
5. Extensibility:
○ SOAP is highly extensible and allows for adding extra features like security,
transaction management, and reliability. These extensions are often defined in
the SOAP header.
○ WS-Security is a standard that adds security features to SOAP messages, such
as digital signatures and encryption.
6. Error Handling:
○ SOAP includes a mechanism for error handling via the Fault element. This
element is included in the body of the SOAP message when there is an error in
processing a request.
○ The Fault element provides standardized error codes and messages to help in
diagnosing and handling issues.
7. Interoperability:
○ SOAP is designed to be interoperable between different platforms. It works
well with the WSDL (Web Services Description Language), which is used to
describe the operations offered by a web service. Using SOAP and WSDL
together enables automatic generation of client and server stubs, making it
easier for developers to consume services.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<!-- Optional header information like authentication tokens -->
</soap:Header>
<soap:Body>
<GetWeather xmlns="http://www.example.com/weather">
<City>New York</City>
</GetWeather>
</soap:Body>
</soap:Envelope>
SOAP Response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<GetWeatherResponse xmlns="http://www.example.com/weather">
<Temperature>15</Temperature>
<Condition>Sunny</Condition>
</GetWeatherResponse>
</soap:Body>
</soap:Envelope>
Disadvantages of SOAP:
1. Complexity:
○ SOAP can be more complex to implement than simpler alternatives like REST
because of its reliance on XML, headers, and detailed message structures.
2. Performance Overhead:
○ SOAP messages are typically larger than REST messages because they are
XML-based and include additional metadata (e.g., headers), which increases
the size of the message and may slow down transmission over the network.
3. Tightly Coupled:
○ SOAP-based web services are often more tightly coupled with the client
because of the reliance on WSDL to define the service interface. This can lead
to difficulties in versioning an d maintaining services over time.
SOAP (Simple Object Access Protocol) Message Exchange Model defines how messages are
transmitted between a client and a server in a web service environment. It outlines the process of
sending and receiving SOAP messages using a request-response or one-way communication pattern,
which is crucial for distributed computing.
1. SOAP Nodes:
- SOAP nodes are entities that process SOAP messages. There are typically three types:
Initial Sender: The node that originates the SOAP message (usually a client).
Intermediaries: Nodes that receive the message and forward it to the next node.
Ultimate Receiver: The final node that processes the message (usually the server).
2. Message Path:
- The path that the SOAP message takes from the initial sender, through intermediaries, to the
ultimate receiver.
- The message may pass through multiple intermediaries for various processing tasks such as
logging, security checks, or transformations before reaching the final destination.
3. SOAP Messages:
The communication is done using SOAP messages, which are XML-based envelopes. These contain
a Header (optional) and a Body (mandatory), allowing information to be exchanged between nodes.
5. SOAP Intermediaries:
These are optional processing nodes that act on the SOAP headers. They can modify, add, or remove
headers for purposes like encryption, logging, or routing but do not change the body of the message.
6. Message Processing:
Each SOAP node, including intermediaries and the ultimate receiver, must process the message
according to the SOAP processing model. The ultimate receiver is responsible for interpreting the
SOAP body and acting on it, while intermediaries handle only the header information.
7. SOAP Faults:
- When a SOAP message cannot be processed correctly, a SOAP Fault is generated. This is a special
message that informs the sender of an error, specifying the cause of the failure (e.g., incorrect data,
security violation).
Client (Initial Sender): Sends a SOAP request (e.g., asking for weather data).
Server (Ultimate Receiver): Receives the request, processes it, and sends back a response with the
requested weather data.
Intermediaries (Optional): If intermediaries are involved, they might log the request or encrypt parts
of the message before it reaches the server.
Significance:
The SOAP message exchange model ensures interoperability and flexibility by defining how nodes
communicate in distributed systems. It allows services to be loosely coupled, supports message
routing, and provides fault handling mechanisms.
In conclusion, the SOAP message exchange model provides a robust, extensible framework for
exchanging information in a distributed web services environment, enabling seamless communication
between diverse systems.
SOAP messages are always synchronous. They can implement Request/Response synchronous
messages with the response having the output parameters returned in another SOAP document to the
sender.SOAP supports HTTP-POST and HTTP-GET formats. PeopleSoft supports only HTTP, using
the Integration Gateway.Processing the message requires validation of the mandatory sections of the
SOAP XML document and understanding SOAP namespaces.
A SOAP message is a well-structured XML document that consists of a SOAP envelope containing
optional headers and a body. It supports communication between various applications, regardless of
the operating system, programming language, or platform.
In this example:
In summary, SOAP messaging is a versatile and secure way of exchanging structured data across
different platforms and environments, making it a key protocol for enterprise-level web services.
XML elements in <Header> and <Body> are defined by the applications that make use of
them, although the SOAP specification imposes some constraints on their structure. The
following diagram shows the structure of a SOAP message.
A SOAP (Simple Object Access Protocol) message is a protocol for exchanging structured
information in web services, using XML. It’s designed to be platform-independent and
language-neutral, enabling communication between different systems. A SOAP message
consists of four main parts:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header> ... </soap:Header>
<soap:Body> ... </soap:Body>
<soap:Fault> ... </soap:Fault>
</soap:Envelope>
1. SOAP Envelope
○ Description: This is the root element of a SOAP message, and it defines the
XML document as a SOAP message. The Envelope element contains the
Header and Body elements.
○ Purpose: It defines the boundaries of the message and ensures that the SOAP
message is understood by the recipient.
2. SOAP Header (Optional)
○ Description: This optional element contains metadata about the SOAP
message, such as authentication, transaction control, or session data.
○ Purpose: The header can contain information that must be processed by
intermediaries along the message path before reaching the final destination.
○ Example:
<soap:Header>
<auth:Authentication xmlns:auth="http://example.com/auth">
<auth:Token>abc123</auth:Token>
</auth:Authentication>
</soap:Header>
SOAP Body
● Description: The body is the main part of the message. It contains the actual message
that is being transmitted between systems (request or response). The content inside
the body is typically application-specific information.
● Purpose: It carries the message payload (e.g., a request to a web service or the
response).
● Example:
<soap:Body>
<m:GetTemperature xmlns:m="http://www.example.org/weather">
<m:City>New York</m:City>
</m:GetTemperature>
</soap:Body>
● Description: The Fault element provides information about any error that occurs
during the processing of the message. If the message processing fails, the Fault
element is included in the Body to communicate the error details.
● Purpose: Used to report errors, such as client mistakes (incorrect parameters) or
server issues (service unavailability).
● Example:
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>Invalid City Name</faultstring>
</soap:Fault>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<auth:Authentication xmlns:auth="http://example.com/auth">
<auth:Token>abc123</auth:Token>
</auth:Authentication>
</soap:Header>
<soap:Body>
<m:GetTemperature xmlns:m="http://www.example.org/weather">
<m:City>New York</m:City>
</m:GetTemperature>
</soap:Body>
</soap:Envelope>
This SOAP message is requesting the temperature for the city of New York, with the
authentication token provided in the header. If something goes wrong, a Fault element would
be included in the response.
4. SOAP Encoding
SOAP encoding defines how data types (both simple and complex) are serialized into XML
for transmission in a SOAP message. This serialization allows the message to be understood
and reconstructed by different systems, enabling interoperability between web services.
SOAP encoding is governed by the SOAP encoding rules, specified in the SOAP
specification. It ensures that various data structures (like numbers, strings, arrays, and
objects) can be represented in a standardized XML format, so they can be exchanged between
different platforms and technologies.
1. Namespace Declaration:
○ SOAP encoding is associated with a specific namespace:
http://schemas.xmlsoap.org/soap/encoding/.
○ Example of how it's declared
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
Data Serialization:
● SOAP uses XML Schema (XSD) to describe the types and structure of data. The
xsi:type attribute defines the data type of elements in the SOAP message.
● Example (string data type with encoding)
<soap:Body>
<name xsi:type="xsd:string">John Doe</name>
</soap:Body>
Simple data types are basic, primitive types like integers, floating-point numbers, strings,
and boolean values. SOAP relies on XML Schema definitions (xsd: namespace) for defining
these data types.
Example:
<name xsi:type="xsd:string">Alice</name>
Example:
<age xsi:type="xsd:int">30</age>
Example:
<temperature xsi:type="xsd:float">98.6</temperature>
Example:
<isMarried xsi:type="xsd:boolean">false</isMarried>
Example:
<dob xsi:type="xsd:date">1990-05-15</dob>
Example of SOAP Message with Simple Data Types:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<person>
<name xsi:type="xsd:string">Alice</name>
<age xsi:type="xsd:int">30</age>
<isMarried xsi:type="xsd:boolean">false</isMarried>
</person>
</soap:Body>
</soap:Envelope>
In this example:
Compound data types are more complex structures that can contain multiple values or
fields. SOAP encoding supports two common types of compound data types:
● Arrays: Ordered collections of items, all of which are of the same data type.
● Structures: Groupings of multiple named fields, which can be of different data types.
2.1. Arrays
An array is an ordered list of elements, all of which have the same data type. SOAP
encoding represents arrays with attributes such as arrayType to specify the type and length of
the array.
<item>10</item>
<item>20</item>
<item>30</item>
</numbers>
</soap:Body>
In this example:
A struct (or complex type) is a data structure that groups multiple fields, which can each
have a different type. SOAP encoding serializes structs as XML elements, with each field
represented as an individual child element.
<soap:Body>
<person xsi:type="soap:Struct">
<age xsi:type="xsd:int">35</age>
<email xsi:type="xsd:string">john.doe@example.com</email>
</person>
</soap:Body>
In this example:
● person is a complex structure (SOAP struct).
● It has three fields: name (string), age (integer), and email (string).
Attribute
● The xsi:type attribute is used in SOAP encoding to define the specific data type of
each element.
● The types are based on XML Schema (xsd:) types for simple data, or SOAP-specific
types like Array and Struct for compound data.
● The encodingStyle attribute in the SOAP envelope indicates that SOAP encoding is
being used.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
...
</soap:Envelope>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<soap:Body>
<person xsi:type="soap:Struct">
<name xsi:type="xsd:string">Alice</name>
<age xsi:type="xsd:int">30</age>
<isMarried xsi:type="xsd:boolean">false</isMarried>
<item>7</item>
<item>11</item>
<item>42</item>
</favoriteNumbers>
</person>
</soap:Body>
</soap:Envelope>
In this example:
● The person struct contains fields like name, age, and isMarried (simple types).
● favoriteNumbers is an array of integers (compound type).
Summary:
● SOAP encoding defines how data is serialized into XML for transmission.
● Simple data types include primitive types like strings, integers, floats, and booleans,
based on XML Schema.
● Compound data types include arrays and structs, which allow for more complex data
structures to be transmitted.
5.
SOAP Communication refers to how SOAP (Simple Object Access Protocol) facilitates the
exchange of structured information between web services and client applications over a
network. SOAP communication involves sending and receiving SOAP messages, which are
XML-based, via a transport protocol like HTTP, SMTP, or TCP. SOAP enables different
applications to communicate across platforms, programming languages, and networks by
adhering to a standardized format.
Components of SOAP Communication:
1. SOAP Message:
○ The core of SOAP communication is the SOAP message. This message is an
XML-based request or response sent between a client and a web service.
○ Each SOAP message has a defined structure that includes:
■ Envelope: Defines the start and end of the message.
■ Header (optional): Contains metadata, such as security tokens, routing
information, or transaction controls.
■ Body: Contains the actual data being exchanged, such as function
parameters (in a request) or results (in a response).
■ Fault (optional): Contains error information when something goes
wrong during the processing of a message.
2. Transport Protocols:
○ SOAP is protocol-independent and can be used over various transport
protocols like:
■ HTTP/HTTPS: The most commonly used transport protocol for
SOAP communication. It allows SOAP messages to be sent over the
web.
■ SMTP: SOAP can be used with email-based transport.
■ JMS: Java Message Service can also be used for SOAP message
exchange.
■ TCP: SOAP messages can also be exchanged directly over TCP/IP.
3. Synchronous and Asynchronous Communication:
○ Synchronous Communication: In a typical HTTP-based SOAP
communication, the client sends a request to the server and waits for the
response in the same session.
○ Asynchronous Communication: With SMTP or JMS, the SOAP message is
sent, and the response may come later, allowing the client to process other
tasks while waiting for the response.
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header/>
<soap:Body>
<GetWeather xmlns="http://www.example.com/weather">
<City>New York</City>
</GetWeather>
</soap:Body>
</soap:Envelope>
<soap:Body>
<GetWeatherResponse xmlns="http://www.example.com/weather">
<City>New York</City>
<Temperature>15</Temperature>
<Condition>Sunny</Condition>
</GetWeatherResponse>
</soap:Body>
</soap:Envelope>
4. Client Receives and Interprets the Response:
○ The client receives the SOAP response and extracts the necessary data from
the message (e.g., "Temperature" and "Condition").
○ The client can then display the data or perform further processing.
1. SOAP Envelope:
○ The root element of every SOAP message, defining the boundaries of the
message.
Example:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
Example:
<soap:Header>
<Security>
</Security>
</soap:Header>
3. SOAP Body:
○ The body contains the actual payload (data), which could be a request or a
response, depending on the context.
Example:
<soap:Body>
<GetWeather>
<City>New York</City>
</GetWeather>
</soap:Body>
Example:
<soap:Body>
<soap:Fault>
<faultcode>Client</faultcode>
</soap:Fault>
</soap:Body>
Host: www.example.com
Content-Length: length
<soap:Envelope>
</soap:Envelope>
HTTP Response:
HTTP/1.1 200 OK
Content-Length: length
<soap:Envelope>
</soap:Envelope>
1. Complexity:
○ SOAP messages are more complex and verbose compared to simpler
alternatives like REST, due to the use of XML and additional metadata
(headers, envelopes).
2. Performance Overhead:
○ The use of XML, along with the SOAP envelope and headers, results in larger
messages and thus more bandwidth usage compared to other protocols like
REST.
Conclusion:
SOAP communication is a reliable and structured way for applications to communicate over
a network, offering features like security, extensibility, and cross-platform compatibility. It is
widely used in enterprise environments where reliability, security, and well-defined service
contracts are crucial. While it may be more complex and heavy compared to alternatives like
REST, it is ideal for applications that require formal communication with built-in standards
for handling security, transactions, and message reliability.
The SOAP (Simple Object Access Protocol) Processing Model defines how messages are
processed as they travel between the originator, intermediaries, and final recipient. This
protocol is widely used for exchanging structured information in web services.
1. SOAP Nodes:
○ Originator: The node that sends the SOAP message.
○ Intermediary: Any node that processes the message and forwards it to the
next node.
○ Recipient: The final destination that processes the message body.
2. Message Flow: SOAP messages consist of a Header and a Body. Headers contain
metadata, while the body holds the message payload (data). The message flows
through several nodes, each having specific roles based on the header entries.
3. SOAP Headers and Actor Attribute:
○ Headers: SOAP headers can be used by nodes to process specific instructions.
Headers are used to pass additional information and control how the message
is processed.
Actor Attribute: Each header can include an actor attribute that specifies which node is
responsible for processing it. For example:
<env:Header>
<x:action soap:actor="http://example.com/intermediary"/>
</env:Header>
This attribute is critical for ensuring that mandatory headers are processed. If a node
encounters a mustUnderstand attribute on a header that it cannot process, it must reject the
message and generate a fault.
For example:
<x:SomeHeader soap:mustUnderstand="1"/>
○ This tells the node it must process this header or report an error.
6. Routing and Intermediary Role: SOAP allows messages to be routed through
multiple intermediaries. Each intermediary can process parts of the message (usually
headers) and then forward the message. This hop-by-hop processing makes SOAP
highly flexible and allows for distributed systems where different nodes perform
specialized tasks.
7. Caching: SOAP intermediaries can enhance message processing by caching
responses to frequent requests. This feature reduces redundant processing and
improves performance. For instance, if a special cache server is set as an actor in the
message header, it can cache the response for future requests.
Example of SOAP Message Flow
[Originator] ---> [Intermediary Node 1] ---> [Intermediary Node 2] ---> [Final Recipient]
Each intermediary node processes the headers meant for it, adds new headers if needed, and
forwards the message. The final recipient processes the body of the message.
In web services, bindings define how operations of a web service are transmitted between the
client and the service. They specify the protocol used and the format of the data. Here’s a
breakdown of the types of bindings you've mentioned:
1. SOAP Bindings
Example in WSDL:
<soap:binding transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="MyOperation">
<soap:operation soapAction="urn:MyAction"/>
<input>
<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="urn:MyService" use="encoded"/>
</input>
</operation>
</binding>
2. HTTP Bindings
● HTTP bindings specify that the web service messages are transmitted using the
HTTP protocol.
● The HTTP binding is simpler than the SOAP binding because it uses HTTP's standard
methods like GET and POST to transmit data, often in XML format.
● HTTP bindings are commonly used for lightweight web services where the overhead
of SOAP is not needed.
Example in WSDL:
<http:binding verb="POST"/>
<operation name="MyOperation">
<http:operation location="/MyOperation"/>
<input>
<http:body use="literal"/>
</input>
</operation>
</binding>
3. SMTP-POP Bindings
● SMTP (Simple Mail Transfer Protocol) and POP (Post Office Protocol) are
protocols typically used for sending and receiving email.
● While these are not typical web service bindings in the same sense as SOAP or HTTP,
they can be used in specific applications, such as email-based web services or systems
that interact with mail servers.
● SMTP is used to send messages, and POP is used to retrieve them.
For example, a binding might define how to send or retrieve email messages through these
protocols.
● SMTP is often used for sending email (e.g., through a service like Gmail or Outlook).
● POP is used for retrieving email from a server to a local client.
These protocols can be specified in a web service context where the service sends email
notifications or retrieves data from email messages.
<operation name="SendEmail">
<smtp:operation action="send"/>
<input>
<smtp:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
</operation>
</binding>
Each of these bindings provides different methods of transporting data between a web service
and its clients, depending on the needs of the application. SOAP bindings offer a more robust
and standardized message format, while HTTP bindings are lightweight and commonly used
for RESTful services, and SMTP/POP bindings are more relevant to email-based services.
SOAP security in the context of XML and web services is a crucial concern, as SOAP
messages are often exchanged over the internet and can carry sensitive information. Ensuring
the confidentiality, integrity, and authenticity of SOAP messages is essential. Below is an
overview of various SOAP security mechanisms and standards:
SOAP relies heavily on XML for message format, so XML security mechanisms are often
employed to secure SOAP messages:
a. XML Encryption
● XML Encryption ensures that parts of the SOAP message are encrypted to maintain
confidentiality. It allows selective encryption of elements within the XML document,
which can protect sensitive data (e.g., credit card details, passwords).
● Encrypted data is wrapped in <EncryptedData> tags.
Example:
<soap:Envelope>
<soap:Header>...</soap:Header>
<soap:Body>
<EncryptedData>
</EncryptedData>
</soap:Body>
</soap:Envelope>
b. XML Signature
● XML Signature ensures the integrity and authenticity of the SOAP message. It allows
you to digitally sign the entire message or specific parts, preventing tampering during
transmission.
● A signature is wrapped in a <Signature> element, and typically, a public key is used
for verification.
Example:
xml
Copy code
<soap:Envelope>
<soap:Header>...</soap:Header>
<soap:Body>
<Signature>
</Signature>
<SignedInfo>
</SignedInfo>
</soap:Body>
</soap:Envelope>
● XKMS simplifies the integration of public key infrastructure (PKI) into XML-based
applications. It allows SOAP-based web services to handle public keys and encryption
without dealing with complex certificate management.
WS-Security is a standard that enhances SOAP messaging with security features. It defines
how to secure SOAP messages through various mechanisms such as authentication,
encryption, and digital signatures.
<soap:Envelope>
<soap:Header>
<wsse:Security>
<wsse:UsernameToken>
<wsse:Username>user123</wsse:Username>
<wsse:Password>password</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</soap:Header>
<soap:Body>
</soap:Body>
</soap:Envelope>
b. Timestamp
● WS-Security can also use a timestamp to ensure that the message is processed within
a specific time window. This prevents replay attacks (where a malicious party resends
an old message to impersonate a valid request).
Example:
<wsu:Timestamp>
<wsu:Created>2024-11-08T12:34:56Z</wsu:Created>
<wsu:Expires>2024-11-08T12:44:56Z</wsu:Expires>
</wsu:Timestamp>
3. Transport-Level Security
Transport-level security protects the entire SOAP message during transmission over the
network. The most common method is HTTPS, which is HTTP over SSL/TLS (Secure
Sockets Layer / Transport Layer Security). This method provides:
While transport-level security secures the communication channel, it does not provide
end-to-end security (i.e., the message is only secure between the client and the service, not
across intermediaries). That’s why message-level security (such as WS-Security) is often
used to secure SOAP messages beyond a single hop.
Example:
<wsp:Policy>
<sp:SignedSupportingTokens>
<wsp:Policy>
<sp:UsernameToken/>
</wsp:Policy>
</sp:SignedSupportingTokens>
<sp:TransportBinding>
<wsp:Policy>
<sp:TransportToken>
<wsp:Policy>
<sp:HttpsToken/>
</wsp:Policy>
</sp:TransportToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:Basic256/>
</wsp:Policy>
</sp:AlgorithmSuite>
</wsp:Policy>
</sp:TransportBinding>
</wsp:Policy>
SAML is commonly used for single sign-on (SSO) in SOAP-based services. It allows secure,
token-based authentication across different domains. A SAML assertion can be used within a
SOAP message to provide authentication and authorization information.
Summary
WSDL
WSDL Documents
An WSDL document describes a web service. It specifies the location of the service, and the
methods of the service, using these major elements:
Element Description
<types> Defines the (XML Schema) data types used by the web service
<portType> Describes the operations that can be performed and the messages
involved.
<binding> Defines the protocol and data format for each port type
<definitions>
<types>
</types>
<message>
</message>
<portType>
set of operations......
</portType>
<binding>
</binding>
</definitions>
WSDL Example
This is a simplified fraction of a WSDL document:
<message name="getTermRequest">
<part name="term" type="xs:string"/>
</message>
<message name="getTermResponse">
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
In this example the <portType> element defines "glossaryTerms" as the name of a port, and
"getTerm" as the name of an operation.
The "getTerm" operation has an input message called "getTermRequest" and an output message
called "getTermResponse".
The <message> elements define the parts of each message and the associated data types.
The <portType> Element
The <portType> element defines a web service, the operations that can be performed, and the
messages that are involved.
The request-response type is the most common operation type, but WSDL defines four types:
Type Definition
One-way The operation can receive a message but will not return a
response
Request-response The operation can receive a request and will return a response
Solicit-response The operation can send a request and will wait for a response
Notification The operation can send a message but will not wait for a
response
<message name="newTermValues">
</message>
<portType name="glossaryTerms">
<operation name="setTerm">
</operation>
</portType >
In the example above, the portType "glossaryTerms" defines a one-way operation called
"setTerm".
The "setTerm" operation allows input of new glossary terms messages using a "newTermValues"
message with the input parameters "term" and "value". However, no output is defined for the
operation.
<message name="getTermRequest">
</message>
<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
In the example above, the portType "glossaryTerms" defines a request-response operation called
"getTerm".
The "getTerm" operation requires an input message called "getTermRequest" with a parameter
called "term", and will return an output message called "getTermResponse" with a parameter
called "value".
<message name="getTermRequest">
<message name="getTermResponse">
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation>
<soap:operation soapAction="http://example.com/getTerm"/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output>
</operation>
</binding>
The name attribute (you can use any name you want) defines the name of the binding, and the
type attribute points to the port for the binding, in this case the "glossaryTerms" port.
The style attribute can be "rpc" or "document". In this case we use document. The transport
attribute defines the SOAP protocol to use. In this case we use HTTP.
The operation element defines each operation that the portType exposes.
For each operation the corresponding SOAP action has to be defined. You must also specify how
the input and output are encoded. In this case we use "literal".
This element is the root of the WSDL document. It defines the name of the service
(StockQuote) and sets the namespace (targetNamespace). It also declares XML namespaces
for WSDL (xmlns) and XML Schema (xmlns:xsd).
This defines the getQuoteRequest message, which includes one part named ticker of type
xsd:string. This message is used to request a stock quote for a particular stock ticker.
This defines the getQuoteResponse message, which includes one part named result of type
xsd:float. This message represents the response that includes the stock quote as a
floating-point number.
The portType element defines a set of operations provided by the service. Here, there's one
operation called getQuote which allows the client to request a stock quote. The
parameterOrder attribute indicates that the ticker parameter is the input for the operation. The
operation has:
•An input message, tns:getQuoteRequest, which corresponds to the request message defined
earlier.
•An output message, tns:getQuoteResponse, which corresponds to the response message
defined earlier.