Reputation: 2167
I have an interceptor like this:
public class WebServiceInterceptor extends EndpointInterceptorAdapter {
@Inject
private Jaxb2Marshaller myJaxb2Marshaller;
@Inject
private WebServiceHistoryDao webServiceHistoryDao;
@Override
public boolean handleRequest(MessageContext messageContext, Object endpoint)
throws Exception {
Source payloadSource = messageContext.getRequest().getPayloadSource();
Object unmarshaled = myJaxb2Marshaller.unmarshal(payloadSource);
//EXTRACT XML HERE
//is there a better way than this:
String extractedXml = myJaxb2Marshaller.marshal(unmarshaled);
return true;
}
}
How can i extract the whole xml of envelope (for logging purposes - to write it to the DB)
Upvotes: 3
Views: 2474
Reputation: 403501
You don't need to write one, there's an existing one in the API - SoapEnvelopeLoggingInterceptor
. See the javadoc.
SOAP-specific
EndpointInterceptor
that logs the complete request and response envelope ofSoapMessage
messages. By default, request, response and fault messages are logged, but this behaviour can be changed using thelogRequest
,logResponse
,logFault
properties.
If you only need to see the payload, rather than the entire SOAP envelope, then there's PayloadLoggingInterceptor
.
Upvotes: 1