Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get SOAP message while using a Axis 1.4 wsdl2java-generated client

This is probably an easy question for anyone with any moderate expertise with web services using Apache Axis.

I have a web service client that was generated by wsdl2java in Axis 1.4. I am writing unit tests that need to access the actual SOAP message itself, and do a comparison to the client side java classes which are generated by Axis. (don't ask)

How can I retrieve the actual SOAP message from a response from the service?

From what I can gather from searching around is that I have to get the MessageContext. I have tried something along these lines...

MessageContext mc = MessageContext.getCurrentContext(); String message = mc.getCurrentMessage().getSOAPPartAsString();

But mc is null in this case....

Any help is appreciated!

like image 937
rshepherd Avatar asked Oct 20 '09 18:10

rshepherd


People also ask

What is Axis SOAP?

Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways, etc. The current version of Axis is written in Java, but a C++ implementation of the client side of Axis is being developed.

How do I use Axis Web services?

This step is extremely simple: just copy (recursively) the webapps/axis directory under the webapps directory of your Tomcat installation (i.e., $TOMCAT_HOME\webapps). Next, copy the XML parser libraries (such as the 3 Xerces JAR files mentioned above) to the $TOMCAT_HOME\webapps\axis\lib directory.

What is the use of Apache Axis in Web services?

Apache Axis2/C can be used to provide and consume WebServices. It has been implemented with portability and ability to embed in mind, hence could be used as a Web services enabler in other software. Rampart is the security module of Axis2.


2 Answers

This is how it's done.

http://users.skynet.be/pascalbotte/rcx-ws-doc/jaxrpchandler.htm

like image 51
rshepherd Avatar answered Sep 20 '22 12:09

rshepherd


When _call object is filled calling the line below gives it.

String request=_call.getMessageContext().getRequestMessage() .getSOAPPart().getEnvelope().toString();

For response use the below one

_call.getMessageContext().getResponseMessage() .getSOAPPart().getEnvelope().toString()

Call is a org.apache.axis.client.Call as you know.

like image 36
Davut Gürbüz Avatar answered Sep 20 '22 12:09

Davut Gürbüz