I am using the following program in order to test the send of HTTP POST message to a remote server:
Using java Syntax Highlighting
- package mobile.YourVideosMobile;
- import java.io.IOException;
- import java.net.Inet4Address;
- import java.net.InetAddress;
- import java.net.UnknownHostException;
- import java.util.ArrayList;
- import java.util.List;
- import org.apache.http.HttpResponse;
- import org.apache.http.NameValuePair;
- import org.apache.http.client.ClientProtocolException;
- import org.apache.http.client.HttpClient;
- import org.apache.http.client.entity.UrlEncodedFormEntity;
- import org.apache.http.client.methods.HttpPost;
- import org.apache.http.impl.client.DefaultHttpClient;
- import org.apache.http.message.BasicNameValuePair;
- import android.app.Activity;
- import android.os.Bundle;
- import android.util.Log;
- import android.widget.TextView;
- public class YourVideos extends Activity {
- private static final String TAG = "YourVideos_DEBUG";
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- postData();
- }
- public void postData() {
- // Create a new HttpClient and Post Header
- HttpClient httpclient = new DefaultHttpClient();
- HttpPost httppost = new HttpPost("http://yourvideos.servehttp.com:2323");
- try {
- // Add your data
- List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
- nameValuePairs.add(new BasicNameValuePair("id", "12345"));
- nameValuePairs.add(new BasicNameValuePair("stringdata", "AndDev is Cool!"));
- httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
- // Execute HTTP Post Request
- HttpResponse response = httpclient.execute(httppost);
- Log.i(TAG, response.toString());
- } catch (ClientProtocolException e) {
- Log.e(TAG, "Error in client protocol");
- } catch (IOException e) {
- Log.e(TAG, "IOException");
- }
- }
- }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4
but nothing is written in the logger. I've alreadt tried to establish a socket with server but it is not created; any possible problem with the port?
Thanks in advance,
Best regards!

