Hi guys,

I sorta have a problem. I m currently programming a Android Code for
passing information to a server using httpsURLConnection. However I
have problems when I execute the command: int rc =
httpsUrlConnection.getResponseCode();

It always takes at least half a minute to process this method since I
m sending relatively big strings back. Is there any way to speeden
things up? I tried to leave this command away but then nothing works,
the server does not receive any information.

This is my Code:
                if(isOnline(context))
                {
                        byte[] bytes = soap.getBytes();

                        System.setProperty("http.keepAlive", "false");

                        SSLContext sslContext = SSLContext.getInstance("TLS");
                        sslContext.init(null, new TrustManager[] { new 
MyTrustManager() },
new SecureRandom());

        
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
                        HttpsURLConnection.setDefaultHostnameVerifier(new
MyHostnameVerifier());
                        HttpsURLConnection httpsUrlConnection = 
(HttpsURLConnection) new
URL(APIData.getURL()).openConnection();

                        TelephonyManager telephonyManager = (TelephonyManager)
ActivityStack.peek().getSystemService(Context.TELEPHONY_SERVICE);
                        String imei = telephonyManager.getDeviceId();


                        httpsUrlConnection.addRequestProperty("Authorization", 
"Basic " +
Base64Encoder.encode(imei + ":" + imei));
                        httpsUrlConnection.addRequestProperty("Content-Length", 
"" +
bytes.length);
                        httpsUrlConnection.addRequestProperty("Content-Type", 
"text/xml;
charset=\"utf-8\"");
                        httpsUrlConnection.addRequestProperty("SOAPAction", 
"http://
tempuri.org/IDataUploadWS/UploadSmartPhoneData");

                        httpsUrlConnection.setRequestMethod("POST");
                        httpsUrlConnection.setDoInput(true);
                        httpsUrlConnection.setDoOutput(true);
                        httpsUrlConnection.connect();

                        OutputStream output = 
httpsUrlConnection.getOutputStream();

                        output.write(bytes);
                        output.flush();
                        output.close();

                        int rc = httpsUrlConnection.getResponseCode();
                        Log.i("", "APIConnection.sendSOAP(...): ResponseCode = 
" + rc);
                        Log.i("", "APIConnection.sendSOAP(...): ResponseMessage 
= " +
httpsUrlConnection.getResponseMessage());

                        httpsUrlConnection.disconnect();

                        result = checkResponseCode(rc);
                }

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

Reply via email to