How to access response payload content from custom handler in WSO2 APIM 1.9

旧巷老猫 提交于 2019-12-08 20:58:28

You need to build the message inside you handler before reading the payload, as shown below.

    public boolean handleResponse(MessageContext messageContext) {
        try {
            RelayUtils.buildMessage(((Axis2MessageContext) messageContext).getAxis2MessageContext());
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }

        // read the body
        log.info(messageContext.getEnvelope().getBody());
        return true;
    }

Refer [1] for a complete sample to build the message inside handler for API Manager 1.8.0. You need to put the correct dependencies in pom.xml for API Manager 1.9.0 (update both synapse-core & synapse-nhttp-transport version to 2.1.2-wso2v7)

[1] https://github.com/R-Rajkumar/samples/tree/master/message-builder-handler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!