How to print SOAP message contents when using Apache Axis
Solution 1
You probably don't need this answer anymore, but stays here for anyone else that ends right up here with the same problem.
The easiest way to retrieve both the request and the response is to get them from the call you are making. In the axis generated stub, after invoking a call do this:
String requestXML = _call.getMessageContext().getRequestMessage().getSOAPPartAsString();
String responseXML = _call.getMessageContext().getResponseMessage().getSOAPPartAsString();
Hope it helps. It helped me when I needed to print the request too.
Solution 2
I was having trouble figuring this out as well. The problem for me was my _call.invoke() was failing. I was able to surround this in a try-catch clause and still get the request message for debugging:
Example:
try{
_call.invoke();
catch(Exception e){
_call.getMessageContext().getRequestMessage().getSOAPPartAsString();
}
Solution 3
Use an axis2handler and try to log the messages.
msgcontext.getEnvelope().getBody()
R11G
Updated on July 05, 2022Comments
-
R11G almost 2 years
I am using Apache Axis for web service automation.
I am preparing SOAP requests via Axis and hitting the web service further. What I am looking for is how to print the SOAP request content which is getting compiled and hitting the webservice.
I found that log4j can help but I am struggling how to use it.
-
Rajeev over 5 years
-
-
Ratha over 10 yearsThat is the axis2 configuration file.
-
Eric over 8 years
_call
is an object of what type? -
Paulo Rodrigues over 8 yearsIt's the type org.apache.axis.client.Call.
-
Roberto Rodriguez over 7 yearsHow do I access to that call?
-
Abhishek Singh about 6 yearsThis is simple, yet a very important addition to the accepted answer.
-
Abhishek Singh about 6 yearsAs mentioned in the answer given by Brian, if your call is failing in invoke itself, wrap that in a try catch block and get the message.
-
Jairo Martínez over 4 years@Eric the object _call is located most of the time inside BindingStub.java file if you generates the Objects with Apache Axis.