Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cassandra/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel 使用Apache Camel(Java DSL)拦截cxf web服务头_Apache Camel_Cxf_Wss4j - Fatal编程技术网

Apache camel 使用Apache Camel(Java DSL)拦截cxf web服务头

Apache camel 使用Apache Camel(Java DSL)拦截cxf web服务头,apache-camel,cxf,wss4j,Apache Camel,Cxf,Wss4j,我创建了一个web服务客户端,用ApacheCamel处理cxf soap web服务 String serviceUri = "cxf:http://localhost:10000/myservice?serviceClass=" + MyRequest.class.getCanonicalName(); from(uri).to("mock:xyz"); web服务接收soap调用,但抛出异常,因为请求需要对wss进行处理 org.apache.cxf.binding.soap

我创建了一个web服务客户端,用ApacheCamel处理cxf soap web服务

String serviceUri = "cxf:http://localhost:10000/myservice?serviceClass=" + 
    MyRequest.class.getCanonicalName();

from(uri).to("mock:xyz");
web服务接收soap调用,但抛出异常,因为请求需要对wss进行处理

org.apache.cxf.binding.soap.SoapFault:MustUnderstand标头:[{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd}安全性]未被理解。

原因是,服务需要ws-security,这可以通过在请求时进行lloking来查看

<SOAP-ENV:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" SOAP-ENV:mustUnderstand="1">

我发现我需要实现一个拦截器来处理头属性

我的问题:

  • 如何添加拦截器来处理Camel Java DSL的头属性

  • 这是否足以消除SOAP故障

    • 你可以通过 cxfEndpointConfigurer选项@请参阅:

      (我使用Spring(它更简单)),但我想DSL URI应该是这样的:

      String serviceUri = "cxf:http://localhost:10000/myservice?serviceClass=" + 
      MyRequest.class.getCanonicalName() +
      "&cxfEndpointConfigurer="+ MyConfigurer.class.getCanonicalName();
      
      通过实现org.apache.camel.component.cxf.CxfEndpointConfigurer,您可以在configureServer方法中添加拦截器

      server.getEndpoint().getInInterceptors().add(new MyJAASLoginInterceptor());
      
      如果您使用JAAS(如JBOSS)在容器中运行Camel,您可以使用

      org.apache.cxf.interceptor.security.JAASLoginInterceptor
      
      使用所需的回调处理程序。 针对JBOSS用户验证WSS标头中的用户/密码的简单示例:

      public class MyJAASLoginInterceptor extends javax.security.auth.callback.JAASLoginInterceptor {
      
        @Override
        protected CallbackHandler getCallbackHandler(String name, String password) {
      
          return new org.apache.cxf.interceptor.security.NamePasswordCallbackHandler(name, password, "setCredential");
      
        }
      
      }
      
      不幸的是“&cxfEndpointConfigurer=“+MyConfigurer.class.getCanonicalName()”;无法工作,我收到错误消息“无法为属性:cxfEndpointConfigurer找到合适的setter,因为没有相同类型的setter方法:java.lang.String,也不可能进行类型转换:”pls。请阅读以下内容: