kallada
kallada

Reputation: 1929

SOAP out interceptor CXF

In our application, we need to interact with different third party web services. In one of the case, we had to add an out interceptor to manipulate the request headers and body. The main technologies we are using are Spring and CXF and the configurations are using XML (in spring context).

Is there a way to limit the interceptor invocation only when a request is made to a particular web service.

public abstract class TransformSOAPMessageInterceptor extends AbstractPhaseInterceptor<Message> {

}

Thanks and Regards, San

Upvotes: 0

Views: 1370

Answers (1)

Frank
Frank

Reputation: 2066

You could check the SOAPAction-header in the message (most of the example shown below is taken from http://cxf.apache.org/docs/interceptors.html:

if (message.getVersion() instanceof Soap11) {
            Map<String, List<String>> headers = CastUtils.cast((Map)message.get(Message.PROTOCOL_HEADERS));
            if (headers != null) {
                List<String> sa = headers.get("SOAPAction");
                if (sa != null && sa.size() > 0) {
                    String action = sa.get(0);
                    if (action.startsWith("\"")) {
                        action = action.substring(1, action.length() - 1);
                    }
                    if (StringUtils.equals(action, "YOUR_SPECIAL_ACTION" ) {
                        doYourSpecialProcessint(message, action);
                    }
                }
            }
        } else if (message.getVersion() instanceof Soap12) {
          ...........
        }

Upvotes: 1

Related Questions