• 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
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to send and receive multiple HTTP POST requests over a connection

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I need to create a resource adaptor for a proprietary protocol based on HTTP protocol

Basically i have to send and receive requests . The main things here are :

1. For sending requests i have to open a connection (eg. http url connection ) to a network element which listens to the HTTP requests , construct the
HTTP POST request and send this POST request . My doubt here is can i use the same connection to send multiple requests .If so how can i match the responses to the requests. Please suggest how can i achieve this.
2. For receiving HTTP POST request from the network element i have to listen to the network element running on some ip , port continously . I must be able to receive multiple requests simultaneouly and send the responses syncronously or synschronously . How can i achieve this.

Please suggest.

Thanks
sagi
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i just wrote some code for a twitter API in j2me, this is the basics of what you need i think

public void updateStatus(String data) {

HttpConnection con = (HttpConnection) Connector.open("http://twitter.com/statuses/update.json");
once we have this connection, linked to the url in question we can set a few request properties which are needed by the site
con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
con.setRequestProperty("Content-Length",""+data.getBytes().length);
con.setRequestProperty("Connection", "close");

OutputStreamWriter ow = new OutputStreamWriter(con.openOutputStream());
wr.write(data);
wr.flush();

}

The call to the above method should be something like updateStatus("status=this is a status @ptay89&in_reply_to_status_id=4051308780");
the data is the stuff you post, fieldName=fieldData&fieldName2=fieldName2data and so on, as a String

Sorry if that doesn't work, very basic as i said
Phil
 
It will give me the powers of the gods. Not bad for a tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic