MessageContext中的WSO2 ESB自定义轴模块JSON有效负载

时间:2017-02-03 23:35:53

标签: json wso2esb axis2

我写了一个自定义Axis模块来嗅出我的WSO2 ESB中的所有通信。我在所有阶段都注册了它 - 当涉及到SOAP通信时,一切都按预期工作。

但是,我无法检索在WSO2 ESB中定义和调用的REST API的JSON有效内容。 MessageContext.getEnvelope返回一个空体,即使我可以看到我的REST客户端中返回了一个JSON有效负载。

基本上我的代码如下所示:

    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
            String logId = msgContext.getLogCorrelationID();
            long currentTimestamp = System.currentTimeMillis();

            logEntry.setId(logId);

            if( msgContext.isDoingREST() ) {
                logEntry.setFormat(ILogEntry.FORMAT_REST);
                logEntry.setPayload(String.valueOf(msgContext.getEnvelope()));
            } else if( msgContext.isDoingMTOM() ) {
                logEntry.setFormat(ILogEntry.FORMAT_MTOM);
            } else if( msgContext.isDoingSwA() ) {
                logEntry.setFormat(ILogEntry.FORMAT_SWA);
            } else {
                logEntry.setFormat(ILogEntry.FORMAT_SOAP);
                JSONObject json = XML.toJSONObject(String.valueOf(msgContext.getEnvelope()));
                logEntry.setPayload(String.valueOf(json));
            }
    }

org.apache.axis2.context.MessageContext内的JSON有效负载是否以与SOAP不同的方式进行管理?

如何找回它?

彼得

1 个答案:

答案 0 :(得分:0)

看起来您遇到了与此处所述相同的问题。

Will JSON based REST - ESB - REST communication build AXIS 2 XML MessageContext

相关问题