Please check out the CXF http client configuer[1], and add these in your beans.xml

<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";

xmlns:http-conf="http://cxf.apache.org/transports/http/configuration";
       xmlns:security="http://cxf.apache.org/configuration/security";

xsi:schemaLocation="http://cxf.apache.org/transports/http/configuration

http://cxf.apache.org/schemas/configuration/http-conf.xsd
                           http://cxf.apache.org/configuration/security

http://cxf.apache.org/schemas/configuration/security.xsd
                           http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans.xsd";>

  <http-conf:conduit name="*.http-conduit">
    <http-conf:authorization>
       <security:UserName="XXXX" />
       <security:Password="XXXX" />
    </http-conf:authorization>
  </http-conf:conduit>
</beans>

[1]http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html

Willem

On 9/30/10 7:43 PM, xiaotao183 wrote:

Hi,

I am looking for a way that I could possibly inject the http basic
authentication credential to cxf endpoint to invoke a remote ws which has
http basic authentication enabled.

Here is the beans.xml

<osgi:camelContext xmlns="http://camel.apache.org/schema/spring";>
                <routeBuilder ref="myTransform"/>
        </osgi:camelContext>

        <bean id="myTransform"
class="org.apache.servicemix.examples.camel.MyRouteBuilder">
        </bean>

        <cxf:cxfEndpoint
                id="thebean"
                wsdlURL="greeting-wsdl.xml"
                serviceClass="tutorial.hanbo.webservice.Greeting"
                address="http://localhost:8080/greeting";>
        </cxf:cxfEndpoint>


Here is the actual camel route

from("timer://javaTimer?fixedRate=true&period=2000").log(LoggingLevel.INFO,
"Sending a ping!")
                 .process(new Processor()
                 {

                     public void process(Exchange ex) throws Exception
                     {

                         ex.getIn().setHeader(CxfConstants.OPERATION_NAME,
"greetClient");

                         MessageContentsList list = new
MessageContentsList();
                         list.add(0, "hi");
                         ex.getIn().setBody(list);
                     }
                 }).to("cxf:bean:thebean").process(new Processor()
                 {

                     public void process(Exchange ex) throws Exception
                     {
                         System.out.println(ex);
                     }
                 });


Thanks


--
Willem
----------------------------------
Open Source Integration: http://www.fusesource.com
Blog:    http://willemjiang.blogspot.com (English)
         http://jnn.javaeye.com (Chinese)
Twitter: http://twitter.com/willemjiang

Reply via email to