File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Rest Response adding extra characters

 
David McWilliams
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have written a very basic Restful web service using Jersey and Mule 2.2.1. The service returns the string 'hello' when a GET is sent to the service.



When I use a poster application like Google Poster to send a GET request, I get the string 'hello' back but when I use a simple PHP client to call the service, I get the following:

5
Hello
0

It seems the the service is adding the length of the string. I have the string to '1234567890' and it added a 'b' to the response (hex?)

I have used Fiddler to check the Http Response and I can see the extra characters.

Does anyone know why this is happening?

David
 
David McWilliams
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that the extra characters is not content length. I tested it with more characters.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you saying:


when you are obviously not returning JSON but text.

Bill
 
David McWilliams
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
William Brogden wrote:Why are you saying:


when you are obviously not returning JSON but text.

Bill


I will be returning a JSON object. I have removed the JSON to simplify the example. Extra characters are still sent when I change to:
@Produces("text/plain").

I believe the issue is to do with encoding. The response is sent with Chunked Transfer Encoding. I will need to decode this but no idea how.
 
David McWilliams
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got my PHP client to decode the encode response from my service. I did not write the client but apparently there is some library you can you.
 
Patrick Yeh
Greenhorn
Posts: 1
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic