1
Я пытаюсь загрузить изображения с помощью андроида на C# веб-службыЗначение <XML типа java.lang.String не могут быть преобразованы в JSONObject Android
Веб-служба принимает эти параметры:
byte[] data, string strFileName
но каждый раз, когда я запускаю приложение! он дал мне эту ошибку:
Value <?xml of type java.lang.String cannot be converted to JSONObject
Это код:
class ImageUploadTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... unsued) {
try {
HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpPost httpPost = new HttpPost(
"http://192.168.1.100:8080/ScanFiles.asmx?op=vFileUpload");
MultipartEntity entity = new MultipartEntity(
HttpMultipartMode.BROWSER_COMPATIBLE);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bmp.compress(CompressFormat.JPEG, 80, bos);
byte[] data = bos.toByteArray();
entity.addPart("fileName", new StringBody(fnameglob));
entity.addPart("data", new ByteArrayBody(data, "image/jpeg", fnameglob));
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost,
localContext);
BufferedReader reader = new BufferedReader(
new InputStreamReader(
response.getEntity().getContent(), "iso-8859-1"));
String sResponse = reader.readLine();
return sResponse;
} catch (Exception e) {
if (dialog.isShowing())
dialog.dismiss();
Toast.makeText(getApplicationContext(), e.getMessage(),
Toast.LENGTH_LONG).show();
Log.e(e.getClass().getName(), e.getMessage(), e);
return null;
}
// (null);
}
Любые предложения? Любая помощь очень заметна.