Shivani Garg
Shivani Garg

Reputation: 735

How to log request.xml and response.xml in Apache Axis2

I am trying to log the request and response of a wsdl using Apache axis 2. I got some solution from internet of adding some SOAPHandler and add client-config.wsdd but i am not able to make it working at my place. Anybody can provide me a working solution or any reference which works actually.

Any help will be appreciated.

Upvotes: 2

Views: 4064

Answers (1)

galmeriol
galmeriol

Reputation: 461

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());

Upvotes: 1

Related Questions