简体   繁体   English

SOAP输出拦截器CXF

[英]SOAP out interceptor CXF

In our application, we need to interact with different third party web services. 在我们的应用程序中,我们需要与不同的第三方Web服务进行交互。 In one of the case, we had to add an out interceptor to manipulate the request headers and body. 在一种情况下,我们必须添加一个out拦截器来操纵请求标头和主体。 The main technologies we are using are Spring and CXF and the configurations are using XML (in spring context). 我们使用的主要技术是Spring和CXF,而配置则使用XML(在Spring上下文中)。

Is there a way to limit the interceptor invocation only when a request is made to a particular web service. 是否只有在对特定Web服务发出请求时才有限制拦截器调用的方法。

public abstract class TransformSOAPMessageInterceptor extends AbstractPhaseInterceptor<Message> {

}

Thanks and Regards, San 感谢和问候,San

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 : 您可以检查消息中的SOAPAction标头(下面显示的大多数示例摘自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) {
          ...........
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM