You can use the Java Beans
XML Encoder/Decoder API to produce a XML file which represents your Java Object, if it meets the Java Beans specification. This is similar to normal Serilization with
java.io.Serializable.
But please note that your class should adhere to Java Beans requirements. XML Encoder/Decoder API can be found at
java.beans.*;
Other option is to use a JAXB Implementation. But in this case, you will have to write a XSD (XML Schema Definition) and use the JAXB Binding Compiler to build the classes from the XSD.
This article about JAXB 2.0 gives the basics of JAXB 2.0.
Once you got the XML from the object, you can easily return the XML from your Web Service method.
(You will need the class file at the client-side to De-Serialize the XML).
[ October 07, 2007: Message edited by: Yohan Liyanage ]