• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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:

 
Let's get him boys! We'll make him read this tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic