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)
You don't need to write one, there's an existing one in the API - SoapEnvelopeLoggingInterceptor. See the javadoc.
SOAP-specific
EndpointInterceptorthat logs the complete request and response envelope ofSoapMessagemessages. By default, request, response and fault messages are logged, but this behaviour can be changed using thelogRequest,logResponse,logFaultproperties.
If you only need to see the payload, rather than the entire SOAP envelope, then there's PayloadLoggingInterceptor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With