我想在ESB上公开一个API(REST),它将请求转换为SOAP服务。
我的Api以这种方式确定:
<api xmlns="http://ws.apache.org/ns/synapse" name="__test" context="/mytest">
<resource methods="GET" uri-template="/{symbol}">
<inSequence>
<property name="symbol" expression="get-property('uri.var.symbol')"/>
<payloadFactory media-type="xml">
<format>
<ser:getQuote xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
<ser:request>
<xsd:symbol>$1</xsd:symbol>
</ser:request>
</ser:getQuote>
</format>
<args>
<arg evaluator="xml" expression="get-property('symbol')"/>
</args>
</payloadFactory>
<log level="full"/>
<send>
<endpoint>
<wsdl service="SimpleStockQuoteService" port="SimpleStockQuoteServiceHttpEndpoint"
uri="http://localhost:9000/services/SimpleStockQuoteService?wsdl"/>
</endpoint>
</send>
</inSequence>
</resource>
</api>
但是当我用http://:8280 / mytest / WSO2调用网址时,我在控制台上发现了这个错误
<soapenv:Reason xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Text xml:lang="en-US">
The endpoint reference (EPR) for the Operation not found is /services/SimpleStockQuoteService.SimpleStockQuoteServiceHttpEndpoint/WSO2?request= and the WSA Action = null. If this EPR was previously reachable, please contact the server administrator.
</soapenv:Text>
</soapenv:Reason>
因为esb会将请求的 WSO2 部分附加到网址。
我怎么解决这个问题? 感谢
答案 0 :(得分:1)
您可以按照this指南来实现此目的。请注意,soap操作标头应添加如下,端点不同。
<header name="Action" value="urn:getQuote"/>
找到下面的完整解决方案API,
<api xmlns="http://ws.apache.org/ns/synapse" name="__test" context="/mytest"><resource methods="GET" uri-template="/{symbol}">
<inSequence>
<property name="symbol" expression="get-property('uri.var.symbol')"/>
<payloadFactory media-type="xml">
<format>
<ser:getQuote xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">
<ser:request>
<xsd:symbol>$1</xsd:symbol>
</ser:request>
</ser:getQuote>
</format>
<args>
<arg evaluator="xml" expression="get-property('symbol')"/>
</args>
</payloadFactory>
<property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
<log level="full"/>
<header name="Action" value="urn:getQuote"/>
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
</endpoint>
</send>
</inSequence></resource></api>
如果您想直接使用WSDL网址,可以使用WSO2 API Manager实现此目标,并且可以在WSO2 API Cloud中轻松尝试。还有一个类似的问题here。