We’ve recently moved some rails applications from Glassfish V2 (using warble) to Glassfish V3 running natively. For the most part, this has been remarkably painless and things have “just worked”.
Code related to processing REST web services has not just worked and took quite a bit of investigation to fix so I’m documenting it here.
We process REST calls in rails by calling request.raw_post() on a POST or PUT request to return the XML payload and then doing some processing on it. In Glassfish V2 and every other ruby implementation I tried, this just works fine. In Glassfish V3, raw_post() was sometimes returning nil rather than the actual content of the http request.
After much investigation, we determined that if the incoming POST or PUT has a content type of “text/xml” then raw_post() will return the correct content. If it has a different content type then raw_post() will return nil. In our case we weren’t explicitly setting the content type and so it was failing.
How would you fix this if the content type is being sent in via an external vendor POST?
It completely depends what technology you’re using to generate your POST. There’s always some way to set the Content-Type header.