Reading http request as IO in rails

Hi,
Here's what i'm trying to do my mobile phone app ( j2me) tries to
connect to the my rails application.
the j2me app opens a java.io.OutputStream here's the snippet
               hc = (HttpConnection) Connector.open(UPDATE_URL,
Connector.READ_WRITE);
               hc.setRequestMethod(HttpConnection.POST);
               hc.setRequestProperty("If-Modified-Since", "29 Oct
1999
19:43:31 GMT");
               hc.setRequestProperty("User-Agent", "Profile/MIDP-2.0
Configuration/CLDC-1.2");
               hc.setRequestProperty("Content-Language", "en-US");
               out = hc.openOutputStream();

j2me app then just writes data to the output stream(pretty basic
here). so far so good. not a problem here.
And on my rails controller i do the following,

class MainController < ApplicationController
def read_data
   url = request.env["REQUEST_URI"]
   method = request.env["REQUEST_METHOD"]
   data = request.env["RAW_POST_DATA"]

   newf = File.open("MY_DATA", "wb")
   str = request.body.read
   newf.write(str)
   newf.close
   render :text => "Hello Load #{url}"
end
end

the problem is the same j2me app works(only changes the url) if i have
a servlet receiving the data, i do request.getInputStream on a servlet
and everything works.
But on rails i get ioexception under j2me app saying couldn't write to
socket.

Also is request.body.read the correct way to do it. ?
Is this possible in rails or am i making the wrong assumptions here ?
what am i doing wrong, or rather how is it done.

I appreciate any insights that you may have.
mb

So i should take it that this is not possible in rails ?