2

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.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Shivani Garg
  • 735
  • 13
  • 37

1 Answers1

1

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());
galmeriol
  • 461
  • 4
  • 14
  • This can't be done for ADB and XMLBeans data binding because IllegalOperationException occurs for the following reason: https://jira.apache.org/jira/browse/AXIS2-5202 – Renato Dragišić Aug 29 '18 at 10:24