使用带有WSO2 ESB的SOAP代理RESTful服务

Din*_*ett 5 rest wso2 wso2esb

我们想用SOAP代理RESTful Web服务.

REST服务使用GET方法并通过查询参数接受输入.它生成application/csv类型的资源.

WSO2 ESB/Synapse是否支持这种情况,是否有可用的示例?

示例请求

SOAP代理请求:

<request>
  <fromDate>2012-01-01</fromDate>
  <toDate>2012-12-31</toDate>
</request>
Run Code Online (Sandbox Code Playgroud)

REST端点请求:

http://localhost/person?fromDate=2012-01-01&toDate=2012-12-31
Run Code Online (Sandbox Code Playgroud)

示例响应

REST端点响应

"Name","Age","Sex"
"Geoff","22","Male"
Run Code Online (Sandbox Code Playgroud)

SOAP代理响应

<person>
  <name>Geoff</name>
  <age>22</age>
  <sex>Male</sex>
<person>
Run Code Online (Sandbox Code Playgroud)

非常感谢.

Rav*_*viU 5

如果我理解正确,您希望将REST服务公开为SOAP服务,以便SOAP客户端可以通过ESB访问您的REST服务?

如果是这种情况,那么可能:)你应该看看这些样本152:http://docs.wso2.org/wiki/display/ESB451/Proxy+Service+Samples

它将解释如何获取SOAP请求并将其传递给REST后端,然后将REST响应转换为SOAP响应.

编辑:这是一个示例配置,如何在评论中做你所要求的,希望它会让你开始:)

<proxy xmlns="http://ws.apache.org/ns/synapse" name="RESTProxy" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
   <target>
      <inSequence>

         <!-- We set the HTTP Method we want to use to make the REST request here -->
         <property name="HTTP_METHOD" value="GET" scope="axis2"/>

         <!-- This is where the magic happens, for what you want i.e. mapping SOAP "params" to REST query param's --> 
         <property name="messageType" value="application/x-www-form-urlencoded" scope="axis2"/>

         <send>
            <endpoint>
               <!-- This is the RESTful URL we are going to query, like the one in the ESB example 152 -->
               <address uri="http://localhost/person" />
            </endpoint>
         </send>

      </inSequence>

      <outSequence>
         <log level="full"/>
         <property name="messageType" value="text/xml" scope="axis2"/>
         <send/>
      </outSequence>
   </target>
   <description></description>
</proxy>
Run Code Online (Sandbox Code Playgroud)

然后,您对ESB的SOAP请求应该是这样的:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
    <person>
        <fromDate>2012-01-01</fromDate>
        <toDate>2012-12-31</toDate>
    </person>
   </soapenv:Body>
</soapenv:Envelope>
Run Code Online (Sandbox Code Playgroud)

希望有帮助:)