我正在开发一个应用程序,我必须通过调用 Restful Web Service 在服务器上以 base64 格式发送多个图像。
调用 Restful Web 服务的代码:
try {
//instantiates httpclient to make request
DefaultHttpClient httpclient = new DefaultHttpClient();
//url with the post data
HttpPost request = new HttpPost(urlPath);
//convert parameters into JSON object
JSONObject holder = new JSONObject(jsonObjString);
//passes the results to a string builder/entity
StringEntity se = new StringEntity(holder.toString());
//sets the post request as the resulting string
request.setEntity(se);
//sets a request header so the page receving the request
//will know what to do with it
request.setHeader("Accept", "application/json");
request.setHeader("Content-type", "application/json");
//Handles what is returned from the page
ResponseHandler<String> responseHandler = new BasicResponseHandler();
responseString = httpclient.execute(request, responseHandler);
}catch (Exception e) {
e.printStackTrace();
}
另一个问题是,当我使用 JSON 对象作为请求参数调用 Web 服务时,我得到了 ThreadPoolExecutor。我们如何解决这个问题。是否有通过调用 Restful Web 服务在服务器上上传多个 base64 图像的完美方法。