2012-10-10 114 views
1

我是Apache Camel和CXF的新手,我试图创建一个查询需要基本认证的远程WS并指定SoapAction头的路由。我用spring-ws组件实现了它,但是我想知道是否可以对cxf组件做同样的事情。骆驼CXF生产者基本认证

我现在的配置是:

RouteBuilder

from("file:src/test/resources/data?noop=true") 
    .to("xquery:transform/search.xquery") 
    .to("cxf:-----") 
    .to("log:TestApp"); 

我读过一些有关管道,但我不知道怎么在我目前的骆驼上下文配置。

CamelContext
<camel:camelContext xmlns="http://camel.apache.org/schema/spring"> 
    <package>my.package</package> 
</camel:camelContext> 

在此先感谢

回答

2

您可以用骆驼HTTP组件实现这一点:

http://server.com?authMethod=Basic&authUsername=user&authPassword=password

不过,你可能想利用的功能, CXF提供。

您可以设置一个CXF豆骆驼,然后设置一个HTTP管道提供基本身份验证:

http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-BasicAuthentication

<conduit name="https://localhost:.*"" 
    xmlns:sec="http://cxf.apache.org/configuration/security" 
    xmlns="http://cxf.apache.org/transports/http/configuration"> 
    <authorization> 
     <sec:UserName>myuser</sec:UserName> 
     <sec:Password>mypasswd</sec:Password> 
     <sec:AuthorizationType>Basic</sec:AuthorizationType> 
    </authorization> 
</conduit> 

使用HTTP管道链接到骆驼CXF豆的“名称'参数。您可以像上面那样将其设置为一个网址,或者查看文档以将其设置为与您的服务匹配的URI。

感谢, 约杰什

+0

感谢约杰什我会尝试一下尽快 –