Hello Anant,
you'd better send an entity with a POST method, not a GET.
You have to change your request like this, on client side:
Request request = new Request(Method.POST, myServiceUrl);
best regards,
Thierry Boileau
Hi all,
I am using Restlet 1.0.8. I am running my application in servlet container of
JBoss-4.2.2.GA. My service will get some parameters and return list of Persons
from my database. I want to send those parameters in XML format.
Lets my service wants following data in GET Request from client.
<params>
<start-date>start date string</start-date>
<end-date>end date string</end-date>
<country>country name</country>
</params>
In response of this request my service will search my database based on these
parameters and send back a response like..
<person-list>
<player>
<first-name>Sachin</first-name>
<last-name>Tendulkar</last-name>
<matches-played>400</matches-played>
</player>
<player>
<first-name>Rahul</first-name>
<last-name>Dravid</last-name>
<matches-played>300</matches-played>
</player>
.
.
</person-list>
When I try to send DomRepresentation from client to server its giving error
"[STDERR] [Fatal Error] :-1:-1: Premature end of file." in server side.
some code that I have used to send it
Request request = new Request(Method.GET, myServiceUrl);
DomRepresentation rep = new DomRepresentation(MediaType.TEXT_XML, paramXml);
// I tried here MediaType.TEXT_XML, MediaType.APPLICATION_XML,
//MediaType.PLAIN_TEXT but no luck
request.setEntity(rep);
Client client = new Client(Protocol.HTTP);
Response response = client.handle(request);
Its giving response code 500 internal server error.
server side I have written like
DomRepresentation dom = request.getEntityAsDom();
if(dom != null)
{
try
{
dom.write(System.out);
}
catch(IOException e)
{
logger.error("IO exception while writing dom to system console");
}
}
its printing [STDERR] [Fatal Error] :-1:-1: Premature end of file.
IO exception while writing dom to system console
my document was well formed that I checked in client side. Not sure whether we
can send entity in GET request.
Any type of help will be appreciated.
Thanks in advance.
--Anant--