How to support Complex type and call a compex webservice
jim.ma Nov 27, 2008 12:46 AMI know this is a old question I discussed with Stefano before. But I think it is necessary to post here to discuss it widely and get more thoughts before we do 1.0 release since we have this good place to have more feedback.
When use Wise to call a webserivce, we usually write the following code to do it :
1 WSDynamicClientFactory factory = WSDynamicClientFactory.getInstance(); 2 WSDynamicClient client = factory.getClient(wsdURL.toString()); 3 WSMethod method = client.getWSMethod("HelloService", "HelloWorldBeanPort", "echo"); 4 Map<String, Object> args = new java.util.HashMap<String, Object>(); 5 args.put("arg0", "from-wise-client"); 6 InvocationResult result = method.invoke(args, null);
You can notice WISE needs a parameter map before invoke the WSmethod. The parameter map key "arg0" should be same as the annotation WebParamter name value in the generated JAXWS class on fly . The parameter map value should also be an object and its type (Class) is the parameter type in the generated method on fly. It works for the simple case , for example , the web service method is doc-wrapped style and parameter type is simple java type . Because we can get the parameter name and value information from WSDL.
But if the Webservice method is doc-bare or rpc-literal style, you can not get these information directly and visibly from WSDL. There are complex rules defined in JAXWS spec to map WSDL's element to @WebParameter name value and webservice method signature. So it is difficult to tell what I should put in the parameter map (see above code snippet line 5). To better understanding the problem I described, let's took a look at the real world WSDL:
http://queue.amazonaws.com/doc/2008-01-01/QueueService.wsdl
It is difficult to compose this parameter map to call a web service defined in this wsdl. right ?
So far we use Smooks mapper [2] to transform the java object to the jaxws complex type objects to call the web service. But I believe it is also difficult to write the smooks configuration to do the mapping work, also it is difficult to find out the parameter name .
I know the wise tool we plan to create can help us generate the web service invocation code and give more informatoin we needed to create the paramter map. But before we do 1.0 relase, how do we plan to resolve this issue ?
One of the approach I can think is making WISE support jaxws classes generated beforehand instead of jaxws classes generated on fly. The generated jaxws classes can provide these information to write wise code to call a webservice.
Your thoughts and comments ? Thanks.
Jim Ma
[1] http://jcp.org/aboutJava/communityprocess/pfd/jsr224/index.html
[2]http://anonsvn.jboss.org/repos/labs/labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer_wise2