Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extracting the complete envelope xml from MessageContext

Tags:

soap

spring-ws

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)

like image 875
Benchik Avatar asked Feb 15 '26 00:02

Benchik


1 Answers

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 of SoapMessage messages. By default, request, response and fault messages are logged, but this behaviour can be changed using the logRequest, logResponse, logFault properties.

If you only need to see the payload, rather than the entire SOAP envelope, then there's PayloadLoggingInterceptor.

like image 56
skaffman Avatar answered Feb 20 '26 21:02

skaffman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!