0

我在 wso2-am 2.0.0 中创建了一个 RESTful API。但我面临一个问题,并且会有所帮助。我有一个带有 GET http 方法的资源,它接收一个 url 参数,我制作了一个 SOAP 有效负载以通过 POST 发送到后端(后端是soap11)。

为此,我使用了一个自定义的“in”序列:

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="JSONtoSOAP" trace="disable"
    xmlns="http://ws.apache.org/ns/synapse">
    <log description="Entrada" level="full" separator=",">
    <property expression="get-property('uri.var.cpfCnpj')" name="cpfcnpj" />
    <property name="trace"
        value="IN LOG" />
    </log>
    <property name="HTTP_METHOD" value="POST" scope="axis2" type="STRING" />
    <property name="messageType" scope="axis2" type="STRING"
    value="application/soap+xml" />
    <enrich>
        <source type="inline">
            <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                <soap:Body />
            </soap:Envelope>
        </source>
        <target action="replace" type="envelope" />
    </enrich>
    <payloadFactory media-type="xml">
        <format>
            <man:QueryCustomerDetailsRequestMessage
                xmlns:man="http://www.algartelecom.com.br/SOA/Service/ManageCustomerInformationPortalClientesReqCS">
                <man:documentNumber>$1</man:documentNumber>
                <man:tagetCRM />
            </man:QueryCustomerDetailsRequestMessage>
         </format>
        <args>
            <arg evaluator="xml" expression="get-property('uri.var.cpfCnpj')" />
        </args>
    </payloadFactory>
    <property name="REST_URL_POSTFIX" value="" scope="axis2" />
    <header name="Action" scope="default" value="queryCustomerDetails" />
    <log description="Saida" level="full" separator=",">
        <property name="trace" value="DEBUG LOG" />
    </log>
</sequence>

直到这里,没有问题。

但是,当我尝试从任何 restClient(例如 SOAPui 或 wso2-am 商店)调用资源时,会导致运行时异常,如下所示:

<?xml version='1.0' encoding='UTF-8'?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
       <am:fault xmlns:am="http://wso2.org/apimanager">
           <am:code/>
           <am:type>Status report</am:type>
           <am:message>Runtime Error</am:message>
           <am:description/>
       </am:fault>
     </soap:Body>
 </soap:Envelope>

请注意,代码和描述标签是空的,当我检查服务器的日志时,我发现:

[2016-09-30 16:53:44,603]  INFO - LogMediator STATUS = Executing default 'fault' sequence, ERROR_CODE = null, ERROR_MESSAGE = null

这是生成restful API和调用SOAP后端的正确方法吗?

有人知道这个问题吗?(我相信,此功能适用于 WSO2 ESB)。

有人可以帮我吗?

非常感谢!

4

1 回答 1

0

您可以尝试以下方法:

  • 在发布者中,将端点类型设置为 HTTP/SOAP 端点
  • 在您的序列中,不要将 REST_URL_POSTFIX 设置为“”,而是完全删除该属性

丹尼

于 2016-10-03T07:27:11.037 回答