Ultimately this is only a problem because you are attempting to use Web services as a Java RPC mechanism. XML Schema has no problem accommodating optional elements in a document schema.
Returning List<Object> will possibly give your clients headaches.
Non Java-based clients have no clue what a List<Object> is. They are going to have to deal with some awful generated XML representation that is specific to the Java2WSDL tool that generated it.
Pre Java 5 SE based clients have not clue what a List<Object> is. If they are lucky their WSDL2Java may give them an array of Objects.
Even Java 5 based clients may not end up with a List<Object> if they rely solely on the published WSDL. Sure Java EE clients may use mapping files to map it back to the List<Object>. However that is information that is outside of the WSDL and the mapping option isn't necessarily available to plain Java clients.
Production Web Services aren't simply a matter of exposing some Java methods.
hello and thanks for the fast reply well im coming from corba background and im beginner in web services and every day im learning something new like for me one of the main differences that web service can't return value by reference so i need always to return my results in some kind of list of objects , don't worry about the return list<Object> the client in my case will know what the service will return . also the difficulty to deal with complex objects when sending them .. you have to think in different way in adapters and converter between your application data types and the ones web services understand this is not easy when you dealing with legacy application that needs to implement web services ... so where can i understand it better or there is easy solutions for this kind of jobs ?
Joined: Aug 19, 2005
Originally posted by Meir Yan: well im coming from corba background
If I recollect correctly from my very brief exposure to CORBA, "IDL first" (i.e. design interface first) is considered a best practice.
Analogous to that "WSDL first" is considered a best practice with Web Services, i.e. :
Figure out what raw data you need to exchange to get the job done.
Design an "XML Application" (an XML Schema for the request and response documents) to structure this data in XML - or even better use an existing XML Application.
Use the XML Request and Response document definitions in a WSDL to define your Web service interface.
Use WSDL2Java to generate your server stubs and the supporting Java data classes.
hello again i started to read the links you gave me very informative indeed onoter thing i need to learn more about the uses of jaxws and jaxb is there any good book i can buy about this subject ?
Joined: Aug 19, 2005
Originally posted by Meir Yan: another thing i need to learn more about the uses of jaxws and jaxb is there any good book i can buy about this subject ?
Its too recent and not that widely used yet. Its only going to be pervasive once most of the vendors comply with Java EE 5 or development with Java 6 SE is more commonplace (Java 6 is still in beta and many places aren't using Java 5 yet).
Currently the best source of information is the java web services development pack (JWSDP) 2.0 and its tutorial