users@jersey.java.net

1)regaring testing http POST of restful webservices with multiple parameters and 2) restful file uploading

From: Jyothsna L <l.jyothsna_at_yahoo.com>
Date: Sat, 10 May 2008 23:04:22 -0700 (PDT)

Hi


I have two questions.

1) while testing the POST of restful web services, I always get a string content as parameter that needs to be filled while posting.
so , I am parsing the string based some delimiters like comma and then saving each element in database.
for example my database has email,name as its columns in one table.
so if my POST parameter : content has jyothsna_at_yahoo.com, jyothsna. I am parsing it into two elements jyothsna_at_yahoo.com(email) and jyothsna(name).
and then I am creating entries in the table.

I tried to add two parameters to postxml() instead of one. but, its not working properly.

so do you suggesting parsing one single parameter or is there any other good way to have multiple parameters.

my second question
2)

I need to upload an image file to the backend. I want to save the file on disk and its URL in the database.

I am using restful webservices and ejb module.

here the http PUT method definition.
Since, I will be uploading an image, i am consuming multipart/form-data.
I dont know how to handle the file. I have the struts and jersey plugins too. I am new to struts and a bit familiar with jersey(restful).

 @PUT
    @ConsumeMime("multipart/form-data")
    public void putXml(@PathParam("id")
    String id, MimeMultipart data ) {
        Images newImage= new Images();
        newImage.setImageURL(url);//just showing the methods available for Images object. this statement is not completely correct
                                                                   I need to save the image file on disk and set its location in the imageresource.
        newImage.setImagename(name); // 'name' needs to be extracted from the MimeMultipart or whatever..just wanted to show available methods for Images object.
        lookupImagesFacade().create(newImage);
    }

My question is : how will i be able to save the file on disk and its url on database based on the template i have above. is the "MimeMultipart data " correct in the above code. which package has this "MimeMultipart"( I see there are different kinds of packages java mail etc.)

or is there any other good way to do file uploading in restful using jersey.

thanks,
Jyothsna



      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ