3
um對於android來說相當新穎,並試圖通過android對網址進行發佈。我的網址看起來像這樣。Android HTTP發佈到不帶參數的網址
http://192.168.101.111:7000/MyService.svc/home/updatejob/4600/XCV13030001/TTTT0000/CCCC0000/SSSS0000
我可以通過高級休息客戶端做這個網址,這工作正常。這是我的android代碼執行
public boolean updateInfo() {
boolean result = false;
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(url);
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("sbDriverID", sbDriverID.toString()));
params.add(new BasicNameValuePair("sbJobNumber", sbJobNumber.toString()));
params.add(new BasicNameValuePair("sbTrailerNumber", sbTrailerNumber.toString()));
params.add(new BasicNameValuePair("sbContainerNumber", sbContainerNumber.toString()));
params.add(new BasicNameValuePair("sbSealNumber", sbSealNumber.toString()));
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(params, "UTF-8");
httpPost.setEntity(entity);
HttpResponse httpResponse = httpClient.execute(httpPost);
if (httpResponse != null) {
if (httpResponse.getStatusLine().getStatusCode() == 204)
result = true;
}
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
這會返回我一個404。我試了很難,找不到原因。
上面的URL說「無法連接」。 – KunalK
這就是位置服務器 –
@Kalanamith當您嘗試訪問URL時,您的瀏覽器顯示什麼? –