You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Cameron Taggart <ca...@gmail.com> on 2007/01/23 03:08:37 UTC
Simple JAX-WS Client like XFire?
I was surprised at how easy it was to create a JAX-WS service with
CXF. Is there a simple way to create a client? Something like
XFireClientFactoryBean as described at
http://xfire.codehaus.org/Spring+Remoting would be very nice.
Looking for something similar in CXF for this XFire code:
public static void main(String[] args) throws Exception {
GetterWebServiceInterface getter =
createClient(GetterWebServiceInterface.class,
"http://localhost:9000/getter?wsdl");
out.println("string: "+getter.getString());
out.println("int: "+getter.getInt());
}
public static <T> T createClient(Class<T> serviceInterface, String
wsdlUrl) throws Exception {
XFireClientFactoryBean cf = new XFireClientFactoryBean();
cf.setServiceClass(serviceInterface);
cf.setWsdlDocumentUrl(wsdlUrl);
cf.afterPropertiesSet();
return serviceInterface.cast(cf.getObject());
}
cheers,
Cameron
Re: Simple JAX-WS Client like XFire?
Posted by Cameron Taggart <ca...@gmail.com>.
Well it works! It can be made pretty later. All I had to do was pass
in the service url instead of the wsdl url and change my
createClient() to:
public static <T> T createClient(Class<T> serviceInterface, String serviceUrl){
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getClientFactoryBean().setServiceClass(serviceInterface);
factory.getClientFactoryBean().setAddress(serviceUrl);
return serviceInterface.cast(factory.create());
}
cheers,
Cameron
On 1/23/07, Dan Diephouse <da...@envoisolutions.com> wrote:
> Hi Cameron,
>
> I've ported some of the XFireClientFactoryBean to CXF so far. The API on it
> kind of sucks at the moment now though:
>
> JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
> factory.getClientFactoryBean().setServiceClass(
> MyServiceInterface.class);
> factory.getClientFactoryBean().setAddress("http://localhost/service
> ");
> MyServiceInterface client = (MyServiceInterface) factory.create();
>
> Obvoiusly I'd like to get rid of the unnecessary getClientFactoryBean calls
> at some point. But its a start :-)
>
> - Dan
>
> On 1/22/07, Cameron Taggart <ca...@gmail.com> wrote:
> >
> > I was surprised at how easy it was to create a JAX-WS service with
> > CXF. Is there a simple way to create a client? Something like
> > XFireClientFactoryBean as described at
> > http://xfire.codehaus.org/Spring+Remoting would be very nice.
> >
> > Looking for something similar in CXF for this XFire code:
> >
> > public static void main(String[] args) throws Exception {
> > GetterWebServiceInterface getter =
> > createClient(GetterWebServiceInterface.class,
> > "http://localhost:9000/getter?wsdl");
> > out.println("string: "+getter.getString());
> > out.println("int: "+getter.getInt());
> > }
> >
> > public static <T> T createClient(Class<T> serviceInterface, String
> > wsdlUrl) throws Exception {
> > XFireClientFactoryBean cf = new XFireClientFactoryBean();
> > cf.setServiceClass(serviceInterface);
> > cf.setWsdlDocumentUrl(wsdlUrl);
> > cf.afterPropertiesSet();
> > return serviceInterface.cast(cf.getObject());
> > }
> >
> > cheers,
> > Cameron
> >
>
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
>
>
Re: Simple JAX-WS Client like XFire?
Posted by Dan Diephouse <da...@envoisolutions.com>.
Hi Cameron,
I've ported some of the XFireClientFactoryBean to CXF so far. The API on it
kind of sucks at the moment now though:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.getClientFactoryBean().setServiceClass(
MyServiceInterface.class);
factory.getClientFactoryBean().setAddress("http://localhost/service
");
MyServiceInterface client = (MyServiceInterface) factory.create();
Obvoiusly I'd like to get rid of the unnecessary getClientFactoryBean calls
at some point. But its a start :-)
- Dan
On 1/22/07, Cameron Taggart <ca...@gmail.com> wrote:
>
> I was surprised at how easy it was to create a JAX-WS service with
> CXF. Is there a simple way to create a client? Something like
> XFireClientFactoryBean as described at
> http://xfire.codehaus.org/Spring+Remoting would be very nice.
>
> Looking for something similar in CXF for this XFire code:
>
> public static void main(String[] args) throws Exception {
> GetterWebServiceInterface getter =
> createClient(GetterWebServiceInterface.class,
> "http://localhost:9000/getter?wsdl");
> out.println("string: "+getter.getString());
> out.println("int: "+getter.getInt());
> }
>
> public static <T> T createClient(Class<T> serviceInterface, String
> wsdlUrl) throws Exception {
> XFireClientFactoryBean cf = new XFireClientFactoryBean();
> cf.setServiceClass(serviceInterface);
> cf.setWsdlDocumentUrl(wsdlUrl);
> cf.afterPropertiesSet();
> return serviceInterface.cast(cf.getObject());
> }
>
> cheers,
> Cameron
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog