在WSO2 API1.7中POST POST restful service request时发出问题

时间:2016-04-04 06:00:24

标签: wso2 wso2-am

它之前工作得很好,但现在我使用相同的文档作为POST方法发送另一个安静的服务,它抛出以下错误

ERROR - SequenceMediator Error while building message
org.apache.axis2.AxisFault: Error while building Passthrough stream
    at org.apache.synapse.transport.passthru.util.RelayUtils.handleException(RelayUtils.java:236)
    at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:111)
    at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:82)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:68)
    at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
    at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
    at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.mediate(APIManagerExtensionHandler.java:64)
    at org.wso2.carbon.apimgt.gateway.handlers.ext.APIManagerExtensionHandler.handleRequest(APIManagerExtensionHandler.java:180)
    at org.apache.synapse.rest.API.process(API.java:285)
    at org.apache.synapse.rest.RESTRequestHandler.dispatchToAPI(RESTRequestHandler.java:83)
    at org.apache.synapse.rest.RESTRequestHandler.process(RESTRequestHandler.java:64)
    at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.injectMessage(Axis2SynapseEnvironment.java:220)
    at org.apache.synapse.core.axis2.SynapseMessageReceiver.receive(SynapseMessageReceiver.java:83)
    at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
    at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:344)
    at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:385)
    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:745)
Caused by: org.apache.axis2.AxisFault: Failed to convert JSON to XML payload. Expected a ',' or '}' at character 26 of { "xmlPayload" : username=sm&password=sm10&versions=1&regid=1&deviceType=1}
    at org.apache.axis2.json.JSONBuilder.processDocument(JSONBuilder.java:87)
    at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:118)
    at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:107)
    ... 19 more
[2016-04-04 11:35:45,158]  INFO - LogMediator STATUS = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Error while building message

1 个答案:

答案 0 :(得分:0)

这是APIM 1.7中的一个已知问题,它为多根JSON消息添加了额外的xmlPayload元素。这是由于Jettison库中的一个错误,它是APIM 1.7中的默认json消息解析器。您可以通过修改axis2.xml文件来更改消息构建器和格式化程序来消除此错误,如下所示;

在APIM 1.7的axis2.xml中为application/json类型添加以下构建器和格式化程序(注释掉现有的消息构建器和“application / json”类型的格式化程序)

<messageFormatter contentType="application/json"
                  class="org.apache.synapse.commons.json.JsonStreamFormatter"/>


<messageBuilder contentType="application/json"
                class="org.apache.synapse.commons.json.JsonStreamBuilder"/>