Search in sources :

Example 1 with SynapsePayloadHandler

use of org.wso2.carbon.apimgt.gateway.handlers.ext.payloadhandler.SynapsePayloadHandler in project carbon-apimgt by wso2.

the class ExtensionListenerUtil method generateMessageInfo.

/**
 * Populate common MsgInfoDTO properties for both Request and Response from MessageContext.
 *
 * @param messageContext Synapse MessageContext
 */
private static MsgInfoDTO generateMessageInfo(MessageContext messageContext) {
    MsgInfoDTO msgInfoDTO = new MsgInfoDTO();
    org.apache.axis2.context.MessageContext axis2MC = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
    msgInfoDTO.setHeaders(getAxis2TransportHeaders(axis2MC));
    msgInfoDTO.setResource(GatewayUtils.extractResource(messageContext));
    msgInfoDTO.setElectedResource((String) messageContext.getProperty(APIMgtGatewayConstants.API_ELECTED_RESOURCE));
    // Add a payload handler instance for the current message context to consume the payload later
    msgInfoDTO.setPayloadHandler(new SynapsePayloadHandler(messageContext));
    Object correlationId = axis2MC.getProperty(CorrelationConstants.CORRELATION_ID);
    if (correlationId instanceof String) {
        msgInfoDTO.setMessageId((String) correlationId);
    }
    msgInfoDTO.setHttpMethod((String) messageContext.getProperty(APIMgtGatewayConstants.HTTP_METHOD));
    return msgInfoDTO;
}
Also used : SynapsePayloadHandler(org.wso2.carbon.apimgt.gateway.handlers.ext.payloadhandler.SynapsePayloadHandler) MsgInfoDTO(org.wso2.carbon.apimgt.common.gateway.dto.MsgInfoDTO) Axis2MessageContext(org.apache.synapse.core.axis2.Axis2MessageContext)

Aggregations

Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)1 MsgInfoDTO (org.wso2.carbon.apimgt.common.gateway.dto.MsgInfoDTO)1 SynapsePayloadHandler (org.wso2.carbon.apimgt.gateway.handlers.ext.payloadhandler.SynapsePayloadHandler)1