web services - Dynamic webservice client and java reflection -


webservice contains:

resultobj resultobj = getdoccountaction(requestobj requestobj); 

where:

resultobj , requestobj contain "long count" attribute. 

so, webservis method gets count on input , returns count on output (i know - it's nonsense :)

i want "client.invoke("getdoccountaction", requestobj);" return value responseobj. default returns object[].

// webservice client remote wsdl string wsdlurl = "http://localhost:8080/test/test.wsdl" classloader loader = thread.currentthread().getcontextclassloader(); dynamicclientfactory factory = dynamicclientfactory.newinstance(); client client = factory.createclient(wsdlurl, loader);  // accessing request object , setter method count attribute , setting 666 value object requestobj = thread.currentthread().getcontextclassloader().loadclass("pl.kago.stuff.requestobj").newinstance(); method setcount = requestobj.getclass().getmethod("setcount", long.class); setcount.invoke(requestobj, 666); 

and have problem. know must invoke webservice method , define , acces responseobj. how "bind" result of webmethod responseobj?

// accessing response object , getter method count attribute object responseobj = thread.currentthread().getcontextclassloader() .loadclass("pl.kago.stuff.responseobj").newinstance(); method getcount = responseobj.getclass().getmethod("getcount", long.class); client.invoke("getcount", responseobj); 

below access webmethod

object[] result = client.invoke("getcountaction", requestobj); 

heh :)

for others kind of problem:

// webservice client remote wsdl string wsdlurl = "http://localhost:8080/test/test.wsdl" classloader loader = thread.currentthread().getcontextclassloader(); dynamicclientfactory factory = dynamicclientfactory.newinstance(); client client = factory.createclient(wsdlurl, loader);  // accessing request object , setter method count attribute , setting 666 value object requestobj = thread.currentthread().getcontextclassloader().loadclass("pl.kago.stuff.requestobj").newinstance(); method setcount = requestobj.getclass().getmethod("setcount", long.class); setcount.invoke(requestobj, 666);  // "binding" new result object webmethod result object responseobj = thread.currentthread().getcontextclassloader() .loadclass("pl.kago.stuff.responseobj").newinstance(); responseobj = client.invoke("getcountaction", requestobj);  // getting count value method getcount = responseobj .getclass().getmethod("getcount"); object count = getcount.invoke(responseobj); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -