Webservice contains:
ResultObj resultObj = getDocCountAction(RequestObj requestObj);
where:
ResultObj and RequestObj contain "Long count" attribute.
so, the webservis method gets count on input and returns count on output (I know - it's nonsense :)
I want for "client.invoke("getDocCountAction", requestObj);" to return value to responseObj. By default it returns Object[].
// webservice client from 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 and setter method for count attribute and 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 now I have problem. I know I must invoke webservice method and define and acces responseObj. How to "bind" result of webmethod with responseObj?
// accessing response object and getter method for 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 to webmethod
Object[] result = client.invoke("getCountAction", requestObj);
heh :)
For others with this kind of problem:
// webservice client from 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 and setter method for count attribute and 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 to 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.