Arun Paarthi
Arun Paarthi

Reputation: 643

Web Service request is not working in android browser and code; but it is working in pc browser

My PC is connected to client's network via tunneling and I am calling a webservice which is in client's network. This works fine in PC Browsers, where as when I try to access it via android application I am getting ClientProtocolException. I tried to hit the web service ip via android browser I was able to see the IIS server response in browser but couldn't access the webservice. Not an https url, just normal http url. It's not working in any version of android emulator.

Code :

HttpClient httpclient = new DefaultHttpClient();

HttpGet httpget = new HttpGet(url); 

HttpResponse response;

try {
    response = httpclient.execute(httpget);

    Log.i("Debug",response.getStatusLine().toString());

    HttpEntity entity = response.getEntity();

    if (entity != null) {

        ....
    }


} catch (Exception e) {
   e.printStackTrace();
}

Upvotes: 3

Views: 1902

Answers (3)

Arun Paarthi
Arun Paarthi

Reputation: 643

Actually there is no response headers in the webservice. That is why I got the exception. Now I opened a socket to get the response, but still a request without proper response header is not good.

Upvotes: 1

roky
roky

Reputation: 208

It could be a firewall application (there is none built-in to my knowledge) on your Android device that may be blocking the access to the webservice.

Upvotes: 1

DevCat
DevCat

Reputation: 113

Have you tried setting up a Web proxy?

httpclient.getHostConfiguration().setProxy("ip-address","port")

or

System.setProperty("http.proxyHost", "ip-address");
System.setPropery("http.proxyPort", "port");

Upvotes: 0

Related Questions