【问题标题】:WS02: Invoking external weather SOAP webservice from ESBWS02:从 ESB 调用外部天气 SOAP Web 服务
【发布时间】:2017-11-17 16:35:10
【问题描述】:

我正在尝试使用 WSO2 ESB(版本 4.8.1)来调用外部托管的 SOAP Web 服务。为了尝试它,我使用公共网络服务获取天气信息 (http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL),更具体地说,是 GetWeatherInformation 操作。

我已经使用soapUI工具成功使用了网络服务。

我是 SOAP 和 ESB 的新手,所以我尝试关注一些博客条目,但我不断收到错误消息。我尝试使用代理服务、有效负载工厂和发送,但仍然无法管理。有人可以帮我设置一下吗?

谢谢

【问题讨论】:

  • 我们需要了解您遇到的错误以便帮助您:您能否向我们展示堆栈跟踪和您的代理配置副本(WSO2 ESB 中的代理服务)?
  • 我实际上设法使用了代理,但必须按如下方式发布 WSDL:ws.apache.org/ns/synapse" name="testws3" transports="http" statistics="disable" trace="disable" startOnLoad="true">
    wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL">
  • 我可以通过 API 而不是代理做类似的事情吗?

标签: web-services soap wsdl wso2 wso2esb


【解决方案1】:

这里有一个示例 API 来调用 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>

您只需向http://esb.hostname:8280/testws3api/GetWeatherInformation 发送一个 GET http 请求(使用 SoapUI 或在您的 Internet 浏览器中输入此地址),您就会从 Weather WS 返回 XML 响应

【讨论】:

    【解决方案2】:

    它适用于部署在 WSO2 ESB v4.8.1 中的这个代理配置:

    <?xml version="1.0" encoding="UTF-8"?>
    <proxy xmlns="http://ws.apache.org/ns/synapse"
           name="testws3"
           transports="https http"
           startOnLoad="true"
           trace="disable">
       <target>
          <endpoint>
             <wsdl service="Weather"
                   port="WeatherSoap12"
                   uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
          </endpoint>
          <outSequence>
             <send/>
          </outSequence>
       </target>
       <publishWSDL uri="http://wsf.cdyne.com/WeatherWS/Weather.asmx?WSDL"/>
    </proxy>
    

    【讨论】:

    • 我想通过 API 专门调用 GetWeatherInformation 操作,但我没有管理。我该怎么做?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-31
    • 2010-09-19
    相关资源
    最近更新 更多