逃離報價,我試圖讓一個Web服務調用,我必須要通過在Java
login.php?message=[{"email":"[email protected]","password":"tiger"}]
我已經用反斜槓轉義雙引號這樣
String weblink = "login.php?message=[{\"email\":\"[email protected]\",\"password\":\"tiger\"}]";
但我米仍然有錯誤。我試着打電話給其他沒有任何雙引號需要數據的Web服務,他們工作正常,所以我很確定問題出在這裏。此外,我得到一個異常的java.lang說
java.lang.Exception Indicates a serious configuration error.DateParseException An exception to indicate an error parsing a date string. DestroyFailedException Signals that the destroy() method failed
編輯: 我使用的URLEncoder和JSON對象,但仍得到一個錯誤
這裏試過是代碼
String HOST = "http://62.285.107.329/disaster/webservices/";
String weblink = "login.php?message=[{\"email\":\"[email protected]\",\"password\":\"tiger\"}]";
String result = callWebservice(weblink);
public String callWebservice(String weblink) {
String result = "";
try {
HttpParams httpParameters = new BasicHttpParams();
int timeoutConnection = 7500;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
int timeoutSocket = 7500;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpClient client = new DefaultHttpClient(httpParameters);
HttpGet request = new HttpGet();
URI link = new URI(HOST + weblink);
request.setURI(link);
HttpResponse response = client.execute(request);
BufferedReader rd = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()));
result = rd.readLine();
} catch (Exception e1) {
e1.printStackTrace();
result = "timeout";
}
return result;
}
其餘
此外web服務返回一個JSON對象,所以這也可能是錯誤的原因?
異常變得沒有意義。發佈堆棧跟蹤。 – Doorknob
如果你提供了錯誤,它可能會幫助更多。 – scrappedcola