0
votes

I have a REST API, (let's call it MYTESTAPI1), which invokes a third party API for some data. The third-party API returns the data in the following format.

After the call, when a new sequence is invoked in the above API, it works fine.

<wd:Report_Data xmlns:wd="Project_Export">
<wd:Report_Entry>
<wd:referenceID>PR00001</wd:referenceID>
<wd:projectName>
Test Project1
</wd:projectName>
<wd:Inactive>0</wd:Inactive>
<wd:Cost_Center_group>
<wd:Cost_Center_ID>CG1</wd:Cost_Center_ID>
</wd:Cost_Center_group>
<wd:Research_Budget_Remaining>0</wd:Research_Budget_Remaining>
<wd:Currency wd:Descriptor="AUD">
<wd:ID wd:type="WID">8a96ee707a264afe888d90ef93253305</wd:ID>
<wd:ID wd:type="Currency_ID">AUD</wd:ID>
<wd:ID wd:type="Currency_Numeric_Code">036</wd:ID>
</wd:Currency>
</wd:Report_Entry>
</wd:Report_Data>

But, when I call the MYTESTAPI1 REST API, from another proxy service(which is in a different CAR file), then it gives the following exception. Any help would be really helpful. If I return the result without passing to the sequence, then it does not give an error.

[2020-02-10 18:00:39,229] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} - Error while building Passthrough stream org.apache.axiom.soap.SOAPProcessingException: First Element must contain the local name, Envelope , but found Report_Data
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.constructNode(StAXSOAPModelBuilder.java:305)
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createOMElement(StAXSOAPModelBuilder.java:252)
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createNextOMElement(StAXSOAPModelBuilder.java:234)
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:249)
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelope(StAXSOAPModelBuilder.java:204)
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:154)
    at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBuilder(AbstractOMMetaFactory.java:73)
    at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder(AbstractOMMetaFactory.java:79)
    at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLBuilderFactory.java:196)
    at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:65)
    at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:153)
2
It seems like the SOAP envelope tags are removed from the response due to some reason. Since you have a sequence, that might cause this. Would you be able to provide the sequence logic as well?menaka_
<?xml version="1.0" encoding="UTF-8"?> <sequence name="testseq" trace="disable" xmlns="ws.apache.org/ns/synapse"> <log> <property name="msg" value="hi hello"/> </log> </sequence>ravi
The third party API returns message which is not in SOAP format, cant we use that message for further mediation?ravi

2 Answers

0
votes

I believe you are using an address endpoint. Please switch to an HTTP endpoint to resolve the issue.

0
votes

It seems that the message is trying to get built using a SOAP builder. To avoid the issue can you try setting messageType property to something suitable. (For eg: application/xml)

Try to add this property before calling the sequence.

<property name="messageType" value="application/xml" scope="axis2"/>