Search code examples
wso2apache-axis

Empty soap envelope in WSO2 axis2 module


I'm working on custom axis2 module for wso2 esb. Right now I'm using code from https://docs.wso2.com/display/ESB490/Writing+an+Axis2+Module and I have a problem with incoming requests. It doesn't matter what request I send because it always looks like this:

<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>

On the other hand OutFlow works more or less as it should - response looks ok but instead of "out" its direction is set as "in". If I'm not mistaken invoke method will be called for requests and revoke for responses - am I right? In my case both are using invoke. Any ideas what I'm doing wrong?

Edit: My handler code:

public class LogHandler extends AbstractHandler implements Handler {
    private Logger log = Logger.getLogger(LogHandler.class.toString());

    @Override
    public void init(HandlerDescription handlerDescription) {
        super.init(handlerDescription);
    }

    public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
        System.out.println("invoked: " + msgContext.getEnvelope().toString() + "\n");
        log.info("invoked: " + msgContext.getEnvelope().toString() + "\n");
        return InvocationResponse.CONTINUE;
    }

    public void revoke(MessageContext msgContext) {
        log.info("revoked: " + msgContext.getEnvelope().toString() + "\n");
    }

}

Module:

public class LoggingModule implements Module {
    private static final Log log = LogFactory.getLog(LoggingModule.class);

    // initialize the module
    public void init(ConfigurationContext configContext, AxisModule module) throws AxisFault {
    }

    public void engageNotify(AxisDescription axisDescription) throws AxisFault {
    }

    // shutdown the module
    public void shutdown(ConfigurationContext configurationContext) throws AxisFault {
    }

    public String[] getPolicyNamespaces() {
        return null;
    }

    public void applyPolicy(Policy policy, AxisDescription axisDescription) throws AxisFault {
    }

    public boolean canSupportAssertion(Assertion assertion) {
        return true;
    }
}

module.xml:

<module name="sample-logging" class="pl.wso2.logging.LoggingModule">
    <InFlow>
        <handler name="InFlowLogHandler" class="pl.wso2.logging.LogHandler">
            <order phase="loggingPhase"/>
        </handler>
    </InFlow>
    <OutFlow>
        <handler name="OutFlowLogHandler" class="pl.wso2.logging.LogHandler">
            <order phase="loggingPhase"/>
        </handler>
    </OutFlow>
</module>

In my wso2 proxy I use Payload Mediator to create response and then return it using Respond Mediator. For given request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
   <aa>blahblah</aa>
   </soapenv:Body>
</soapenv:Envelope>

there two thing logged: request from InFlow

invoked: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlso
ap.org/soap/envelope/"><soapenv:Body/></soapenv:Envelope>

and response from OutFlow

invoked: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlso
ap.org/soap/envelope/"><soapenv:Body><m:checkpriceresponse xmlns:m="http://services.samples/xsd"><m:
code>dsadsa</m:code></m:checkpriceresponse></soapenv:Body></soapenv:Envelope>

Solution

  • After debugging everything I've found that while request was parsed in InFlow, instead of using its soap message, new one (empty) was created. Thankfully it's possible to access proper request using soap tracer handler (or just its code).