Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print SOAP message contents when using Apache Axis

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.

like image 545
R11G Avatar asked Dec 03 '13 11:12

R11G


People also ask

Where is the payload for the SOAP message contained?

The Body element contains the message payload. In the case of a request message the payload of the message is processed by the receiver of the message and is typically a request to perform some service and, optionally, to return some results.

What is the message format used in SOAP?

A SOAP message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element, contained in <Body> , is used for reporting errors.

What is Axis SOAP?

Introduction. Apache Axis is an implementation of the SOAP ("Simple Object Access Protocol") submission to W3C. From the draft W3C specification: SOAP is a lightweight protocol for exchanging structured information in a decentralized, distributed environment.

What does SOAP document contain?

A SOAP message is an XML document that consists of a SOAP envelope, an optional SOAP header, and a SOAP body. The SOAP message header contains information that allows the message to be routed through one or more intermediate nodes before it reaches its final destination.


1 Answers

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.

like image 112
Paulo Rodrigues Avatar answered Sep 23 '22 14:09

Paulo Rodrigues