You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Alexandre Gazola <al...@yahoo.com.br> on 2007/11/29 23:46:53 UTC
Acessing a WS with CXF by using a DynamicClient...
Hello guys,
I´m starting to develop with webservices... I would like to start with a simple call to a WS, given that I have the WSDL url. To relieve me from generating service interfaces, I´m trying to use a DynamicClient (as shown in http://xfire.codehaus.org/Dynamic+Client ). But I downloaded CXF instead of XFire.
After download CXF, I created an Eclipse project and put all jars of CXF/lib in my project´s classpath. Then I tried to make the same code work, but I didn´t succeed (actually, I changed the class Client to ClientImpl, since Client is a interface in CXF).
public static void main(String[] args) throws Exception { URL url = new URL("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"); Client client = new ClientImpl(url); Object[] results = client.invoke("ConversionRate", new Object[] { "BRL", "UGX" }); // Service returns a double of the currency conversion rate. System.out.println((Double) results[0]); }
But when I execute this code I get the NullPointerException bellow. Can anybody help?
29/11/2007 18:39:29 org.apache.cxf.configuration.spring.ConfigurerImpl <init>
INFO: Could not find the configuration file cxf.xml on the classpath.
29/11/2007 18:39:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
INFO: Interceptor has thrown exception, unwinding now
java.lang.NullPointerException
at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeToOutputStream(AbstractOutDatabindingInterceptor.java:110)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:67)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:6
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:200)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:186)
at mypackage.test.main(MyTestClass.java:4)
Exception in thread "main" java.lang.NullPointerException
at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeToOutputStream(AbstractOutDatabindingInterceptor.java:110)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:67)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:6
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:200)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:186)
at mypackage.test.main(MyTestClass.java:4)
Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
http://br.mail.yahoo.com/
Re: Acessing a WS with CXF by using a DynamicClient...
Posted by tog <gu...@gmail.com>.
Hi
You can have a look to GroovyWS, it is using the dynamic client underneath ;-)
Cheers
Guillaume
On Nov 30, 2007 6:46 AM, Alexandre Gazola <al...@yahoo.com.br> wrote:
> Hello guys,
>
> I´m starting to develop with webservices... I would like to start with a simple call to a WS, given that I have the WSDL url. To relieve me from generating service interfaces, I´m trying to use a DynamicClient (as shown in http://xfire.codehaus.org/Dynamic+Client ). But I downloaded CXF instead of XFire.
>
> After download CXF, I created an Eclipse project and put all jars of CXF/lib in my project´s classpath. Then I tried to make the same code work, but I didn´t succeed (actually, I changed the class Client to ClientImpl, since Client is a interface in CXF).
>
> public static void main(String[] args) throws Exception { URL url = new URL("http://www.webservicex.net/CurrencyConvertor.asmx?WSDL"); Client client = new ClientImpl(url); Object[] results = client.invoke("ConversionRate", new Object[] { "BRL", "UGX" }); // Service returns a double of the currency conversion rate. System.out.println((Double) results[0]); }
>
> But when I execute this code I get the NullPointerException bellow. Can anybody help?
>
> 29/11/2007 18:39:29 org.apache.cxf.configuration.spring.ConfigurerImpl <init>
>
> INFO: Could not find the configuration file cxf.xml on the classpath.
>
> 29/11/2007 18:39:33 org.apache.cxf.phase.PhaseInterceptorChain doIntercept
>
> INFO: Interceptor has thrown exception, unwinding now
>
> java.lang.NullPointerException
>
> at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeToOutputStream(AbstractOutDatabindingInterceptor.java:110)
>
> at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:67)
>
> at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:6
>
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:200)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:186)
>
> at mypackage.test.main(MyTestClass.java:4)
>
> Exception in thread "main" java.lang.NullPointerException
>
> at
> org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeToOutputStream(AbstractOutDatabindingInterceptor.java:110)
>
> at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:67)
>
> at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:6
>
> at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:207)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:254)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:205)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:180)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:200)
>
> at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:186)
>
> at mypackage.test.main(MyTestClass.java:4)
>
>
>
>
>
> Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
> http://br.mail.yahoo.com/
--
Best Regards
Guillaume
http://cheztog.blogspot.com
Re: Acessing a WS with CXF by using a DynamicClient...
Posted by Glen Mazza <gl...@verizon.net>.
Well, looking at the Dynamic Client you would appear to be losing your
compile-time checks at the least. But it was the premise for which he
was trying to use DynamicClient to begin with ("To relieve me from
generating service interfaces") that I was questioning. I got the
impression that the user had not much experience with wsdl2java, and as
a result, was overestimating the tool's difficulty.
Glen
Am Samstag, den 01.12.2007, 11:23 +0800 schrieb tog:
> Btw, conceptually it is the same: one is embedded in the other. Am I wrong ?
>
> On Dec 1, 2007 8:29 AM, Glen Mazza <gl...@verizon.net> wrote:
> > Am Donnerstag, den 29.11.2007, 14:46 -0800 schrieb Alexandre Gazola:
> > > Hello guys,
> > >
> > > I´m starting to develop with webservices... I would like to start with
> > > a simple call to a WS, given that I have the WSDL url. To relieve me
> > > from generating service interfaces, I´m trying to use a DynamicClient
> > > (as shown in http://xfire.codehaus.org/Dynamic+Client ).
> >
> > Really? If you already have the WSDL, code generation is *much* easier
> > (and more accurate) than Dynamic Clients IMO. Here are Ant[1] and
> > Maven[2] based options for you.
> >
> > HTH,
> > Glen
> >
> > [1] http://www.jroller.com/gmazza/date/20070929
> > [2] http://www.jroller.com/gmazza/date/20071129
> >
> >
> >
> >
>
>
>
Re: Acessing a WS with CXF by using a DynamicClient...
Posted by tog <gu...@gmail.com>.
Btw, conceptually it is the same: one is embedded in the other. Am I wrong ?
On Dec 1, 2007 8:29 AM, Glen Mazza <gl...@verizon.net> wrote:
> Am Donnerstag, den 29.11.2007, 14:46 -0800 schrieb Alexandre Gazola:
> > Hello guys,
> >
> > I´m starting to develop with webservices... I would like to start with
> > a simple call to a WS, given that I have the WSDL url. To relieve me
> > from generating service interfaces, I´m trying to use a DynamicClient
> > (as shown in http://xfire.codehaus.org/Dynamic+Client ).
>
> Really? If you already have the WSDL, code generation is *much* easier
> (and more accurate) than Dynamic Clients IMO. Here are Ant[1] and
> Maven[2] based options for you.
>
> HTH,
> Glen
>
> [1] http://www.jroller.com/gmazza/date/20070929
> [2] http://www.jroller.com/gmazza/date/20071129
>
>
>
>
--
Best Regards
Guillaume
http://cheztog.blogspot.com
Re: Acessing a WS with CXF by using a DynamicClient...
Posted by Glen Mazza <gl...@verizon.net>.
Am Donnerstag, den 29.11.2007, 14:46 -0800 schrieb Alexandre Gazola:
> Hello guys,
>
> I´m starting to develop with webservices... I would like to start with
> a simple call to a WS, given that I have the WSDL url. To relieve me
> from generating service interfaces, I´m trying to use a DynamicClient
> (as shown in http://xfire.codehaus.org/Dynamic+Client ).
Really? If you already have the WSDL, code generation is *much* easier
(and more accurate) than Dynamic Clients IMO. Here are Ant[1] and
Maven[2] based options for you.
HTH,
Glen
[1] http://www.jroller.com/gmazza/date/20070929
[2] http://www.jroller.com/gmazza/date/20071129