In Axis2 exchanged messages are represented in OperationContext
. So after the invocation of the service;
StringBuffer xmlRequestMessage = new StringBuffer();
StringBuffer xmlResponseMessage = new StringBuffer();
OperationContext operationContext = stub._getServiceClient().getLastOperationContext();
// For request message
MessageContext requestMessageContext = operationContext.getMessageContext("Out");
xmlRequestMessage = new StringBuffer(requestMessageContext.getEnvelope().toString());
// For response message
MessageContext responseMessageContext = operationContext.getMessageContext("In");
xmlResponseMessage = new StringBuffer(responseMessageContext.getEnvelope().toString());