aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes How to send and receive multiple HTTP POST requests over a connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How to send and receive multiple HTTP POST requests over a connection" Watch "How to send and receive multiple HTTP POST requests over a connection" New topic
Author

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

raj routhu
Greenhorn

Joined: May 06, 2009
Posts: 1
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
Phillip Taylor
Greenhorn

Joined: Sep 18, 2009
Posts: 1
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to send and receive multiple HTTP POST requests over a connection