Hi Friends! i am implimenting a java service as an web service using axis. I m using wsdl2java to generate stubs and skeltons. The problem i m facing is returning collections from the service. I did my R&D and come to the solution that i must return arrays instead of List etc. That solution is correct and its works but i was wondering that is there any way to impliment list as return type in wsdl? so that it could work for atleast java clients. Please share ....
If you use data types not defined in XML Schema (which is what WSDL uses to describe datatypes), you're giving some of the benefits of type checking, in addition to cross-platform compatibility. Why would you want to do that?
Ping & DNS - updated with new look and Ping home screen widget
Given the ease with which you can convert between List and array representations, there is no good reason to transmit Lists in web services. Think about it - most clients are going to use a List like an array anyway.
Originally posted by Muhammad Ahsan Jamshaid: i just want to know that is there any mechnisim by which we can impliment collection returns?
Your point of view is a Java-centric point of view; web services don't care about Java or any other host language they are implemented in (as Ulf has already pointed out). SOAP web services use the XML Schema sequence where you use collections in Java. However the simplest Java type that can represent a sequence is in fact the array (it is the lowest common denominator) - so arrays were chosen to represent a sequence. And as Bill has already pointed out there are plenty of convenience functions to turn an array into a List (Arrays.asList) and a List into an array (List.toArray) which makes implementation of a wrapper that consumes a produces Lists fairly simple.
Some tools (e.g. JAXB) may provide you with a facility for coercing those XML Schema sequences into a collection of your choice instead of an array. However that choice is captured either in the tool's binding file or in some Java code annotation but not in the WSDL.
That being said, JAX-WS supports inline-customizations as shown in AddNumbers.wsdl. However this is no longer a WSDL in the conventional sense as it contains information that can only be used by some clients - and even those that can use it may want to ignore it. I think the inline-customization use case is one where you make a copy of the original WSDL and then customize it for your own purpose before you perform any WSDL-to-Java code generation. [ February 12, 2008: Message edited by: Peer Reynders ]