XML - Managing Data Exchange/Web Services/Exercises

Exercises

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

  <?xml version="1.0"?>
  <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/">
 
         <message name="getRateRequest">
            <part name="country1" type="xsd:string"/>
	    <part name="country2" type="xsd:string"/>	
         </message>
         <message name="getRateResponse">
            <part name="Result" type="xsd:float"/>
         </message>
 
         <portType name="CurrencyExchangePortType">
            <operation name="getRate">
               <input message="tns:getRateRequest"/>
               <output message="tns:getRateResponse"/>
            </operation>
         </portType>
 
         <binding name="CurrencyExchangeBinding" type="tns:CurrencyExchangePortType">
            <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
            <operation name="getRate">
               <soap:operation soapAction=""/>
               <input>
                  <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchang" 
                      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </input>
               <output>
                  <soap:body use="encoded" namespace="urn:xmethods-CurrencyExchange" 
                      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
               </output>
            </operation>
         </binding>

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

</definitions>

    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

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

    Response

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