Dear all,

I am trying to open a url like "https://192.168.10.199/HSMobile/
HSService.asmx" using httpclient and try to read response.

Now if i will open the above url in normal browser, it redirects to
one firewall page and asking login and password.After giving username
and password I able to view response. If i will type only firewall
page url and give login and password, it sows "1.1 Internal server
error 29".

Now I am doing it in android and using http post method. I am seding
login and password for firwall page. I am getting the same error". If
I use the actual URL i.e "https://192.168.10.199/HSMobile/
HSService.asmx" and sending the same login and password usng POST . I
am getting some other error.

Any possibility to solve it.

My demo  code is

String URL = "https://192.168.10.199/cgi/login";;    //firewall page
String URL1 = "https://192.168.10.199/NUHSMobile/NUHSService.asmx?
wsdl"; //actual URL
public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.main);
                Button btn = (Button) findViewById(R.id.btn);
                Button btn1 = (Button) findViewById(R.id.btn1);
                txt = (TextView) findViewById(R.id.label2);
                Name = (EditText) findViewById(R.id.name);
                Name.setText("Sample");
                btn.setOnClickListener(new OnClickListener() {

                        public void onClick(View v)
                        {
                                thread_creation();
                        }
                });
                btn1.setOnClickListener(new OnClickListener() {

                        public void onClick(View v)
                        {
                                thread_creation1();
                        }
                });
        }

        public void thread_creation()
        {
                myProgressDialog = ProgressDialog.show(demo.this, "Please 
wait...",
                                "Connecting server...", true);

                Handler handler = new Handler();
                new LoadingThread(handler).start();
        }

        class LoadingThread extends Thread
        {
                Handler handler;
                public LoadingThread(Handler handler) {
                        super();
                        this.handler = handler;
                }
                @Override
                public void run()
                {
                        try
                        {
                                url_send();
                        } catch (Exception E)
                        {
                                Log.i("Arindam", "result" + 
E.getClass().getName() + ": "
                                                + E.getMessage());
                        }

                        handler.post(new FinishThread());
                }

        }

        class FinishThread extends Thread
        {

                @Override
                public void run()
                {
                        // you can change UI etc

                        if (myProgressDialog != null)
                                myProgressDialog.dismiss();
                        try
                        {
                                txt.setText(return_Data);
                        } catch (Exception e)
                        {
                                Toast.makeText(demo.this, "Network Connection 
Problem",
                                                Toast.LENGTH_SHORT).show();
                        }
                }
        }

        private void url_send()
        {
                nameValuePairs = new ArrayList<NameValuePair>(2);
                nameValuePairs.add(new BasicNameValuePair("login", "david"));
                nameValuePairs.add(new BasicNameValuePair("passwd", 
"u0403668@"));
                nameValuePairs.add(new BasicNameValuePair("", ""));

                /
******************************************************************
                // HttpService is the class for POST and getting
responce
 
********************************************************************/
                HttpService httpService = new HttpService(this, null, 1, URL, 1,
                                nameValuePairs, true);
                return_Data=httpService.start();
        }

        public void thread_creation1()
        {
                myProgressDialog = ProgressDialog.show(demo.this, "Please 
wait...",
                                "Connecting server...", true);

                Handler handler = new Handler();
                new LoadingThread1(handler).start();
        }
        class LoadingThread1 extends Thread
        {
                Handler handler;
                public LoadingThread1(Handler handler) {
                        super();
                        this.handler = handler;
                }
                @Override
                public void run()
                {
                        try
                        {
                                url_send1();
                        } catch (Exception E)
                        {
                                Log.i("Arindam", "result" + 
E.getClass().getName() + ": "
                                                + E.getMessage());
                        }

                        handler.post(new FinishThread1());
                }

        }

        class FinishThread1 extends Thread
        {

                @Override
                public void run()
                {
                        // you can change UI etc

                        if (myProgressDialog != null)
                                myProgressDialog.dismiss();
                        try
                        {
                                txt.setText(return_Data);
                        } catch (Exception e)
                        {
                                Toast.makeText(demo.this, "Network Connection 
Problem",
                                                Toast.LENGTH_SHORT).show();
                        }
                }
        }

        private void url_send1()
        {
                nameValuePairs = new ArrayList<NameValuePair>(2);
                HttpService httpService = new HttpService(this, null, 1, URL1, 
3,
                                null, true);
                return_Data=httpService.start();
        }

}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to