4

I just noticed a strange thing in MIDP 2.0 API: The HttpConnection class apidocs make explicit references to methods GET, POST and HEAD, but no other methods. Does this mean that they are not supported?

http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/io/HttpConnection.html

I also tried checking the MIDP 2.0 spec, but couldn't find any hard facts about this.

I can give this a try on some phone(s), but can't try them all. Does anyone know which HTTP methods are required to be supported by phones implementing the MIDP 2.0 spec? Or any experience in finding phones that support/don't support e.g. HTTP PUT?

If PUT is not supported, are there any (portable) workarounds for implementing it? Implement HTTP on top of SocketConnection?

hvuoltee
  • 408
  • 4
  • 8
  • Ok, tested it on a Nokia S40 phone, results in an exception "unsupported method". And it doesn't look likely that it would be supported elsewhere either... – hvuoltee Oct 19 '09 at 13:52

3 Answers3

3

It is not technically supported by the spec. I am sure there are wrapper classes but I am sure they would introduce their own set of bugs and work arounds.

Writing a simple wrapper isn't hard, writing a decent usable bug free one is way mmore complicated

drubin
  • 1,012
  • 7
  • 10
  • Ok, thanks. I'll have to check out if there are already any libraries available to do this, but I would guess not. – hvuoltee Oct 19 '09 at 13:56
0

You may experience some difficulty implementing it on top of SocketConnection as many (most?) implementations won't let you connect to port 80 or 8080 using SocketConnection unless you're trusted/signed.

funkybro
  • 8,432
  • 6
  • 39
  • 52
  • That restriction is more for listening on a socket than making an outbound connection – Sam Barnum Oct 19 '09 at 13:39
  • Thanks for the pointer. I found some documentation related to this, it looks like JSR 185 (JTWI) requires this behavior. I have no idea why they would require this, though. Pretty strange. – hvuoltee Oct 19 '09 at 13:59
-3

Right, HttpConnection is limited to those verbs. I don't think it's feasible to patch it to use some other method. You'll want to use Apache HttpClient. Among many other features,

Full implementation of all HTTP methods (GET, POST, PUT, DELETE, HEAD, OPTIONS, and TRACE) in an extensible OO framework.

Sam Barnum
  • 10,559
  • 3
  • 54
  • 60