You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by tog <gu...@gmail.com> on 2010/05/19 19:00:38 UTC
Dynamic client
Hi
I am using the dynamic client as describe in the book Apache CXF Web Service
Development and got the following problem when invoking the method.
Here is a snapshot of the code ...
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance()
Client client = dcf.createClient("
https://myabell.net:443/webservicepublic.asmx?WSDL")
Object getInfo =
Thread.currentThread().getContextClassLoader().loadClass("net.myabell.GetInfoContentFromProduct").newInstance()
Method m1 = getInfo.getClass().getMethod("setProductID" , String.class)
Method m2 = getInfo.getClass().getMethod("setType" , String.class)
Method m3 = getInfo.getClass().getMethod("setLanguageID", String.class)
Method m4 = getInfo.getClass().getMethod("setLocale" , String.class)
m1.invoke(getInfo, "10")
m2.invoke(getInfo, "0")
m3.invoke(getInfo, "2")
m4.invoke(getInfo, "en-gb")
// This is not working
//Object[] response = client.invoke("GetInfoContentFromProduct", getInfo)
// This is working
Object[] response = client.invoke("GetInfoContentFromProduct", "10", "0",
"2", "en-gb")
println "Response is ${response[0]}"
It actually seems that the invocation has to be made not using the object
initialized by reflection (is that called wrapped mode? ) (as stated in the
book).
Is there a way to diagrammatically determine which is type of call has to be
used ?
Guillaume
Re: Dynamic client
Posted by Daniel Kulp <dk...@apache.org>.
You kind of have two options...
1) Call client.getEndpoint().getBinding().getBindingInfo() and walk through
the operations to find the one you are invoking and call isUnwrapped() to
figure out if it wants the wrapper or not.
2) Call client.invokeWrapped(....) instead of client.invoke(..);
The invokeWrapped will always use the wrapper objects.
Dan
On Wednesday 19 May 2010 1:00:38 pm tog wrote:
> Hi
>
> I am using the dynamic client as describe in the book Apache CXF Web
> Service Development and got the following problem when invoking the
> method. Here is a snapshot of the code ...
>
> JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance()
>
> Client client = dcf.createClient("
> https://myabell.net:443/webservicepublic.asmx?WSDL")
>
> Object getInfo =
> Thread.currentThread().getContextClassLoader().loadClass("net.myabell.GetIn
> foContentFromProduct").newInstance() Method m1 =
> getInfo.getClass().getMethod("setProductID" , String.class) Method m2 =
> getInfo.getClass().getMethod("setType" , String.class) Method m3 =
> getInfo.getClass().getMethod("setLanguageID", String.class) Method m4 =
> getInfo.getClass().getMethod("setLocale" , String.class)
>
> m1.invoke(getInfo, "10")
> m2.invoke(getInfo, "0")
> m3.invoke(getInfo, "2")
> m4.invoke(getInfo, "en-gb")
>
> // This is not working
> //Object[] response = client.invoke("GetInfoContentFromProduct", getInfo)
>
> // This is working
> Object[] response = client.invoke("GetInfoContentFromProduct", "10", "0",
> "2", "en-gb")
>
> println "Response is ${response[0]}"
>
> It actually seems that the invocation has to be made not using the object
> initialized by reflection (is that called wrapped mode? ) (as stated in the
> book).
>
> Is there a way to diagrammatically determine which is type of call has to
> be used ?
>
> Guillaume
--
Daniel Kulp
dkulp@apache.org
http://dankulp.com/blog