Search code examples
postsoapwso2wso2-api-managerapi-manager

WSO2 API Manager 2.0.0- Receive GET request and send POST to backend


I've created an RESTful API in wso2-am 2.0.0. But I'm face a problem and a would some help. I have a resource wiht GET http method which receive an url param and I made a SOAP payload to send via POST to backend (backend is soap11).

For this, I used a custom 'in' sequence:

<?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>

Until here, without problem.

But when I try to call the resource from any restClient (SOAPui for example or wso2-am store) result in Runtime exception, like this:

<?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>

Note that code and description tags are empty, and when I checked the server's log I found:

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

This is the correct way to produces a restful API and call a SOAP backend?

Anybody knows about this issue? (I believe, this feature works on WSO2 ESB).


Solution

  • You can try the following:

    • In the publisher, set your endpoint type to HTTP/SOAP endpoint
    • In your sequence don't set the REST_URL_POSTFIX to "", but remove the property completely