Http Post connection in SDK-1.0

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Postby ninor » Fri Oct 03, 2008 10:41 am

Well, I personally don't know ...
Image AndDev: Your Android Development Community / Tutorials | Here's my Basic ToolKit
User avatar
ninor
Moderator
Moderator
 
Posts: 180
Joined: Thu Aug 14, 2008 6:30 pm
Location: Barcelona, Spain

Top

Postby phannguyen » Fri Oct 03, 2008 10:41 am

hi all,
i have just fixed a bug when i try to connect to a webservice.
i missing a permisssion
if have any problem related connect internet ,everyone can refer at http://www.anddev.org/unknown_socket_er ... t3016.html
thanks plusminus.
PhanNguyen
phannguyen
Experienced Developer
Experienced Developer
 
Posts: 56
Joined: Thu Jul 17, 2008 7:37 am

problem http post with android 1.0

Postby akd » Thu Jan 15, 2009 1:34 am

ninor,
I have implement the the code you posted here "httpPostTest ", however its working fine when i make only http get request but when i make http post its not working. I have created my own sample servelt class and implement doPost method which just reponse a small piece of html which i want to display on my text view of main activtiy, when i use the http get it work fine but when executing http post its throwing exception. so how could i resolve this issue. If you will need more information i will post here. thanks a lot in advance.
with Best regards
AKD
akd
Freshman
Freshman
 
Posts: 4
Joined: Thu Jan 15, 2009 1:24 am
Location: India

Postby andbot » Wed Feb 04, 2009 1:46 pm

I am pretty new to here.

What changes should be done to the above code if I want it to POST usernames and passwords to a PHP script.
andbot
Freshman
Freshman
 
Posts: 2
Joined: Wed Feb 04, 2009 12:53 pm

Accessing Https:// url through a proxy

Postby _Davidsekar » Wed Mar 11, 2009 9:08 pm

ninor,


The sample code that you provided was very easy to understand. but my problem is little bit tricky (for me :oops: ) ,,,

i need to access https url through a proxy server.

so i tried following code

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. i created a HttpHost object with my ("proxy_IP",port);
  2.  
  3.  
  4.  
  5. i added this to ttpClient.getParams().setParams() method to set my proxy
  6.  
  7.                       then allowed HandlingRedirects as true
  8.  
  9.  
  10.  
  11.  
  12.  
  13. Then i created
  14.  
  15.       HttpGet httpget = new HttpGet(strUrl);
  16.  
  17. <span style="font-weight: bold">      httpclient.execute(httpget);</span>  this statement throws exception...
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


i get IllegalArgumentException

Please help
_Davidsekar
Freshman
Freshman
 
Posts: 5
Joined: Wed Mar 11, 2009 8:43 pm

Help

Postby _Davidsekar » Thu Mar 12, 2009 5:15 am

im pasting the code part i have modified


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. DefaultHttpClient httpclient = new DefaultHttpClient();
  2.  
  3.                 System.setProperty("java.net.useSystemProxies","true");
  4.  
  5.                 HttpHost proxy = new HttpHost("proxy IP",portnumber);  
  6.  
  7.                 httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
  8.  
  9.                 httpclient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS, true);
  10.  
  11.  
  12.  
  13.                 // Get cookies from the login page (not the address same of the form
  14.  
  15.                 // post)
  16.  
  17.                 HttpGet httpget = new HttpGet("https://www.linkedin.com/secure/login?trk=hb_signin");
  18.  
  19.                 HttpResponse response;
  20.  
  21.                 try {
  22.  
  23.                         response = httpclient.execute(httpget);
Parsed in 0.033 seconds, using GeSHi 1.0.8.4



rest remains the same

i get IllegalArgument while trying to execute httpclient.execute(...) method

Some one please help
_Davidsekar
Freshman
Freshman
 
Posts: 5
Joined: Wed Mar 11, 2009 8:43 pm

Top

Solution

Postby _Davidsekar » Sun Mar 15, 2009 6:56 am

Well!!!

No reply from anyone :evil:

Anyway i googled and found out how to communicate through proxy.

I'm posting the code so that it will be useful for guys who comeup with same query....

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. DefaultHttpClient httpclient = new DefaultHttpClient();
  2.  
  3. httpclient.getCredentialsProvider().setCredentials(
  4.  
  5.                         new AuthScope(proxyHost, proxyPort),
  6.  
  7.                         new UsernamePasswordCredentials(proxyUsername,
  8.  
  9. new String(proxyPassword)));
  10.  
  11. httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, hcProxyHost);
  12.  
  13.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


This will solve that problem.


One more thing, if you get "unknow error" in exception...

may be due to emulator settings, or your program permission setting...


You will get exact exception message only when there is some thing wrong in your code .....


And i have learnt this .... try searching you'll find solution for the problem by yourself.
_Davidsekar
Freshman
Freshman
 
Posts: 5
Joined: Wed Mar 11, 2009 8:43 pm

Password authentication

Postby andy_spoo » Fri Sep 04, 2009 10:29 am

Hi,

if I use the code listed at the start, I get the response HTTP/1.1 200 OK

which seems like a good start, but how can I tell if the password has been accepted, because no matter what password I try (i.e. Invalid Passwords) I get the same response??

I'm logging into Google Analytics by the way.

Thanks,
If you pay peanuts then expect moneys.
andy_spoo
Freshman
Freshman
 
Posts: 5
Joined: Wed Aug 12, 2009 6:25 pm

success

Postby killop » Thu Oct 24, 2013 10:20 am

Grand information. blesss for you recapitulate plus tutorial about how to note. I realize if we traipse to alternative blog we most criticize to provide enjoy for proprietor.
cv editing
killop
Freshman
Freshman
 
Posts: 6
Joined: Thu Oct 24, 2013 10:10 am

Top
Previous

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests