REST服务中的WSo2 ESB 4.0.3和JSON [英] WSo2 ESB 4.0.3 and JSON in REST service

查看:146
本文介绍了REST服务中的WSo2 ESB 4.0.3和JSON的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用REST服务在WSB403中吐出JSON输出,但我一直非常失败.我按照以下链接中概述的步骤进行操作.

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和JSON

我添加了DynamicResponseModule,并且已对其进行全局分配.

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

正常运行REST服务时,将按预期方式获得XML格式的输出,但是当我尝试添加"response=json"时,我的服务超时并得到以下堆栈跟踪.

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.

内部DynamicResponseModule应该将此responseType映射到application/JSON/Badgerfish,并且在这样做时,我得到以下堆栈跟踪.

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:来自数据源的元素名称空间是 http://ws.apache.org/axis2 ,而不是预期的 org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:287) 在 org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867) 在 org.apache.axiom.om.impl.OMNavigator._getFirstChild(OMNavigator.java:196) 在 org.apache.axiom.om.impl.OMNavigator.updateNextNode(OMNavigator.java:140) 在org.apache.axiom.om.impl.OMNavigator.getNext(OMNavigator.java:112) 在 org.apache.axiom.om.impl.SwitchingWrapper.updateNextNode(SwitchingWrapper.java:1113) 在 org.apache.axiom.om.impl.SwitchingWrapper.(SwitchingWrapper.java:235) 在org.apache.axiom.om.impl.OMStAXWrapper.(OMStAXWrapper.java:74)在 org.apache.axiom.om.impl.llom.OMStAXWrapper.(OMStAXWrapper.java:52)在 org.apache.axiom.om.impl.llom.OMContainerHelper.getXMLStreamReader(OMContainerHelper.java:51) 在 org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMElementImpl.java:736) 在 org.apache.axiom.om.impl.llom.OMElementImpl.cloneOMElement(OMElementImpl.java:1038) 在 org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:256) 在 org.apache.synapse.core.axis2.SOAPUtils.convertSOAP11toSOAP12(SOAPUtils.java:95) 在 org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:323) 在 org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:160) 在org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:181)处 org.apache.synapse.transport.nhttp.ClientWorker.run(ClientWorker.java:275) 在 org.apache.axis2.transport.base.threads.NativeWorkerPool $ 1.run(NativeWorkerPool.java:173) 在 java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886) 在 java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:908) 在java.lang.Thread.run(Thread.java:662)这些是消息 我已添加到axis2.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"/>

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(OMElementImpl.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 axis2.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 ?

谢谢

Narsi

推荐答案

您可能会从示例中得到启发[1]. (请注意,如果要从json切换到soap11,则必须将端点格式设置为soap11.)

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.)

在axis2.xml中使用json消息生成器和格式器设置正确的内容类型(例如,application/json)

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

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

这篇关于REST服务中的WSo2 ESB 4.0.3和JSON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆