2017-01-30 70 views
0

我试图从中延伸AbstractSoapInterceptor一个CXF拦截登录消息和补充,拦截器链AbstractSoapInterceptor不与CXF工作:cxfEndpoint

Blueprint.xml

`<cxf:cxfEndpoint id="reportEndpoint" address="/report/" 
     serviceClass="com.shajeer.integration.helloworld.incident.IncidentService"> 
     <cxf:inInterceptors> 
      <bean id="inInterceptor" 
      class="com.shajeer.integration.helloworld.logging.LoggingInSetupInterceptor" /> 
     </cxf:inInterceptors> 
    </cxf:cxfEndpoint>` 

拦截

`import org.apache.cxf.binding.soap.SoapMessage; 
    import org.apache.cxf.binding.soap.interceptor.AbstractSoapInterceptor; 
    import org.apache.cxf.interceptor.Fault; 
    import org.apache.cxf.phase.Phase; 
    import org.slf4j.Logger; 
    import org.slf4j.LoggerFactory; 
    public class LoggingInSetupInterceptor extends AbstractSoapInterceptor{ 
    private static final Logger LOGGER = LoggerFactory.getLogger(LoggingInSetupInterceptor.class); 
     public LoggingInSetupInterceptor() { 
      super(Phase.PRE_INVOKE); 
     } 
     @Override 
     public void handleMessage(SoapMessage soapMessage) throws Fault { 
      System.out.println("In LoggingInSetupInterceptor :: LoggingInSetupInterceptor"); 
      LOGGER.info("In LoggingInSetupInterceptor :: LoggingInSetupInterceptor");  
     } 
    }` 

但是控制流并不是前夕n到达拦截器并直接进入骆驼环境。可能是什么原因?

CXF空间声明

`xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"` 

回答

0

请检查什么消息版本wheteher是Soap11SOAP12添加以下代码段和调试

public void handleMessage(SoapMessage message) throws Fault { 
     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); 
        } 
        getAndSetOperation(message, action); 
       } 
      } 
     } else if (message.getVersion() instanceof Soap12) { 

     }