Reputation: 26528
I am new to Spring SOAP requests. I want to see the final XML output of the SOAP request which includes SOAP header and SOAP envelop.
While debugging I reached up to this piece of code
sendSourceAndReceiveToResult(partnerURI, source,
new WebServiceMessageCallback() {
public void doWithMessage(WebServiceMessage message)
throws IOException, TransformerException {
StringSource mefHeaderSource = new StringSource(
header);
SoapHeader soapHeader = ((SoapMessage) message)
.getSoapHeader();
Transformer transformer = TransformerFactory
.newInstance().newTransformer();
transformer.transform(mefHeaderSource,
soapHeader.getResult());
}
}, result);
I suspect here I can see somewhere the output XML SOAP request by putting some logger but I am not sure I am correct. I tried searching for it but in all the posts available on google nothing is clear.
The issue which we are debugging is client is not able to see SOAP header in the SOAP request.
Upvotes: 3
Views: 15393
Reputation: 51
Make sure to use Commons Logging version 1.1 or higher.
To log all server-side messages, simply set the org.springframework.ws.server.MessageTracing logger to level DEBUG or TRACE. On the debug level, only the payload root element is logged; on the TRACE level, the entire message content. If you only want to log sent messages, use the org.springframework.ws.server.MessageTracing.sent logger; or org.springframework.ws.server.MessageTracing.received to log received messages.
On the client-side, similar loggers exist: org.springframework.ws.client.MessageTracing.sent and org.springframework.ws.client.MessageTracing.received.
Here is an example log4j.properties configuration, logging the full content of sent messages on the client side, and only the payload root element for client-side received messages. On the server-side, the payload root is logged for both sent and received messages:
log4j.rootCategory=INFO, stdout
log4j.logger.org.springframework.ws.client.MessageTracing.sent=TRACE
log4j.logger.org.springframework.ws.client.MessageTracing.received=DEBUG
log4j.logger.org.springframework.ws.server.MessageTracing=DEBUG
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%p [%c{3}] %m%n
Upvotes: 5
Reputation: 3658
from spring documentation for SoapEnvelopeLoggingInterceptor
SOAP-specific EndpointInterceptor that logs the complete request and response envelope of SoapMessage messages. By default, request, response and fault messages are logged, but this behaviour can be changed using the logRequest, logResponse, logFault properties
you can enable this interceptor by adding
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:sws="http://www.springframework.org/schema/web-services" .../>
<sws:interceptors>
<bean class="org.springframework.ws.server.endpoint.interceptor.SoapEnvelopeLoggingInterceptor"/>
</sws:interceptors>
<sws:static-wsdl ..../>
Upvotes: 0