Hi,
I work into securing data between webservice and client android, I
deloy my web service with https url,before that I created the server
and client certficate,so when I try to access on it into android it
gives me errors

 WARN/System.err(: org.apache.http.NoHttpResponseException: The target
server failed to respond
 WARN/System.err(:     at
org.apache.http.impl.conn.DefaultResponseParser.parseHead(DefaultResponseParser.java:
85)
 WARN/System.err(    at
org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:
174)
    at
org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:
179)
     at
org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:
235)
    at
org.apache.http.impl.conn.AbstractClientConnAdapter.receiveResponseHeader(AbstractClientConnAdapter.java:
259)


Here is it the code that I used to access to my web service

protected ClientConnectionManager createClientConnectionManager() {

                SchemeRegistry registry = new SchemeRegistry();
                registry.register(new Scheme("http", PlainSocketFactory
                                .getSocketFactory(), 80));
                registry.register(new Scheme("https", newSslSocketFactory(), 
8181));

                HttpParams params = new BasicHttpParams();
                params.setParameter(ConnManagerPNames.MAX_TOTAL_CONNECTIONS, 
30);
                params.setParameter(ConnManagerPNames.MAX_CONNECTIONS_PER_ROUTE,
                                new ConnPerRouteBean(30));
                params.setParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, 
false);
                HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
                android.util.Log.d("ok2", "ok1");
                ClientConnectionManager cm = new 
ThreadSafeClientConnManager(params,
                                registry);
                android.util.Log.d("ok", "ok3");
                return cm;
        }

        private SSLSocketFactory newSslSocketFactory() {
                try {
                        KeyStore trusted = KeyStore.getInstance("BKS");
                        InputStream in = context.getResources().openRawResource(
                                        R.raw.client);


                        trusted.load(in, "changeit".toCharArray());

                        SSLSocketFactory sf = new SSLSocketFactory(trusted);

                        // Hostname verification from certificate
                        // 
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d4e506
        
sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

                        return sf;
                } catch (Exception e) {
                        throw new AssertionError(e);
                }
        }

-- 
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