在https URL上发布Web服务

时间:2012-11-05 13:44:11

标签: android http-post

我正在尝试在https网址上发布一些数据,但该网址没有证书,因为这只是webservices,我的代码在下面给出

DefaultHttpClient hc=new DefaultHttpClient();   
ResponseHandler <String> res=new BasicResponseHandler();
String   sourceURL=context.getResources().getString(R.string.web_service_url)+"/authenticateUser";
    Log.d("INSIDE AUTHENTICATION", "URLSOFAuthenticateuser" +sourceURL);
    HttpPost postMethod=new HttpPost(sourceURL);   
    List<NameValuePair> userDetails = new ArrayList<NameValuePair>();

    userDetails.add(new BasicNameValuePair("userId", userId)); 
    userDetails.add(new BasicNameValuePair("userPass", userPass)); 

    try {

        Log.d("inside", "&*&*&*&*"+userDetails);
        postMethod.setEntity(new UrlEncodedFormEntity(userDetails)); 
        Log.d("iNSIDE 1", "&*&*&*"+hc.execute(postMethod,res));
        response=hc.execute(postMethod,res);
        Log.d("iNSIDE 2", "&*&*&*");



    }
    catch(HttpResponseException g)
    {
        Log.d("", "&*&*&*HttpResponseException");
    }
    catch (UnsupportedEncodingException e) {
        Log.d("", "&*&*&*UnsupportedEncodingException");

    } catch (ClientProtocolException e) {
        Log.d("", "&*&*&*ClientProtocolException");


    } catch (IOException e) {
        Log.d("", "&*&*&*IOException");

    }  
       return response;  

你可以帮我解决一下这个问题。有没有办法在https网址上建立一个httppost。 感谢

1 个答案:

答案 0 :(得分:1)

http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html

如果您仍然遇到问题,这应该有帮助。

相关问题