我有一个简单的 RESTful 服务,我想使用 WSO2 ESB 将其公开为基于 SOAP 的 Web 服务。
我的简单 RESTful 服务可以像http://<<my system>>:8080/myapp/person/read
响应一样被调用,我获取JSON
Person 实体的数据。
问题:我无法将参数传递给 RESTful 服务。我要从 SOAP 输入中去除参数值,但不知道如何将它传递给我的 RESTful;使用 ESB 的服务。
我在WSO2 ESB中配置了以下内容
<proxy xmlns="http://ws.apache.org/ns/synapse" name="PersonProxy" transports="https,http" statistics="enable" trace="enable" startOnLoad="true">
<target>
<inSequence>
<property xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" name="PERSON_ID" expression="//soapenv:Body/person/id"/>
<log level="full">
<property name="PERSON_ID" expression="get-property('PERSON_ID')"/>
</log>
<filter xpath="//person">
<then>
<property name="REST_URL_POSTFIX" value="read" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING"/>
<property name="id" expression="get-property('PERSON_ID')" scope="axis2" type="STRING"/>
<property name="ContentType" value="application/x-www-form-urlencoded" scope="axis2" type="STRING"/>
</then>
<else/>
</filter>
<send>
<endpoint>
<address uri="http://<<my system>>:8080/myapp/person" format="rest"/>
</endpoint>
</send>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description></description>
</proxy>
我的 SOAP 请求如下所示
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<person>
<id>3</id>
</person>
</soapenv:Body>
</soapenv:Envelope>
我有另一个 RESTful 服务,其GET
方法和 id 作为 URL 本身的一部分,并且工作正常。ESB 配置看起来像
<property name="REST_URL_POSTFIX" expression="get-property('PERSON_ID')" scope="axis2" type="STRING"/>
<property name="HTTP_METHOD" value="GET" scope="axis2" type="STRING"/>
<endpoint>
<address uri="http://<<my system>>:8080/cfs/person" format="rest"/>
</endpoint>
感谢任何指示或帮助。