XML & Web services: How to create a Web Serivce which return value is java object?

  1. For example, I want to return File object from a method, how to consumer it in client? I try to automatically generate the client program, but fail to call the service. Any special steps for this kind of web service?
  2. You can use XStream to convert your object as XML, and then send to your clients, is required to have all classes converted in both clients and webservice.
  3. Well with Axis2 you can do something like following import javax.activation.DataHandler; import javax.activation.FileDataSource; public class MyWebService { public DataHandler getData(String fileNama) { return new DataHandler(new FileDataSource(fileNama)); } } You can deploy the above service as a POJO or as a service archieve file. In the client side you can either generate code or you can hand write the client.
  4. Hi, You have to write a WSDL which defines complex dataType. For example you can define like the following using wsdl:types tag If you are using Axis, and if you do a wsdl2java, Axis will generate a class which will have all the parameters defined in the element tag along with serializers and deserializers in the class itself. Then you can use the class as a normal POJO and you can transfer this object between the sockets. You can not define a plain java class and use it as such in webservice. you have to define it in the wsdl and do a AXIS wsdl2java whih will give you serializers and deserializers then you can use it. If you wanna use SOAP attachments, then you have to follow a different process. First try with defining a complex datatype in wsdl, and wsdl2java , then use it with SOAP calls. With Best Regards, Job Jebaraj Lead Developer.