XML - Managing Data Exchange/Web Services/Exercises

Exercises
 1.Use the following WSDL file to create a SOAP request and response for getting the exchange rate between two countries. 

&lt;?xml version="1.0"?&gt; &lt;definitions name="CurrencyExchangeService" targetNamespace="http://www.xmethods.net/sd/CurrencyExchangeService.wsdl" xmlns:tns="http://www.xmethods.net/sd/CurrencyExchangeService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/"&gt; &lt;message name="getRateRequest"&gt; &lt;part name="country1" type="xsd:string"/&gt; &lt;part name="country2" type="xsd:string"/&gt; &lt;/message&gt; &lt;message name="getRateResponse"&gt; &lt;part name="Result" type="xsd:float"/&gt; &lt;/message&gt; &lt;portType name="CurrencyExchangePortType"&gt; &lt;operation name="getRate"&gt; &lt;input message="tns:getRateRequest"/&gt; &lt;output message="tns:getRateResponse"/&gt; &lt;/operation&gt; &lt;/portType&gt; &lt;binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType"&gt; &lt;soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt; &lt;operation name="getRate"&gt; &lt;soap:operation soapAction=""/&gt; &lt;input&gt; &lt;soap:body use="encoded" namespace="urn:xmethods-CurrencyExchang" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt; &lt;/input&gt; &lt;output&gt; &lt;soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt; &lt;/output&gt; &lt;/operation&gt; &lt;/binding&gt;

&lt;service name="CurrencyExchangeService"&gt; &lt;documentation&gt;Returns the exchange rate between the two currencies&lt;/documentation&gt; &lt;port name="CurrencyExchangePort" binding="tns:CurrencyExchangeBinding"&gt; &lt;soap:address location="http://services.xmethods.net:80/soap"/&gt; &lt;/port&gt; &lt;/service&gt;

&lt;/definitions&gt;



2. Use the following SOAP request and response documents to create a WSDL file with the input being a city, and the output being population of that city.

Request

 &lt;?xml version="1.0" encoding="UTF-8" standalone="no"?/&gt; &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Body&gt; &lt;m:getPopulation xmlns:m="urn:xmethods-Population"&gt; &lt;city xsi:type="xsd:string"&gt;Athens &lt;/city&gt; &lt;/m:getPopulation&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt;

 Response 

&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?/&gt; &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;SOAP-ENV:Body&gt; &lt;SOAPSDK1:getPopulationResponse xmlns:SOAPSDK1="urn:xmethods-Population"&gt; &lt;Result xsi:type="xsd:float"&gt;140,372&lt;/Result&gt; &lt;/SOAPSDK1:getPopulationResponse&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt;