SOAP & WSDLSOAP & WSDL
Aug’10 – Dec ’10
Introduction SOAP - Simple Object Access protocolSOAP - Simple Object Access protocol
Protocol specification for exchanging structured information in the Protocol specification for exchanging structured information in the implementation of web services in computer networksimplementation of web services in computer networks
WSDL – Web Services Description LanguageWSDL – Web Services Description Language
Provides a way of describing where and how to make requests to a Provides a way of describing where and how to make requests to a SOAP-based serviceSOAP-based service
Chapter includesChapter includes
❑ Why SOAP can provide more flexibility than previous RPC protocols
❑ How to format SOAP messages
❑ When to use GET versus POST in an HTTP request
❑ What SOAP intermediaries are
❑ How to describe a service using WSDL
Aug’10 – Dec ’10
What is SOAP?What is SOAP?
A lightweight protocol for exchange of information in a decentralized, distributed environment.
It is a standard way to send information from one computer to another using XML to represent the information.
The SOAP recommendation defines a protocol whereby all information sent from computer to computer is marked up in XML, with the information transmitted via HTTP in most cases.
Aug’10 – Dec ’10
Advantages of SOAP over other protocolsAdvantages of SOAP over other protocols
It’s platform-, language-, and vendor-neutral—Because SOAP is implemented using XML and (usually) HTTP, it is easy to process and send SOAP requests in any language, on any platform
It’s easy to implement—SOAP was designed to be less complex than the other protocols. A SOAP server can be implemented using nothing more than a web server and an ASP page or a CGI script.
❑ It’s firewall-safe—Assuming that you use HTTP as your network protocol, you can pass SOAP messages across a firewall without having to perform extensive configuration.
Aug’10 – Dec ’10
Creating an RPC server in ASP
❑ ❑ To create an RPC server that receives a request and sends To create an RPC server that receives a request and sends back a responseback a response
❑ ❑ Create an ASP.NET page that accepts two integers and Create an ASP.NET page that accepts two integers and returns the results in XMLreturns the results in XML
Values sent : unit price, quantityValues sent : unit price, quantity
Values Receives : Discount, Total priceValues Receives : Discount, Total price
❑ ❑ Not a full fledged SOAP service, but has similar architectureNot a full fledged SOAP service, but has similar architecture
Aug’10 – Dec ’10
Creating an RPC server in ASP
http://localhost:1698/BasicOrderService/GetTotal.aspx?unitprice=8.5&quantity=6
Aug’10 – Dec ’10
Creating an RPC server in ASP
http://localhost:1698/BasicOrderService/GetTotal.aspx?unitprice=8.5&quantity=x
Aug’10 – Dec ’10
Creating an RPC server in ASP
ASP.NET page isn’t limited to being called from a browser
Can load the XML directly and then retrieve the numbers from it
Sub Main()Dim xdDoc As System.Xml.XmlDocument = new System.Xml.XmlDocument()xdDoc.Load(“http://localhost/BasicOrderService/gettotal.aspx?unitprice=8.5&quantity=6”)If xdDoc.documentElement.name = “Error” ThenMsgBox (“Unable to perform calculation”)ElseMsgBox(xdDoc.selectSingleNode(“/*/TotalPrice”).InnerText)End IfEnd Sub
Aug’10 – Dec ’10
Why not REST?Why not REST?
Sends a URL and receives an XMLSends a URL and receives an XML
Even though the result is XML, it doesn’t conform to the structure Even though the result is XML, it doesn’t conform to the structure of a SOAP messageof a SOAP message
Also while sending message is not sent as XML, but as URL Also while sending message is not sent as XML, but as URL
But in some cases, request data is difficult or impossible to provide But in some cases, request data is difficult or impossible to provide as URLas URL
In such cases, SOAP is better to use, more standardizedIn such cases, SOAP is better to use, more standardized
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
SOAP messages are basically XML documents, usually sent across SOAP messages are basically XML documents, usually sent across HTTP.HTTP. SOAP specifies the following:SOAP specifies the following:
❑ ❑ Rules regarding how the message should be sentRules regarding how the message should be sent
❑ ❑ The overall structure of the XML that is sent. This is called The overall structure of the XML that is sent. This is called the envelope. Any information to be sent over SOAP is the envelope. Any information to be sent over SOAP is
contained within this envelope, and is known as the payload. contained within this envelope, and is known as the payload.
❑ ❑ Rules regarding how data is represented in this XML. These Rules regarding how data is represented in this XML. These are called the encoding rules.are called the encoding rules.
Aug’10 – Dec ’10
SOAP Component
HTTP Headers
SOAP method name
SOAP Envelope
SOAP Header
SOAP Body
Call element
Object Endpoint IDMethod/Interface ID
Extension Headers
Parameter Data
Basic SOAP MessagesBasic SOAP Messages When data is sent to a SOAP server, the data must be represented in When data is sent to a SOAP server, the data must be represented in a way so that the server can understand it. The basic structure of a way so that the server can understand it. The basic structure of SOAP message is as follows:SOAP message is as follows:
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”><soap:Header><head-ns:someHeaderElem xmlns:head-ns=”some URI”env:mustUnderstand=”true{{vert}false”env:relay=”true{{vert}false”env:role=”some URI”/></soap:Header><soap:Body encodingStyle=”http://www.w3.org/2003/05/soap-encoding”><some-ns:someElem xmlns:some-ns=”some URI”/><!-- OR --><soap:Fault><soap:Code><soap:Value>Specified values</soap:Value><soap:Subcode><soap:Value>Specified values</soap:Value></soap:Subcode></soap:Code>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<soap:Reason><soap:Text xml:lang=”en-US”>English text</soap:Text><v:Text xml:lang=”fr”>Texte francais</soap:Text></soap:Reason><soap:Detail><!-- Application specific information --></soap:Detail></soap:Fault></soap:Body></soap:Envelope>
Three Main Elements : <Envelope>, <Header>, <Body>Three Main Elements : <Envelope>, <Header>, <Body>
<Envelope> and <Body> are mandatory, <Header> optional<Envelope> and <Body> are mandatory, <Header> optional
<Fault> and its child elements are only required when an error occurs<Fault> and its child elements are only required when an error occurs
All of the attributes, encodingStyle, mustUnderstand etc are optionalAll of the attributes, encodingStyle, mustUnderstand etc are optional
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Envelope><Envelope>
Provides the root element for the XML documentProvides the root element for the XML document
<Envelope> namespace : www.w3.org/2003/05/soapenvelope<Envelope> namespace : www.w3.org/2003/05/soapenvelope
Includes namespace declarationsIncludes namespace declarations
<?xml version="1.0"?> <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"> envelope"> <soap:Header> <soap:Header> </soap:Header> </soap:Header> <soap:Body> <soap:Body> <m:GetStockPrice xmlns:m="http://www.example.org/stock"> <m:GetStockPrice xmlns:m="http://www.example.org/stock"> <m:StockName>IBM</m:StockName><m:StockName>IBM</m:StockName> </m:GetStockPrice> </m:GetStockPrice> </soap:Body> </soap:Body>
</soap:Envelope></soap:Envelope>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Body><Body>
Contains the main body of the SOAP messageContains the main body of the SOAP message
Actual RPC calls are made using the direct children of the <Body> Actual RPC calls are made using the direct children of the <Body> elementelement
<soap:Envelope xmlns:env=”http://www.w3.org/2003/05/soap-envelope”><soap:Body><o:AddToCart xmlns:o=”http://www.wiley.com/soap/ordersystem”><o:CartId>THX1138</o:CartId><o:Item>ZIBKA</o:Item><o:Quantity>3</o:Quantity><o:TotalPrice>34.97</o:TotalPrice></o:AddToCart></soap:Body></soap:Envelope>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Body><Body>
RPC call to a procedure AddToCart in the RPC call to a procedure AddToCart in the http://www.wiley.com/soap/ordersystem namespace namespace
Can add multiple calls in a single namespaceCan add multiple calls in a single namespace
The AddToCart procedure takes four parameters: CartId, Item, The AddToCart procedure takes four parameters: CartId, Item, Quantity, and TotalPrice. Quantity, and TotalPrice.
Direct child elements of the <soap:Body> element must reside in a Direct child elements of the <soap:Body> element must reside in a namespace other than the SOAP namespace. namespace other than the SOAP namespace.
This namespace is what the SOAP server uses to uniquely identify this This namespace is what the SOAP server uses to uniquely identify this procedure so that it knows what code to run.procedure so that it knows what code to run.
When the procedure is done running, the server uses the HTTP When the procedure is done running, the server uses the HTTP response to send back a SOAP message.response to send back a SOAP message.
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Body><Body>
The response is another SOAP message, using an XML structure The response is another SOAP message, using an XML structure similar to the requestsimilar to the request
<soap:Envelope xmlns:soap=’http://www.w3.org/2003/05/soap-envelope’><soap:Body><o:AddToCartResponse xmlns:o=’http://www.wiley.com/soap/ordersystem’><o:CartId>THX1138</o:CartId><o:Status>OK</o:Status><o:Quantity>3</o:Quantity><o:ItemId>ZIBKA</o:ItemId></so:AddToCartResponse></soap:Body></soap:Envelope>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Body><Body>
Encoding StyleEncoding Style
Refers to the way in which data is representedRefers to the way in which data is represented
Eg: SOAP style encoding, RDF (Resource Description Framework)Eg: SOAP style encoding, RDF (Resource Description Framework)
<soap:Envelope xmlns:soap=’http://www.w3.org/2003/05/soap-envelope’><soap:Body soap:encodingStyle=”http://www.w3.org/2003/05/soap-encoding”><o:AddToCartResponse xmlns:o=’http://www.wiley.com/soap/ordersystem’><o:CartId>THX1138</o:CartId><o:Status>OK</o:Status><o:Quantity>3</o:Quantity><o:ItemId>ZIBKA</o:ItemId></o:AddToCartResponse></soap:Body></soap:Envelope>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Header><Header>
Included when additional information is to be added to the SOAP Included when additional information is to be added to the SOAP messagemessage
Contains information about the payloadContains information about the payload
Header blocks are specifically designed for meta informationHeader blocks are specifically designed for meta information
When a <Header> element is used, it must be the first child of the When a <Header> element is used, it must be the first child of the <Envelope> element<Envelope> element
Also defines optional attributes, mustUnderstand, role and relayAlso defines optional attributes, mustUnderstand, role and relay
Eg: Can use a SOAP header for authentication information, so that Eg: Can use a SOAP header for authentication information, so that only authorized person or systems can use the systemonly authorized person or systems can use the system
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages<Header><Header>
The mustUnderstand attributeThe mustUnderstand attribute
Specifies if it is necessary for the SOAP server to process a particular Specifies if it is necessary for the SOAP server to process a particular header blockheader block
A value of true indicates that the header entry is mandatory and the A value of true indicates that the header entry is mandatory and the server must either process it or indicate an errorserver must either process it or indicate an error
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”><soap:Header xmlns:some-ns =”http://www.wiley.com/soap/headers/”> <some-ns:authentication mustUnderstand=”true”> <UserID>User ID goes here...</UserID> <Password>Password goes here...</Password> </some-ns:authentication> <some-ns:log mustUnderstand=”false”> <additional-info>Info goes here...</additional-info> </some-ns:log> <some-ns:log> <additional-info>Info goes here...</additional-info> </some-ns:log></soap:Header>
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages<Header><Header>
The mustUnderstand attributeThe mustUnderstand attribute
<soap:Body xmlns:body-ns=”http://www.wiley.com/soap/rpc”><body-ns:mainRPC>
<additional-info/></body-ns:mainRPC>
</soap:Body></soap:Envelope>
A value of true in <authentication> header means the server should A value of true in <authentication> header means the server should process the headerprocess the header
If the server doesn’t understand the header, it rejects the entire If the server doesn’t understand the header, it rejects the entire SOAP message; server is not allowed to process the bodySOAP message; server is not allowed to process the body
A value of false for mustUnderstand attribute makes the header A value of false for mustUnderstand attribute makes the header entry optionalentry optional
Even if the server doesn’t understand the header, it can process the Even if the server doesn’t understand the header, it can process the bodybody
If the mustUnderstand attribute is omitted, it takes the value false, If the mustUnderstand attribute is omitted, it takes the value false, and header entry is optionaland header entry is optional
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Header><Header>
The role attributeThe role attribute
In some cases a SOAP message may pass through a number of In some cases a SOAP message may pass through a number of applications on a number of computers before it arrives at its final applications on a number of computers before it arrives at its final destinationdestination
These are called intermediariesThese are called intermediaries
Using the role attribute, it can be specified that some SOAP headers Using the role attribute, it can be specified that some SOAP headers must be processed by a specific intermediary. The value of the must be processed by a specific intermediary. The value of the attribute is a URI, which uniquely identifies each intermediary.attribute is a URI, which uniquely identifies each intermediary.
When an intermediary processes a header entry, it must remove that When an intermediary processes a header entry, it must remove that header from the message before passing it on. header from the message before passing it on.
The SOAP specification also says that a similar header entry can be The SOAP specification also says that a similar header entry can be inserted in its placeinserted in its place
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Header><Header>
The role attributeThe role attribute
The SOAP specification defines three roles:The SOAP specification defines three roles:
❑ ❑ http://www.w3.org/2003/05/soap-envelope/role/next applies to the http://www.w3.org/2003/05/soap-envelope/role/next applies to the next intermediary in line, wherever it is.next intermediary in line, wherever it is.
❑ ❑ http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver only applies to the very last stop.only applies to the very last stop.
❑ ❑ http://www.w3.org/2003/05/soap-envelope/role/none effectively http://www.w3.org/2003/05/soap-envelope/role/none effectively “turns off” the header block“turns off” the header block
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Header><Header>
The relay attributeThe relay attribute
The SOAP specification requires a SOAP intermediary to remove any The SOAP specification requires a SOAP intermediary to remove any headers it doesn’t processheaders it doesn’t process
By setting the relay attribute to true, you can instruct any By setting the relay attribute to true, you can instruct any intermediary that encounters it to either process it or leave it alone.intermediary that encounters it to either process it or leave it alone.
If the intermediary does process the header, the intermediary must If the intermediary does process the header, the intermediary must remove it.remove it.
The default value for the relay attribute is false.The default value for the relay attribute is false.
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages
<Fault><Fault>
There may be times when a SOAP server is unable to process a There may be times when a SOAP server is unable to process a SOAP message, for some reasons. SOAP message, for some reasons.
Sometimes a resource needed to perform the operation isn’t Sometimes a resource needed to perform the operation isn’t available, or invalid parameters were passed, or the server doesn’t available, or invalid parameters were passed, or the server doesn’t understand the SOAP request in the first place. understand the SOAP request in the first place.
In these cases, the server returns In these cases, the server returns fault codes fault codes to the client to to the client to indicate errors.indicate errors.
Fault codes are sent using the same format as other SOAP Fault codes are sent using the same format as other SOAP messages. However, in this case, the <Body> element has only one messages. However, in this case, the <Body> element has only one child, a <Fault> element. child, a <Fault> element.
Children of the <Fault> element contain details of the error.Children of the <Fault> element contain details of the error.
Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages<Fault><Fault>
A SOAP message indicating a fault might look like this :A SOAP message indicating a fault might look like this :
<soap:Envelope xmlns:soap=”http://www.w3.org/2003/05/soap-envelope”xmlns:rpc=”http://www.w3.org/2003/05/soap-rpc”><soap:Body> <soap:Fault>
<soap:Code><soap:Value>soap:Sender</soap:Value><soap:Subcode>
<soap:Value>rpc:BadArguments</soap:Value></soap:Subcode>
</soap:Code><soap:Reason>
<soap:Text xml:lang=”en-US”>Processing error</soap:Text><soap:Text xml:lang=”fr”>Erreur de traitement </soap:Text>
</soap:Reason><soap:Detail>
<o:orderFaultInfo xmlns:o=”http://www.wiley.com/soap/ordersystem”><o:errorCode>WA872</o:errorCode><o:message>Cart doesn’t exist</o:message></o:OrderFaultInfo>
</soap:Detail> </soap:Fault></soap:Body></soap:Envelope> Aug’10 – Dec ’10
Basic SOAP MessagesBasic SOAP Messages<Fault><Fault>
The <Code> element contains a <Value> consisting of a unique identifier The <Code> element contains a <Value> consisting of a unique identifier that identifies the type of errorthat identifies the type of error
Fault CodeFault Code DescriptionDescription
VersionMismatchVersionMismatch A SOAP message was received that A SOAP message was received that specified a version of the SOAP protocol specified a version of the SOAP protocol that this server that this server doesn’t doesn’t
understand.understand.
MustUnderstandMustUnderstand The SOAP message contained a mandatory The SOAP message contained a mandatory header that the SOAP server didn't header that the SOAP server didn't understandunderstand
SenderSender Message was not properly formatted, the Message was not properly formatted, the client made a mistake when creating the client made a mistake when creating the SOAP message, or the message contained SOAP message, or the message contained incorrect informationincorrect information
ReceiverReceiver Indicates server had problems processing Indicates server had problems processing the message even though the contents of the message even though the contents of the message was formatted properlythe message was formatted properly
DataEncodingUnknownDataEncodingUnknown Indicates data in the message is organized, Indicates data in the message is organized, or encoded in a way the server doesn’t or encoded in a way the server doesn’t understandunderstand Aug’10 – Dec ’10
Defining Web ServicesDefining Web Services
To use a web service, two things are to be knownTo use a web service, two things are to be known
How to call the serviceHow to call the service
What to expect as a response from the serviceWhat to expect as a response from the service
WSDL or Web Service Description Language provides a standardized WSDL or Web Service Description Language provides a standardized way to describe a web serviceway to describe a web service
If a WSDL file describing the web service is created and the file is If a WSDL file describing the web service is created and the file is made available, the web service can be used easilymade available, the web service can be used easily
Most toolkits used for creating SOAP messages, can automatically Most toolkits used for creating SOAP messages, can automatically generate a client for the web service by analyzing the WSDL file generate a client for the web service by analyzing the WSDL file
In this way, WSDL helps make web services truly platform- and In this way, WSDL helps make web services truly platform- and language-independentlanguage-independent
Aug’10 – Dec ’10
WSDL
WSDL was developed by IBM,Microsoft and Ariba to describe web WSDL was developed by IBM,Microsoft and Ariba to describe web services for SOAP toolkitservices for SOAP toolkit
WSDL document outlines what messages the SOAP server expects in WSDL document outlines what messages the SOAP server expects in order to provide services as well as what messages it returnsorder to provide services as well as what messages it returns
A client program connecting to a web service can read the WSDL file A client program connecting to a web service can read the WSDL file to determine what operations are available on the server.to determine what operations are available on the server.
The client can then use SOAP to actually call one of the operations The client can then use SOAP to actually call one of the operations listed in the WSDL filelisted in the WSDL file
Aug’10 – Dec ’10
WSDL
A WSDL file is written in XML, describing the data to be passed andthe method for passing it, but it doesn’t lean toward any particular language.
That means a web services client generator can use the WSDL information to generate a client in any language.
A developer writing an application around it doesn’t have to know the details of the service, just the methods of the proxy class that actually accesses the service.
The proxy sits between the client and the actual service, translating messages back and forth.
Aug’10 – Dec ’10
WSDLWSDL
<definitions><definitions>
A WSDL file starts with a <definitions> elementA WSDL file starts with a <definitions> element
<?xml version=”1.0”?><definitions name=”temperature”targetNamespace=”http://www.example.com/temperature”xmlns:typens=”http://www.example.com/temperature”xmlns:xsd=”http://www.w3.org/2000/10/XMLSchema”xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/”xmlns=”http://schemas.xmlsoap.org/wsdl/”></definitions>
Defines the name of the web serviceDefines the name of the web service
Root element in WSDL file Root element in WSDL file
A WSDL file builds the service up in levels. First, it defines the data A WSDL file builds the service up in levels. First, it defines the data to be sent and received, and then it uses that data to define to be sent and received, and then it uses that data to define messages.messages.
Aug’10 – Dec ’10
WSDLWSDL<types><types>
A WSDL allows to define the information set using XML SchemasA WSDL allows to define the information set using XML Schemas
Eg: Web service that takes postal code and date and returns Eg: Web service that takes postal code and date and returns temperature; the service would have two types of data to deal withtemperature; the service would have two types of data to deal with
<types><xsd:schema xmlns=””xmlns:xsd=”http://www.w3.org/2000/10/XMLSchema”targetNamespace=”http://www.example.com/temperature”><xsd:complexType name=”temperatureRequestType”><xsd:sequence><xsd:element name=”where” type=”xsd:string” /><xsd:element name=”when” type=”xsd:date”/></xsd:sequence></xsd:complexType><xsd:complexType name=”temperatureResponseType”><xsd:sequence><xsd:element name=”temperature” type=”xsd:integer”/></xsd:sequence></xsd:complexType></xsd:schema></types>
Aug’10 – Dec ’10
WSDLWSDL<messages><messages>
Defines the content of the SOAP messageDefines the content of the SOAP message
Defines what the message is, what it is called, and what kind of data Defines what the message is, what it is called, and what kind of data it holdsit holds
<message name=”TemperatureRequestMsg”> <part name=”getTemperature” type=”typens:temperatureRequestType”/></message><message name=”TemperatureResponseMsg”> <part name=”temperatureResponse” type=”typens:temperatureResponseType”/></message>
Message that consists of an element called getTemperature of the Message that consists of an element called getTemperature of the type temperatureRequestType. This translates into the SOAP message:type temperatureRequestType. This translates into the SOAP message:
<env:Envelope xmlns:env=”http://www.w3.org/2003/05/soap-envelope”><env:Body><getTemperature><where>{{it{POSTAL} CODE}</where><when>{{it{DATE}}</when></getTemperature></env:Body></env:Envelope>
Aug’10 – Dec ’10
WSDLWSDL<portTypes><portTypes>
Contains a number of portType elements that describe the individual Contains a number of portType elements that describe the individual operation provided by the service. operation provided by the service.
These operations come in two varieties, input and output, and are made These operations come in two varieties, input and output, and are made up of the messages defined earlierup of the messages defined earlier
<portType name=”TemperatureServicePortType”> <operation name=”GetTemperature”>
<input message=”typens:TemperatureRequestMsg”/><output message=”typens:TemperatureResponseMsg”/>
</operation></portType>
portType shows it is a request-response patternportType shows it is a request-response pattern
The user sends an input message, the structure of which is defined as a The user sends an input message, the structure of which is defined as a TemperatureRequestMsg, and the service returns an output message in TemperatureRequestMsg, and the service returns an output message in the form of a TemperatureResponseMsg.the form of a TemperatureResponseMsg.
In WSDL 2.0, <portTypes> element is changes to <interfaces> elementIn WSDL 2.0, <portTypes> element is changes to <interfaces> element
Interfaces can be extended, which allows inheritanceInterfaces can be extended, which allows inheritance
Aug’10 – Dec ’10
WSDLWSDL<binding><binding>
To bind the operations to the protocol used to send the messagesTo bind the operations to the protocol used to send the messages
Process of binding operations to SOAP is as follows :Process of binding operations to SOAP is as follows :
<binding name=”TemperatureBinding” type=”typens:TemperatureServicePortType”>
<soap:binding style=”rpc” transport=”http://schemas.xmlsoap.org/soap/http”/>
<operation name=”GetTemperature”> <soap:operation /> <input> <soap:body use=”encoded” encodingStyle=”http://www.w3.org/2003/05/soap-encoding” namespace=”http://www.example.com/temperature” /> </input> <output> <soap:body use=”encoded” encodingStyle=”http://www.w3.org/2003/05/soap-encoding” namespace=”http://www.example.com/temperature” /> </output></operation>
</binding>
Aug’10 – Dec ’10
WSDLWSDL<binding><binding>
<soap:binding><soap:binding>
Specifies it is a SOAP messageSpecifies it is a SOAP message
transport attribute specifies message is sent via HTTPtransport attribute specifies message is sent via HTTP
style attribute has two possible values : rpc and documentstyle attribute has two possible values : rpc and document
The rpc value is a message with method name and parametersThe rpc value is a message with method name and parameters
<env:Envelope xmlns:env=”http://www.w3.org/2003/05/soap-envelope”><env:Body><getTemperature><where>34652</where><when>2004-05-23</when></getTemperature></env:Body></env:Envelope>
Aug’10 – Dec ’10
WSDLWSDL<binding><binding>
<soap:binding><soap:binding>
When document style is used, the entire contents of <env:Body> When document style is used, the entire contents of <env:Body> element is considered to be dataelement is considered to be data
<env:Envelope xmlns:env=”http://www.w3.org/2003/05/soap-envelope”><env:Body><where>34652</where><when>2004-05-23</when></env:Body></env:Envelope>
Aug’10 – Dec ’10
WSDLWSDL<binding><binding>
<soap:operation><soap:operation>
The SOAP 1.1 specification required all services to use a SOAPAction header defining the application that was supposed to execute it.
POST /soap.asp HTTP/1.1Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*Accept-Language: en-usContent-Type: application/x-www-form-urlencodedAccept-Encoding: gzip, deflateUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)Host: www.example.comContent-Length: 242SOAPAction: “http://www.example.org/soap/TemperatureService.asp”<env:Envelope xmlns:env=”http://www.w3.org/2003/05/soap-envelope”><env:Body><getTemperature><where>34652</where><when>2004-05-23</when></getTemperature></env:Body></env:Envelope>
The SOAP 1.2 specification did away with SOAPAction header, but it is necessary to specify that it is a SOAP message, so <soap:operation> element is used Aug’10 – Dec ’10
WSDLWSDL
<binding><binding>
<soap:body><soap:body>
The <binding> element references an operation
Within the <binding> element, how messages are to be presented is defined using the <soap:body> element
<soap:body use=”encoded” encodingStyle=”http://www.w3.org/2003/05/soap-encoding” namespace=”http://www.example.com/temperature” />
The use attribute has two possible values : literal and encoded
When use is literal, it means the server is not to assume any particular meaning in the XML
If use is specified as encoded, encodingStyle has to be specified
namespace attribute to specify the namespace of the payload
Aug’10 – Dec ’10
WSDLWSDL
<service><service>
The final step in creating a WSDL file is to specify the service created
<service name=”TemperatureService”><port name=”TemperaturePort” binding=”typens:TemperatureBinding”><soap:address location=”http://www.example.com/temp/getTemp.asp”/></port></service>
binding attribute to refer to the binding created
location attribute in soap:address to specify the address to send the SOAP message
Aug’10 – Dec ’10
Top Related