简体   繁体   中英

WSo2 ESB 4.0.3 and JSON in REST service

I am trying to use a REST service spit out a JSON output in WSB403 and I have been highly unsuccessful. I followed the steps outlined from the below link.

ESB and JSON

I have added the DynamicResponseModule and I have it assigned globally.

When I run the REST service normally, I get a XML formatted output as expected, but when I try to add a " response=json ", my service times out and I get the following stacktrace.

Internally the DynamicResponseModule is supposed to map this responseType to application/JSON/Badgerfish and when it does that I get the following stack trace.

java.lang.RuntimeException: Element namespace from data source is http://ws.apache.org/axis2 , not the expected at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:287) at org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867) at org.apache.axiom.om.impl.OMNavigator._getFirstChild(OMNavigator.java:196) at org.apache.axiom.om.impl.OMNavigator.updateNextNode(OMNavigator.java:140) at org.apache.axiom.om.impl.OMNavigator.getNext(OMNavigator.java:112) at org.apache.axiom.om.impl.SwitchingWrapper.updateNextNode(SwitchingWrapper.java:1113) at org.apache.axiom.om.impl.SwitchingWrapper.(SwitchingWrapper.java:235) at org.apache.axiom.om.impl.OMStAXWrapper.(OMStAXWrapper.java:74) at org.apache.axiom.om.impl.llom.OMStAXWrapper.(OMStAXWrapper.java:52) at org.apache.axiom.om.impl.llom.OMContainerHelper.getXMLStreamReader(OMContainerHelper.java:51) at org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMEle mentImpl.java:736) at org.apache.axiom.om.impl.llom.OMElementImpl.cloneOMElement(OMElementImpl.java:1038) at org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:256) at org.apache.synapse.core.axis2.SOAPUtils.convertSOAP11toSOAP12(SOAPUtils.java:95) at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:323) at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:160) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181) at org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:275) at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:173) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:662) These are the message formatters and builders that I have added to the axi s2.xml class="org.apache.axis2.json.JSONOMBuilder"/> class="org.apache.axis2.json.JSONBadgerfishOMBuilder"/>
class="org.apache.axis2.json.JSONOMBuilder"/>
class="org.apache.axis2.json.JSONBadgerfishMessageFormatter"/>
class="org.apache.axis2.json.JSONMessageFormatter"/>

Any idea what am I missing here ?

Thanks

Narsi

You may inspire from the sample[1]. (Please note that if you want to switch from json to soap11, then you have to set the endpoint format to soap11.)

Use json message builder and formtter in the axis2.xml for the correct content type (eg application/json for instance)

[1] http://wso2.org/project/esb/java/4.0.3/docs/samples/advanced_mediation_samples.html#Sample440

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM