views:

32

answers:

2

Hi, I have been given an api which states that it requires:

URL http://server/a/messages.xml

HTTP Method POST (even though the soapui example  of this call uses PUT)

Input XML
<?xml version="1.0" encoding="UTF-8"?>
<message>
  <content>Post message</content>
  <parent-id nil="true"></parent-id>
</message>

Now i have tried to use the following code (where request body is the xml as seen above with no \r\n in)

PutMethod putMethod = null;
putMethod = new PutMethod(url); 
putMethod.setQueryString(requestParams);
RequestEntity rEnt = new StringRequestEntity(requestBody,"text/xml",null);
putMethod.setRequestEntity(rEnt);
statusCode = client.executeMethod(putMethod);

I keep getting back 500 from the status, I know it works as the soapui example (put) works.

Any ideas what small thing I am missing. (I am going to try post too)

Thanks

+1  A: 

If you get back a 500 status code, it's a server error. In theory, bad requests (even badly formed) should make the server return a 4xx status code, not make it return a status code indicating an internal fault on its side. If this server returns a 500 status code for a request you make, it indicates a problem on the server side.

Bruno
A: 

Well it turned out that a POST did work, even though the SOAPUI request was a PUT.. Most odd i guess i don't understand something..

Thanks for the help

joe90