File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes Working with Webservices in J2ME Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "Working with Webservices in J2ME" Watch "Working with Webservices in J2ME" New topic
Author

Working with Webservices in J2ME

Prasanth Duggirala
Ranch Hand

Joined: Dec 22, 2006
Posts: 36
Hi All,

Can any one provide a sample example to work on web services client in J2ME.

How to consume web services in J2ME.

Can any one suggest best book or site for J2ME case study.

thanking you
[ December 17, 2008: Message edited by: prasanth duggirala ]

Thanks & Regards,<br />Prasanth Duggirala.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Have you actually gone through the articles (and the material they reference) that I suggested back here?

J2ME Web Services (2004 June)
SOA Without SOAP: The Java ME Perspective (June 2007)

Web Services APIs for J2ME, Part 1: Remote service invocation API (2004 Jul)
Web Services APIs for J2ME, Part 2: Java API for XML processing (2004 Nov)
Turn Your J2ME Mobile Devices into Web Service Clients (2005 May)

The most recent article (SOA Without SOAP) makes a case that SOAP on J2ME could actually be a dead end:
SOAP's dependence on XML is also a disadvantage, however. While it's true that the Web Services APIs for Java ME (WSA) support a subset of the SOAP 1.1 standard and a simple API for parsing XML, WSA support is far from widespread. ... The pragmatic Java ME developer understands this, which is why alternative approaches must often be explored. And even if SOAP was universally supported on Java ME platforms, some developers would look for different solutions because of the extra overhead involved in using SOAP. ... In other words, services are invoked using the HTTP GET and POST methods, with any input data passed in using query parameters (for GET requests) or the request body (for POST requests) ... If data security is a concern, use code from the Bouncy Castle Crytographic APIs-an open source cryptography project-to encrypt the communication, as described in Data Encryption for J2ME Profiles.
Prasanth Duggirala
Ranch Hand

Joined: Dec 22, 2006
Posts: 36
Hi all

How to Create a HTTP connection in J2ME.

i have a URL with will return a URL string.

and i want make a request to that URL and display in next form.

please give me an example for Http Connection.

thanks
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
Networking with J2ME
javax.microedition.io.HttpConnection

Developing J2ME applications with HTTP service
Prasanth Duggirala
Ranch Hand

Joined: Dec 22, 2006
Posts: 36
Hi Peer,

i got the connection and able to get the values in emulator Peer.

i tested in phone Nokia N91 what happened is i cant able to get the responce.

I have doubt, throw J2ME app we are req to a server for resonse as i kept the URL this will get the respons String and i am displaying in J2ME app.

i am getting responce like this <h1>Length Required</h1> i am not able to see the Responce string iam getting in the emulator.

please help me in this issue.

please find the attachemants
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
I think we are now moving into issues that would be more appropriately addressed in the Java Micro Edition forum.

It is already apparent that the emulator environment is more forgiving than the Nokia N91 over the wireless network.

I am assuming that you are actually receiving an (error) HTTP Response Code: HTTP/1.1 411 Length Required.

This suggests to me that successful transmission of a J2ME client HTTP request over the wireless network requires a valid Content-Length header in the request (even though HTTP/1.1 doesn't require it (RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1; 4.4 Message Length). To be compatible with HTTP/1.0 Content-Length should be included anyway).

See also
J2ME Tech Tips: Client-Server communication over HTTP using MIDP and servlets
HTTP POST Basics
content-length property in wireless toolkit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Working with Webservices in J2ME