You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Sagi Mann <sa...@gmail.com> on 2008/10/09 00:16:44 UTC

Re: Basic authentication as a client

Hi, I've got a similar problem: I'm trying to do this via the
<http:authentication> config, but it seems that only by using the code
version am I able to authenticate to the web service... I don't want to use
code - I want to use the external cxf.xml config and it simply does not
work.

Here is my secure_cxf.xml:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:sec="http://cxf.apache.org/configuration/security"
       xmlns:http="http://cxf.apache.org/transports/http/configuration"
       xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
       xsi:schemaLocation="
       http://cxf.apache.org/configuration/security
       http://cxf.apache.org/schemas/configuration/security.xsd
       http://cxf.apache.org/transports/http/configuration
       http://cxf.apache.org/schemas/configuration/http-conf.xsd
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">

    <http:conduit name="{http://ws}HelloPort.http-conduit">
        <http:authorization>           
            <sec:UserName>tester1</sec:UserName>      
            <sec:Password>test</sec:Password>
        </http:authorization>
    </http:conduit>
</beans> 


Here is my client code:
        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = null;
        busFile =
Hello_HelloImplPort_Client.class.getResource("/secure_cxf.xml");
        Bus bus = bf.createBus(busFile.toString());
        bf.setDefaultBus(bus);
        cxf.client.HelloService ss = new HelloService(wsdlURL,
SERVICE_NAME);
        cxf.client.Hello port = ss.getHelloPort();
        // the authentication works only if I uncomment the following lines.
It does not seems to take the credentials from the .xml:
        //BindingProvider bp = (BindingProvider)port;
        //bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
"tester1");
        //bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
"test");


By the way, I also tried the following alternative .xml, with the same code
- same results:

<beans xmlns="http://www.springframework.org/schema/beans" 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:jaxws="http://cxf.apache.org/jaxws" 
        xmlns:soap="http://cxf.apache.org/bindings/soap" 
        xsi:schemaLocation=" 
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 

        <jaxws:client id="client1" 
                serviceClass="cxf.client.Hello" 
                address="http://mann2:8080/param-tester-ws/HelloService"
                username="tester1" password="test"/> 

</beans> 

any ideas how to define the credentials in the xml rather than code?
thanks.
-- 
View this message in context: http://www.nabble.com/Basic-authentication-as-a-client-tp16819907p19888674.html
Sent from the cxf-user mailing list archive at Nabble.com.