Search code examples
web-servicessoapwsdlwso2wso2-esb

WS02: Invoking external weather SOAP webservice from ESB


I am trying to use WSO2 ESB (version 4.8.1) to invoke externally hosted SOAP web services. To try it out I was using a public web service for weather information (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL), more specifically the GetWeatherInformation operation.

I have successfully consumed the web service using the soapUI tool.

I am a newcomer to SOAP and ESB, so I tried to follow a number of blog entries, but I keep on getting errors. I tried using proxy service, payload factory and send but still didn't manage. Can somebody please help me with setting this up?

Thanks


Solution

  • Here come a sample API to invoke GetWeatherInformation :

    <?xml version="1.0" encoding="UTF-8"?>
    <api xmlns="http://ws.apache.org/ns/synapse"
         name="testws3api"
         context="/testws3api">
       <resource methods="GET" url-mapping="/GetWeatherInformation">
          <inSequence>
             <payloadFactory media-type="xml">
                <format>
                   <GetWeatherInformation xmlns="http://ws.cdyne.com/WeatherWS/"/>
                </format>
                <args/>
             </payloadFactory>
             <send>
                <endpoint>
                   <address uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx" format="soap11"/>
                </endpoint>
             </send>
          </inSequence>
          <outSequence>
             <send/>
          </outSequence>
       </resource>
    </api>
    

    You just have to send a GET http request to http://esb.hostname:8280/testws3api/GetWeatherInformation (use SoapUI or type this address in your internet browser) and you will get back the XML response from the Weather WS