• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Sockets in J2ME

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the followingcode that reads data from input socket and then casted to HTTPConnection to allow using HTTP methods but it is giving me casting exception errorHow can I do it " Read string from input stream and get the http header information andbody information from it" Thanks

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi you cant typecast the socketconnection to httpconnection. You have to decide which connection had to be used. If you want header information while opening the connection typecast that to HttpConnection that is the standard way we do in J2ME.

HttpConnection conn =(HttpConnection)Connector.open(url);

 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for assistance my requirement is: The client wants to communicate with a server that provides restful web services.
So the client will send for example (GET /Addition?q1=5&q2=6 HTTP1.1) and the server will should parse the received message and extract the Addition and parameters and redirect it to the appropriate resource? So what is the best solution?

 
Srinivas Vurrinkala
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got what you want to do. For invoking restful services you just need to construct http url with above said parameters . The url can be this http://somesite.com/addition?q1=5&q2=6. This will definitely works out.


Regards
Srinivas
 
feda alshahwan
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did what you told me but I got the following error:
Uncaught exception java/lang/IllegalArgumentException: Malformed address.
knowing that the code is:


The server side code is:

 
I don't always make ads but when I do they're tiny
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic