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:04:49 UTC

Re: Basic authentication with Spring configured client

could you pls post the init code of the client? I'm having the same issue,
I'm using CXF 2.1.2 (which should contain the fix) but I'm not sure how to
write the client code so it can properly use the cxf.xml.

My cxf xml is:

<?xml version="1.0" encoding="UTF-8"?> 
<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> 

Note that I use the PORT class (Hello) as the serviceClass above. I'm not
sure if this is correct, but if I try to use the HelloService generated
class, I get an exception "HelloService is not an interface".

My client code is:

        SpringBusFactory bf = new SpringBusFactory();
        URL busFile = null;
        if ("secure".equals(args[1])) {
            busFile =
Hello_HelloImplPort_Client.class.getResource("/JaxwsSecureClient.xml");
        } else if ("insecure".equals(args[1])) {
            busFile =
Hello_HelloImplPort_Client.class.getResource("/InsecureClient.xml");
        } else {
            System.out.println("arg1 needs to be either secure or
insecure");
            System.exit(1);
        }
        Bus bus = bf.createBus(busFile.toString());
        bf.setDefaultBus(bus);

        cxf.client.HelloService ss = new HelloService(wsdlURL,
SERVICE_NAME);
        cxf.client.Hello port = ss.getHelloPort();
        // invokations start here...

thanks...
-- 
View this message in context: http://www.nabble.com/Basic-authentication-with-Spring-configured-client-tp17500802p19888502.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: Basic authentication with Spring configured client

Posted by Daniel Kulp <dk...@apache.org>.
On Thursday 09 October 2008 1:46:34 pm Daniel Kulp wrote:
> Add a createdFromAPI="true" attribute to the jaxws:client element.
>
> With that attribute set to "true", the jaxws:client becomes a configuration
> element for a client that you create from the CXF (or jaxws) API's.
>
> Without that attribute, it's an actual spring object that you need to
> lookup from the context.

One more thing....  if you do the createdFromAPI, the "id" needs to change to 
the URL of the endpoint.   Basically, something like:

id="{http://the.name.space.com/blah}HelloPort" 
or similar so the runtime can match the config with the proxy you are 
creating.

Dan



>
> Dan
>
> On Wednesday 08 October 2008 6:04:49 pm Sagi Mann wrote:
> > could you pls post the init code of the client? I'm having the same
> > issue, I'm using CXF 2.1.2 (which should contain the fix) but I'm not
> > sure how to write the client code so it can properly use the cxf.xml.
> >
> > My cxf xml is:
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <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>
> >
> > Note that I use the PORT class (Hello) as the serviceClass above. I'm not
> > sure if this is correct, but if I try to use the HelloService generated
> > class, I get an exception "HelloService is not an interface".
> >
> > My client code is:
> >
> >         SpringBusFactory bf = new SpringBusFactory();
> >         URL busFile = null;
> >         if ("secure".equals(args[1])) {
> >             busFile =
> > Hello_HelloImplPort_Client.class.getResource("/JaxwsSecureClient.xml");
> >         } else if ("insecure".equals(args[1])) {
> >             busFile =
> > Hello_HelloImplPort_Client.class.getResource("/InsecureClient.xml");
> >         } else {
> >             System.out.println("arg1 needs to be either secure or
> > insecure");
> >             System.exit(1);
> >         }
> >         Bus bus = bf.createBus(busFile.toString());
> >         bf.setDefaultBus(bus);
> >
> >         cxf.client.HelloService ss = new HelloService(wsdlURL,
> > SERVICE_NAME);
> >         cxf.client.Hello port = ss.getHelloPort();
> >         // invokations start here...
> >
> > thanks...



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Basic authentication with Spring configured client

Posted by Daniel Kulp <dk...@apache.org>.
Add a createdFromAPI="true" attribute to the jaxws:client element.

With that attribute set to "true", the jaxws:client becomes a configuration 
element for a client that you create from the CXF (or jaxws) API's.  

Without that attribute, it's an actual spring object that you need to lookup 
from the context.

Dan


On Wednesday 08 October 2008 6:04:49 pm Sagi Mann wrote:
> could you pls post the init code of the client? I'm having the same issue,
> I'm using CXF 2.1.2 (which should contain the fix) but I'm not sure how to
> write the client code so it can properly use the cxf.xml.
>
> My cxf xml is:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <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>
>
> Note that I use the PORT class (Hello) as the serviceClass above. I'm not
> sure if this is correct, but if I try to use the HelloService generated
> class, I get an exception "HelloService is not an interface".
>
> My client code is:
>
>         SpringBusFactory bf = new SpringBusFactory();
>         URL busFile = null;
>         if ("secure".equals(args[1])) {
>             busFile =
> Hello_HelloImplPort_Client.class.getResource("/JaxwsSecureClient.xml");
>         } else if ("insecure".equals(args[1])) {
>             busFile =
> Hello_HelloImplPort_Client.class.getResource("/InsecureClient.xml");
>         } else {
>             System.out.println("arg1 needs to be either secure or
> insecure");
>             System.exit(1);
>         }
>         Bus bus = bf.createBus(busFile.toString());
>         bf.setDefaultBus(bus);
>
>         cxf.client.HelloService ss = new HelloService(wsdlURL,
> SERVICE_NAME);
>         cxf.client.Hello port = ss.getHelloPort();
>         // invokations start here...
>
> thanks...



-- 
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog

Re: Basic authentication with Spring configured client

Posted by Sagi Mann <sa...@gmail.com>.
I have an update: the following client code works:

        ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext(
                new String[]{"secure_cxf.xml"});
        
        Hello client = (Hello)context.getBean("client1");
        // invoke methods...

The only concern I have left is the fact that the user/pwd are clear-text in
the xml. Is there a way to define an external provider class that will
return them instead of writing them clear-text in the .xml? (I'm guessing
Spring can do something, but I'm no Spring expert...) or do I need to create
my own config layer on top of the xml?

thanks

-- 
View this message in context: http://www.nabble.com/Basic-authentication-with-Spring-configured-client-tp17500802p19889075.html
Sent from the cxf-user mailing list archive at Nabble.com.