我正在尝试向其发送请求,Https webservice
但它总是返回404 Not Found
(在此服务器上找不到请求 url),但它在浏览器中完美运行。它以XML
格式返回响应。请帮助各位。
这是我的代码
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();
}