I want to configure JMS to HTTP transformation using WSO2. I tried doing soap/http to soap/http and it worked perfectly fine.
Are there any tips or did I miss any step?
When it is trying to convert JMS to http, I get to following error message.
2015-12-22 17:23:34,128 [-] [PassThroughMessageProcessor-1] ERROR Axis2Sender Content-Length:0,Date:Tue, 22 Dec 2015 10:25:04 GMT,Server:Apache-Coyote/1.1,<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><soapenv:Body/></soapenv:Envelope> Unexpected error sending message back
org.apache.axis2.AxisFault: Transport out has not been set
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:432)
at org.apache.synapse.core.axis2.Axis2Sender.sendBack(Axis2Sender.java:212)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:444)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:102)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:297)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:529)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:172)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:247)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
This error occurs mostly, when fails to register a call-back. Could you tryout following properties.
<property action="set" name="OUT_ONLY" value="true"/>
<property action="set" name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
Related
Description : I am trying to convert the incoming pdf file which has content/type application/pdf into base64 using mediation with wso2 api manager 3.2 but I couldn't figure out how to achieve this. I have added the messageformatters and messagebuilders also in axis.xml but still not able to figure out. Any help from someone would be really appreciable.
Added in Axis.xml
<messageFormatter contentType="application/pdf"
class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>
<messageBuilder contentType="application/pdf"
class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
Response Mediation
<sequence xmlns="http://ws.apache.org/ns/synapse" name="response.xml">
<property expression="$body/*" name="messageBody" scope="default" />
<property expression="base64Encode(get-property('messageBody'))" name="EncodeBody" scope="default" />
<log level="custom">
<property expression="get-property('EncodeBody')" name="EncodeBody" />
</log>
<property name="messageType" scope="axis2" type="STRING" value="application/pdf" />
<property name="contentType" scope="axis2" type="STRING" value="application/pdf" />
</sequence>
Expected Output :
{
"data": {
"file": "base64data"
}
}
Original Response
Error Logs
TID: [-1234] [] [2021-05-07 11:23:42,163] ERROR {org.apache.synapse.transport.passthru.util.RelayUtils} - Error while building Passthrough stream org.apache.axis2.AxisFault: #Can not parse stream. MessageID: urn:uuid:407d7c54-df47-46aa-ada9-9cde9b3eebe1. Error>>> #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
at org.apache.synapse.commons.json.JsonUtil.getNewJsonPayload(JsonUtil.java:862)
at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:43)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:153)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate_aroundBody0(APIManagerExtensionHandler.java:73)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:58)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse_aroundBody4(APIManagerExtensionHandler.java:132)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:120)
at org.apache.synapse.rest.API.process(API.java:371)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144)
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:60)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.axis2.AxisFault: #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
at org.apache.synapse.commons.json.JsonUtil.getNewJsonPayload(JsonUtil.java:846)
... 26 more
TID: [-1234] [] [2021-05-07 11:23:42,169] ERROR {org.apache.synapse.mediators.base.SequenceMediator} - {api:admin--CreditorWatchDownloadCreditReportPDF:v1.0.0} Error while building message. Error while building Passthrough stream org.apache.axis2.AxisFault: Error while building Passthrough stream
at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:452)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:215)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate_aroundBody0(APIManagerExtensionHandler.java:73)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:58)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse_aroundBody4(APIManagerExtensionHandler.java:132)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:120)
at org.apache.synapse.rest.API.process(API.java:371)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144)
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:60)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.apache.axis2.AxisFault: #Can not parse stream. MessageID: urn:uuid:407d7c54-df47-46aa-ada9-9cde9b3eebe1. Error>>> #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
at org.apache.synapse.commons.json.JsonUtil.getNewJsonPayload(JsonUtil.java:862)
at org.apache.synapse.commons.json.JsonStreamBuilder.processDocument(JsonStreamBuilder.java:43)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:153)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:169)
... 23 more
Caused by: org.apache.axis2.AxisFault: #getNewJsonPayload. Could not save JSON payload. Invalid input stream found. Payload is not a JSON string.
at org.apache.synapse.commons.json.JsonUtil.getNewJsonPayload(JsonUtil.java:846)
... 26 more
TID: [-1234] [] [2021-05-07 11:23:42,173] ERROR {API_LOGGER.admin--CreditorWatchDownloadCreditReportPDF} - Error while building message. Error while building Passthrough stream org.apache.axis2.AxisFault: Error while building Passthrough stream
at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:452)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:215)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:122)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:152)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:95)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate_aroundBody0(APIManagerExtensionHandler.java:73)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:58)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse_aroundBody4(APIManagerExtensionHandler.java:132)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:120)
at org.apache.synapse.rest.API.process(API.java:371)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144)
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:60)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Similar to this link Encoding PDF binary data to base64 not working with NodeJS but need to do it in wso2 api manager
As per the shared stack trace, the correct formatters and builders are not picked during the mediation process. And API Manager was using the JSONStreamBuilder to build the message.
The API Manager v3.2.0 uses a centralized configuration to configure the XML artifacts. Therefore, if you have configured the Message Builders and Formatters by directly editing the axis2.xml, the configurations will be lost by the startup of the server. Perform the following configuration in the <apim>/repository/conf/deployment.toml
[[custom_message_formatters]]
class = "org.wso2.carbon.relay.ExpandingMessageFormatter"
content_type = "application/pdf"
[[custom_message_builders]]
class = "org.wso2.carbon.relay.BinaryRelayBuilder"
content_type = "application/pdf"
and restart the server and retry the scenario.
Description : I am trying to transform from xml to json using script mediator in wso2 3.2 api manager. The issue which I am facing is the script mediator method getPayloadXML() is not able to pull out a specific value from xml where it always returns as ReferenceError: "code" is not defined. I tried multiple things but couldn't figure out how to achieve this. Any help from someone would be really appreciable.
Response Mediation
<sequence xmlns="http://ws.apache.org/ns/synapse" name="transform">
<script language="js"><![CDATA[
var envelope = mc.getPayloadXML()..*::fault-code.toString()
var request ={"data":{"success":"true","message":"SuccessFull","faultcode":envelope}};
mc.setPayloadJSON(request);
]]></script>
<log level="full">
<property name="Message" value="UpdatedMessage"/>
</log>
<property name="HTTP_SC" value="200" scope="axis2" />
<property name="messageType" value="application/json" scope="axis2"/>
</sequence>
Original Response
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<wsa:MessageID>210419-BA7CF-32444</wsa:MessageID>
<wsa:RelatesTo>Test123456</wsa:RelatesTo>
<wsa:To>http://www.w3.org/2005/08/addressing/anonymous</wsa:To>
<wsa:From>
<wsa:Address>some data</wsa:Address>
</wsa:From>
<wsa:Action>some data</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<cbo:response xmlns:abr="url" xmlns:asic="url" client-reference1="A1" response-type="error" version="1.2">
<cbo:error>
<cbo:fault-code>CBOX017</cbo:fault-code>
<cbo:fault-string>User account is inactive.</cbo:fault-string>
<cbo:fault-actor/>
<cbo:detail/>
</cbo:error>
</cbo:response>
</soapenv:Body>
</soapenv:Envelope>
Expected Response (Transform To JSON)
{
"data": {
"success": "true",
"message": "SuccessFull",
"faultcode":CBOX017
}
}
Error Logs
TID: [-1234] [] [2021-04-19 16:14:41,259] ERROR {org.apache.synapse.mediators.bsf.ScriptMediator} - {api:admin--equifaxACNCheck:v1.0.0} The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "code" is not defined. (<Unknown Source>#2) in <Unknown Source> at line number 2
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
at javax.script.CompiledScript.eval(CompiledScript.java:92)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:395)
at org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:290)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:258)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate_aroundBody0(APIManagerExtensionHandler.java:73)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:58)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse_aroundBody4(APIManagerExtensionHandler.java:132)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:120)
at org.apache.synapse.rest.API.process(API.java:371)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144)
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:60)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "code" is not defined. (<Unknown Source>#2)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3750)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1728)
at org.mozilla.javascript.gen._Unknown_Source__2233._c_script_0(<Unknown Source>:2)
at org.mozilla.javascript.gen._Unknown_Source__2233.call(<Unknown Source>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen._Unknown_Source__2233.call(<Unknown Source>)
at org.mozilla.javascript.gen._Unknown_Source__2233.exec(<Unknown Source>)
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:55)
... 25 more
TID: [-1234] [] [2021-04-19 16:14:41,267] ERROR {API_LOGGER.admin--equifaxACNCheck} - The script engine returned an error executing the inlined js script function mediate com.sun.phobos.script.util.ExtendedScriptException: org.mozilla.javascript.EcmaError: ReferenceError: "code" is not defined. (<Unknown Source>#2) in <Unknown Source> at line number 2
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:68)
at javax.script.CompiledScript.eval(CompiledScript.java:92)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediateForInlineScript(ScriptMediator.java:395)
at org.apache.synapse.mediators.bsf.ScriptMediator.invokeScript(ScriptMediator.java:290)
at org.apache.synapse.mediators.bsf.ScriptMediator.mediate(ScriptMediator.java:258)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:109)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:71)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate_aroundBody0(APIManagerExtensionHandler.java:73)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:58)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse_aroundBody4(APIManagerExtensionHandler.java:132)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:120)
at org.apache.synapse.rest.API.process(API.java:371)
at org.apache.synapse.rest.RESTRequestHandler.apiProcessNonDefaultStrategy(RESTRequestHandler.java:144)
at org.apache.synapse.rest.RESTRequestHandler.identifyAPI(RESTRequestHandler.java:164)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:60)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:331)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:583)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:197)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:285)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "code" is not defined. (<Unknown Source>#2)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3687)
at org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3665)
at org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3750)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1728)
at org.mozilla.javascript.gen._Unknown_Source__2233._c_script_0(<Unknown Source>:2)
at org.mozilla.javascript.gen._Unknown_Source__2233.call(<Unknown Source>)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3091)
at org.mozilla.javascript.gen._Unknown_Source__2233.call(<Unknown Source>)
at org.mozilla.javascript.gen._Unknown_Source__2233.exec(<Unknown Source>)
at com.sun.phobos.script.javascript.RhinoCompiledScript.eval(RhinoCompiledScript.java:55)
... 25 more
It looks like the ScriptMediator has problem with parsing the fault-code. I think it is because the hyphen - already have meaning in JavaScript and in E4X. Maybe you can use alternate mediation with PayloadFactory like below:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="transform">
<payloadFactory media-type="json">
<format>{"data":{"success":"$1", "message":"$2", "faultcode":"$3"}}</format>
<args>
<arg literal="false" value="true"/>
<arg literal="false" value="SuccessFull"/>
<arg evaluator="xml" expression="//*:fault-code"
literal="false" xmlns:ns="http://org.apache.synapse/xsd"/>
</args>
</payloadFactory>
<log level="full">
<property name="Message" value="UpdatedMessage"/>
</log>
<property name="HTTP_SC" value="200" scope="axis2" />
</sequence>
The <property name="messageType" value="application/json" scope="axis2"/> shouldn't be needed, because the payload factory should set that.
WSO2 API Manager Version: 2.5.0
I have an Out Mediator that is supposed to do something very simple:
Enrich a property based of uri.var.stackstormexecId (Working)
Set an API Key Header (Working)
Set an Accept: */* Header (Working)
Call (Blocking) HTTP Endpoint that returns an unstructured response (Not Working)
Call HTTP Endpoint that returns a structured response (Working)
The step 4) is done simply to block the sequence, I don't care about its response. That specific endpoint will release the HTTP connection when some southbound work is done, allowing the next Call in 5) to retrieve meaningful information.
The problem is that by setting Accept: */* I'm expecting that the API Gw will handle the unstructured response of the 4) Call, for which its Content-Type is text/event-stream. It is throwing a XML Parser Exception on that Call because there is no associated axis2 message builder associated with this specific Content-Type.
Question: Anyone knows which message builder class should be used and defined in axis2.xml to overcame this?
I'm not sure what it is trying to use, but the exception comes from a getSOAPBuilder, which is certainly not the case. It expects a "<" but gets an "e" (which is the first character of the unstructured response of step 4)):
TID: [-1234] [] [2018-12-18 11:22:08,656] INFO {org.apache.axis2.builder.BuilderUtil} - OMException in getSOAPBuilder {org.apache.axis2.builder.BuilderUtil}
org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'e' (code 101) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)
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.soap.impl.builder.StAXSOAPModelBuilder.<init>(StAXSOAPModelBuilder.java:140)
at org.apache.axis2.builder.BuilderUtil.getSOAPBuilder(BuilderUtil.java:658)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:206)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:146)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:109)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:68)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:351)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:456)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:227)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.sendReceive(BlockingMsgSender.java:490)
at org.apache.synapse.message.senders.blocking.BlockingMsgSender.send(BlockingMsgSender.java:382)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:88)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:85)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:511)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:384)
at org.apache.synapse.endpoints.HTTPEndpoint.send(HTTPEndpoint.java:85)
at org.apache.synapse.mediators.builtin.CallMediator.handleBlockingCall(CallMediator.java:164)
at org.apache.synapse.mediators.builtin.CallMediator.mediate(CallMediator.java:119)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:108)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:70)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:66)
at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleResponse(APIManagerExtensionHandler.java:87)
at org.apache.synapse.rest.API.process(API.java:323)
at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:90)
at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:56)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:303)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:570)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:193)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ClientWorker.run(ClientWorker.java:263)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character 'e' (code 101) in prolog; expected '<'
at [row,col {unknown-source}]: [1,1]
at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)
at com.ctc.wstx.sr.BasicStreamReader.nextFromProlog(BasicStreamReader.java:2052)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1134)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)
... 38 more
TID: [-1234] [] [2018-12-18 11:22:08,894] INFO {org.apache.axis2.builder.BuilderUtil} - Remaining input stream :[event: st2.execution.output__create
data: {"timestamp": "2018-12-18T11:22:08.654318Z", "runner_ref": "local-shell-script", "output_type": "stdout", "action_ref": "package.action", "data": "id: 5c18d85ca832cb61d235c1d4\n", "id": "5c18d860a832cb6079e87993", "execution_id": "5c18d85ba832cb61d235c1d1"}
My objective is simply to Call this endpoint, wait for it to respond, ignore the response and move on with the sequence.
The sequence code:
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="someseq.xml" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<enrich>
<source clone="true" type="body"/>
<target property="stackOutput" type="property"/>
</enrich>
<property expression="$ctx:stackOutput/id" name="uri.var.stackstormexecId" scope="default" type="STRING"/>
<header name="St2-Api-Key" scope="transport" value="somekey"/>
<header name="Accept" scope="transport" value="*/*"/>
<call blocking="true">
<endpoint>
<http method="get" uri-template="http://somehost/v1/executions/{uri.var.stackstormexecId}/output"/>
</endpoint>
</call>
<header name="St2-Api-Key" scope="transport" value="somekey"/>
<header name="Accept" scope="transport" value="application/json"/>
<call>
<endpoint>
<http method="get" uri-template="http://somehost/v1/executions/{uri.var.stackstormexecId}"/>
</endpoint>
</call>
<respond/>
</sequence>
The problem was happening because the Content-Type of the call response is text/event-stream, which is not defined out of the box by WSO2 API Manager axis2 message builder.
I am using WSO2 EI 6.3.0 version. I am creating data service within the application which reads data from CSV.
I am running into very unusual case where I have created two data services. One with sample Product.csv which is shipped with WSO2 EI.
When calling Sample (Product.CSV) I am able to get the json response message. but when I am trying to invoke another API which other data service it is giving me below error:
[2018-10-10 17:57:31,916] [EI-Core] ERROR - JsonStreamFormatter Error occurred while writing to application/json
java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor133.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.wso2.carbon.integrator.core.json.JsonStreamFormatter.writeTo(JsonStreamFormatter.java:107)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.submitResponse(PassThroughHttpSender.java:597)
at org.apache.synapse.transport.passthru.PassThroughHttpSender.invoke(PassThroughHttpSender.java:281)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.invokeBusinessLogic(AbstractInOutSyncMessageReceiver.java:45)
at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:110)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:337)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:158)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.xml.stream.XMLStreamException: DS Fault Message: Error in CSVQuery.runQuery.
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Source Data Service:-
Name: InvoiceReport
Location: /InvoiceReport.dbs
Description: N/A
Default Namespace: http://ws.wso2.org/dataservice
Current Request Name: _getinvoice
Current Params: {}
Nested Exception:-
DS Fault Message: Error in 'StaticOutputElement.execute', cannot find parameter with type:column name:Docnumber
DS Code: INCOMPATIBLE_PARAMETERS_ERROR
Below is Data service:
<data name="InvoiceReport" transports="http https local">
<config enableOData="false" id="CSV_InvoiceReport">
<property name="csv_datasource">/usr/lib/wso2/wso2ei/6.3.0/samples/data-services/resources/Invoice.csv</property>
<property name="csv_columnseperator">comma</property>
<property name="csv_startingrow">2</property>
<property name="csv_hasheader">true</property>
<property name="csv_headerrow">1</property>
</config>
<query id="Q2" useConfig="CSV_InvoiceReport">
<result outputType="json">{
"Products": {
"Product": [
{
"Docnumber":"$Docnumber",
"Invoicenumber":"$Invoicenumber",
"Documentdate":"$Documentdate",
"Invoiceduedate":"$Invoiceduedate",
"Customerid":"$Customerid",
"Documenttotal":"$Documenttotal",
"Quantity":"$Quantity",
"Unitprice":"$Unitprice",
"Extendedprice":"$Extendedprice",
"Consumer":"$Consumer",
"Servicename":"$Servicename"
}
]
}
}
</result>
</query>
<operation name="GetInvoiceReport">
<call-query href="Q2"/>
</operation>
<resource method="GET" path="Invoice">
<call-query href="Q2"/>
</resource>
</data>
Not sure where is the problem. Both are simple data service and didnot find any differences in creating them. One is working and one is not working at all.
Can some one please help me. Is this a bug?
Thanks in advance.
I am using wso2 esb 4.8.1. I am trying to do xml to xml transformation with the help of smooks mediator but I am getting following exception when is hit request from the try it from application deployment console of wso2,
[2014-11-07 09:39:20,401] ERROR - SmooksMediator Failed to filter source.
org.milyn.SmooksException: Failed to filter source.
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:61)
at org.milyn.Smooks._filter(Smooks.java:516)
at org.milyn.Smooks.filterSource(Smooks.java:475)
at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:123)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:411)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Premature end of file.
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1236)
at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:70)
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:75)
... 15 more
[2014-11-07 09:39:20,417] ERROR - NativeWorkerPool Uncaught exception
org.wso2.carbon.mediator.service.MediatorException: Failed to filter source. Caused by Failed to filter source.
at org.wso2.carbon.mediator.transform.SmooksMediator.handleException(SmooksMediator.java:242)
at org.wso2.carbon.mediator.transform.SmooksMediator.mediate(SmooksMediator.java:137)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:411)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
seqence xml is as below,
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="smooksTransService" transports="http https" startOnLoad="true" trace="disable">
<target>
<inSequence>
<log level="full" separator=","/>
<smooks config-key="gov:/_system/config/transforms/smooksconfig.xml">
<input type="text"/>
<output type="xml"/>
</smooks>
<log level="full" separator=","/>
<drop/>
</inSequence>
<outSequence/>
<faultSequence/>
</target>
</proxy>
Below is smooks configuration file,
<?xml version="1.0" encoding="UTF-8"?><smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:ftl="http://www.milyn.org/xsd/smooks/freemarker-1.1.xsd">
<params>
<param name="stream.filter.type">SAX</param>
<param name="inputType">input.xml</param>
<param name="default.serialization.on">true</param>
<param name="input.xml" type="input.type.actived">File:/C:\Shailesh\xmls\model-input.xml</param>
</params>
<ftl:freemarker applyOnElement="#document">
<ftl:template><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
<h:salesorder xmlns:h="http://www.w3.org/TR/html4/">
<h:details>
<h:orderid>${.vars["order"]["#id"]}</h:orderid>
<h:customer>
<h:id>${.vars["order"]["header/customer/#number"]}</h:id>
<h:name>${.vars["order"]["header/customer"]}</h:name>
</h:customer>
</h:details>
<#list .vars["order"]["order-items"] as order_items>
<h:itemList>
<#list .vars["order_items"]["order-item"] as order_item>
<h:item>
<h:id>${.vars["order_item"]["#id"]}</h:id>
<h:productId>${.vars["order_item"]["product"]}</h:productId>
<h:quantity>${.vars["order_item"]["quantity"]}</h:quantity>
<h:price>${.vars["order_item"]["price"]}</h:price>
</h:item>
</#list>
</h:itemList>
</#list>
</h:salesorder>]]></ftl:template>
<param name="modelSrc">File:/C:\Shailesh\xmls\model-output.xml</param>
<param name="modelSrcType">XML</param>
<param name="mess![enter image description here][2]ageType">XML</param>
<param name="templateDataProvider">input</param>
</ftl:freemarker>
<resource-config selector="#document">
<resource>org.milyn.delivery.DomModelCreator</resource>
</resource-config>
</smooks-resource-list>
My request for proxy service is as shown in attached image.
I didn't go through your example thoroughly, but it seems the error is that the Smooks Mediator cannot find the registry resource.
Looks like there is an issue when you specify the smooks config-key attribute. When you are working with the registry, you need to know that there are different registry spaces.
If you refer a resource via "gov:", the resource will be in "/_system/governance". You need to use "conf:" to refer a resource in "/_system/config".
For eg: If you have a resource in "/_system/config/transforms/smooksconfig.xml", you need to refer it as follows:
"conf:transforms/smooksconfig.xml"
Related question: Howto access registry in WSO2 ESB
I hope this helps.