2

I have the following piece of code for a service call and I want to print the response SOAP message. I am using a stub generated using apache axis. How can i do this?

service = new RateServiceLocator();
updateEndPoint(service);
port = service.getRateServicePort();
// This is the call to the web service passing in a RateRequest and
// returning a RateReply
RateReply reply = port.getRates(request); // Service call

Thanks

Gayan Dhanushka
  • 73
  • 1
  • 2
  • 8

1 Answers1

0

I create my own log handler, and I configure AXIS (through the wsdd file) to call it on each incoming request / outgoing response.

Please take a look to the next link:

How can I log with Log4J SOAP request and response in AXIS 1.x?

Community
  • 1
  • 1
raspayu
  • 5,089
  • 5
  • 37
  • 50
  • I don't really care about the server side. Since this is a client side service call I need to get the soap response coming from the server – Gayan Dhanushka Oct 10 '12 at 08:04
  • You can use the wsdd in the client side. Of course, if you are not using it, that solution won't help you. Also that solution works on Axis 1.x. Don't know which version of Axis are you using, but if it is 2.x, it may be different. – raspayu Oct 10 '12 at 08:09
  • Thanks I did this and it worked. further more can you please tell me a way to access this SOAP request and response as a String variable where I can write it to a file. – Gayan Dhanushka Oct 10 '12 at 09:21
  • Well, if you see the Handler, I get the SOAP request in String format from "msgContext.getRequestMessage().getSOAPPartAsString()". You can either write it in the Handler directly to a file, save it in a static variable to play with that later(it won't help with the response object,since it will be generated after your code is run), or create another Handler (kind of a "SaveSOAPRequestResponseHandler") which only mission is to write the request / response directly to a file, and configure AXIS to use it, as you have done with the SOAPLogHandler(I think that it is the best solution). – raspayu Oct 10 '12 at 09:54