I have made a servlet that sends an XML data via an HttpServletResponse object. With this approach I can send the XML data to a browser or an HttpClient object which uses the getResponseBody() method. Problem is, it does not work with the MIDP2 HttpConnection object using the openInputStream(). Has anyone tried sending XML data to a mobile phone?
Well for J2ME calling a Servlet, the out.write() would be the straight XML String. Meaning you don't add the XML Object to the HTTPResponse Object, but it is the response itself. I have done this many times with URLConnection and J2ME.
Personally when it comes to this, I just send straight text and forget about the XML. It all depends on the size of the data being sent back. Most of the time I try to keep it really small so there is less time.