Originally posted by steve francisco:
I am thinking about publishing a web services that generates a .csv or .txt or .xls format file given some input. When a client passes some input data to this web services, it generates a .csv or .txt file and return it to the client. As a total novice to this subject, I just herad that web services returns soap xml to client. So can it returns the file in those formats and how ?
1. Write a plain old
java class with a method that creates a file based on input parameters and returns either an output file name or output stream.
2.
Test the helper class with your
servlet (servlet is the client of the helper).
3. Convert the helper class into a java web service by changing file extension from .java to .jws.
4. Put the .jws file into Axis web app root directory. Axis app will generate a WSDL file for the jws at request time,
assuming that you have installed apache axis and deployed sample app axis.war to your server's deploy directory. 5. Convert WSDL to java to use the helper web service in your servlet like below:
java org.apache.axis.wsdl.WSDL2Java --verbose
http://server.com/axis/HelperClassName.jws?wsdl Make sure that you have axis.jar file in your classpath while executing this command, as that is where org.apache.axis.wsdl.WSDL2Java resides.
You will find a number of .java files generated in a subdirectory named your helper. These are the stub files or wrapper classes. You need to compile generated classes and put in your class directory of your application.
6. In your servlet, create an instance of web service locator class generated in the previous step. The exact location of the service will be transparent to the client, the servlet in this case. Using the locator, create a helper web service instance and call necessary method on it.
Good luck!
[ April 04, 2005: Message edited by: Heonkoo Lee ]