Hi,
 I've just started using Restlet 2.0.7. I'm trying to build a REST API. But I'm 
facing problem with declaring a method which accepts POST request which has 
content type - application/xml.
Following is my method which processes POST request:
------------------
@Post
public Representation create(Representation r)
{
        Representation rep = null;
        try{ 
 if(MediaType.APPLICATION_XML.equals(r.getMediaType()))
 {                              
        System.out.println("XML received of size:" + r.getSize() + ",and 
available size: " + r.getAvailableSize() + ", and content: " + r.getText() + ", 
byteChannel: " + r.getChannel() + ", inputStream: " + r.getStream());
        rep = new 
StringRepresentation(Configuration.parseXml(r.getStream()),MediaType.APPLICATION_XML);
                        
 }
 else
 {
    setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
    rep = new StringRepresentation("Invalid Data in POST. XML expected.", 
MediaType.TEXT_PLAIN);
 }
return rep;
}
-------------------

Now the problem is when I test this API using Firefox REST plugin with the 
following XML data in the body:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<config>
<system name="something"></system>
</config>

I get the following output:

XML received of size:125,and available size: 125, and content: null, 
byteChannel: null, inputStream: null.

It seems that though the method is getting the size of the POST data correctly, 
its not able to get the content(String or InputStream) from the Representation.

Am I missing something here??
How do I get the XML content which is sent to this REST API??

Thanks,
Soumik

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2738272

Reply via email to