title: Dynamic webservice client and java reflection
body: <p>Webservice contains:</p>
  
  <pre><code>ResultObj resultObj = getDocCountAction(RequestObj requestObj);
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>ResultObj and RequestObj contain "Long count" attribute.
  </code></pre>
  
  <p>so, the webservis method gets count on input and returns count on output (I know - it's nonsense :) </p>
  
  <p>I want for "client.invoke("getDocCountAction", requestObj);" to return value to responseObj. By default it returns Object[]. </p>
  
  <pre><code>// 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);
  </code></pre>
  
  <p>and now I have problem. I know I must invoke webservice method and define and acces responseObj. <strong>How to "bind" result of webmethod with responseObj?</strong></p>
  
  <pre><code>// 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);
  </code></pre>
  
  <p>below access to webmethod</p>
  
  <pre><code>Object[] result = client.invoke("getCountAction", requestObj);
  </code></pre>