C# 价值<;?无法将java.lang.String类型的xml转换为JSONObject Android

C# 价值<;?无法将java.lang.String类型的xml转换为JSONObject Android,c#,android,web-services,C#,Android,Web Services,我正在尝试使用android将图像上传到C#web服务 Web服务采用以下参数: byte[] data, string strFileName 但每次我运行应用程序!它给了我这个错误: Value <?xml of type java.lang.String cannot be converted to JSONObject Value我使用以下代码解决了我的问题: protected String doInBackground(Void... unsued) {

我正在尝试使用android将图像上传到C#web服务

Web服务采用以下参数:

byte[] data, string strFileName
但每次我运行应用程序!它给了我这个错误:

Value <?xml of type java.lang.String cannot be converted to JSONObject

Value我使用以下代码解决了我的问题:

    protected String doInBackground(Void... unsued) {
        try {

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bmp.compress(CompressFormat.JPEG, 80, bos);

            byte[] byte_arr = bos.toByteArray();
            String image_str = Base64.encodeBytes(byte_arr);

            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("data", image_str));
            nameValuePairs.add(new BasicNameValuePair("strFileName",
                    fnameglob));

            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(
                        "http://192.168.1.100:1234/ScanFiles.asmx/vFileUpload");
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);

                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(response.getEntity()
                                .getContent(), "UTF-8"));

                String sResponse = reader.readLine();
                return sResponse;

            } catch (Exception e) {
                Log.e("HTTP", "Error in http connection " + e.toString());
            } finally {

            }
        } finally {

        }
        return "done";

        // (null);
    }
如果要查找base64类,可以找到它

谢谢

    protected String doInBackground(Void... unsued) {
        try {

            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            bmp.compress(CompressFormat.JPEG, 80, bos);

            byte[] byte_arr = bos.toByteArray();
            String image_str = Base64.encodeBytes(byte_arr);

            ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("data", image_str));
            nameValuePairs.add(new BasicNameValuePair("strFileName",
                    fnameglob));

            try {
                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(
                        "http://192.168.1.100:1234/ScanFiles.asmx/vFileUpload");
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                HttpResponse response = httpclient.execute(httppost);

                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(response.getEntity()
                                .getContent(), "UTF-8"));

                String sResponse = reader.readLine();
                return sResponse;

            } catch (Exception e) {
                Log.e("HTTP", "Error in http connection " + e.toString());
            } finally {

            }
        } finally {

        }
        return "done";

        // (null);
    }
  [WebMethod]
    public void vFileUpload(string data, string strFileName)
    {
        try
        {
            string str = data.Length.ToString();
            string sDestinationScannedFiles = ConfigurationManager.AppSettings["DestinationScannedFiles"].ToString();
            //string filePath = Server.MapPath(sDestinationScannedFiles +  strFileName);
            string filePath = sDestinationScannedFiles + strFileName;

            File.WriteAllBytes(filePath, Convert.FromBase64String(data));
        }