Benchik
Benchik

Reputation: 2167

extracting the complete envelope xml from MessageContext

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

Answers (1)

skaffman
skaffman

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 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.

Upvotes: 1

Related Questions