android - Web 服务给出异常

标签 android web-services

我在我的网络服务中传递了 Emailbody:

String emailBody="<span style='font-size: 14px;font-family:" +
                        " Arial;'>Following task is now completed.<table width=" +
                        "'100%' cellpadding='0' cellspacing='0'><tr><td style=" +
                        "'height: 2px; background-color:'></td></tr>" +
                        "</table><p>"+remark+"</p> " +
                        "Completion Date: "+fmdate+"<br /><br /><br /><i>Note: This is automated message. Please do not reply to this email. If you have questions, please contact your Care Team Members.</i></span>";

我的网络服务代码是:

ProgressDialog Dialog;
boolean flag;
String call_method,method1;
HttpClient client;
XmlPullParserFactory factory;
HttpResponse res;
XmlPullParser parser;

@Override
protected Result doInBackground(String...value) {
    // TODO Auto-generated method stub
    Log.d("submit", "Login");

    method1=value[0];
    call_method=value[1];
    method1=removeSpace(method1);
    method1=removePlus(method1);
    String method=variable.host+call_method+method1;
    Log.d("method","==>"+method);

    HttpGet get;
    try {
        get=new HttpGet(new URI(method));
        //get=new HttpGet(new URI(URLEncoder.encode( method , "UTF8" )));

        res =LogInActivity.client.execute(get);



        factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);  
        Log.i("Bhavik","Response : "+res.getStatusLine().toString());

        parser = factory.newPullParser(); 
        parser.setInput(new InputStreamReader(res.getEntity().getContent()));   

        Log.d("Bhavik", "In Side HTTP "+call_method);


        if(call_method.equals("SaveMesage?")){

            System.out.println("hello world");

        }else{
            Messge_Detail_parser pd=new Messge_Detail_parser();
            flag=pd.replyData(parser);

        }


    }catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } 
   return null;

}

我的异常(exception)是:-

java.net.URISyntaxException: Illegal character in query at index 231: 

请帮助我如何在网络服务中传递 Html 标签。 提前致谢。

最佳答案

您好,请尝试使用 HTML.fromhtml()URLEncoder.encode(String) 并确保在您当前的字符串中,请检查位置处的字符232,如果是不需要的不必要的空白,可能会出现这个错误。通过对您的字符串数据使用修剪功能来替换不需要的不必要的空格。

关于android - Web 服务给出异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21898052/

相关文章:

web-services - 我预计youtube api v.3可以维持多长时间?

java - Netbeans 和 .NET Web 服务

web-services - REST Web服务中@Path和@Requestmapping之间的区别

android - setJavaScriptEnabled(true) 的替代解决方案;

java - 如何在第一个对话框上调用removeView()以显示第2个对话框

android - Android 设备上的批量插入

android - 使用 Google Drive Android API 下载特定 MIME 类型的文件

Android 自定义键盘 - 找不到类 (XML)

.net - 使用我的本地 SSL 证书配置端口

c# - jsTree 3.0.2 - 如何将参数传递给 aspx webmethod