0
我試圖發送請求到Https webservice
,但它總是返回404 Not Found
(在此服務器上找不到請求URL),但它在瀏覽器中完美工作。它返回格式爲XML
的響應。請幫助傢伙。如何在Android中向https webservice發送請求?
這裏是我的代碼
try {
SchemeRegistry schemeRegistry = new SchemeRegistry();
schemeRegistry.register(new Scheme("https", SSLSocketFactory
.getSocketFactory(), 443));
HttpParams param = new BasicHttpParams();
SingleClientConnManager mgr = new SingleClientConnManager(param,
schemeRegistry);
HttpClient client = new DefaultHttpClient(mgr, param);
HttpPost post = new HttpPost(Global.CARD_API_URL);
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add(new BasicNameValuePair("user", "xxx"));
parameters.add(new BasicNameValuePair("pass", "xxxxxxxx"));
parameters.add(new BasicNameValuePair("cardNumber",
"xxxxxxxxxxxxxxxx"));
parameters.add(new BasicNameValuePair("expiryDate", "0515"));
parameters.add(new BasicNameValuePair("cvc", "123"));
post.setEntity(new UrlEncodedFormEntity(parameters));
HttpResponse response = client.execute(post);
String res = EntityUtils.toString(response.getEntity());
Log.d("Card Details", res);
} catch (Exception e) {
e.printStackTrace();
}
什麼是您的服務器日誌顯示? – CommonsWare 2013-05-02 18:38:07
@CommonsWare請參閱[this](http://pastie.org/7754343) – moDev 2013-05-02 18:41:26
**你的服務器日誌**顯示什麼? – CommonsWare 2013-05-02 18:51:09