user3173387
user3173387

Reputation: 41

Web service gives exception

I pass Emailbody in my web sevice:

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>";

My code for web Serivce is:

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;

}

My Exception is :-

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

Please help me how to pass Html tags in web serivce. Thanks in advance.

Upvotes: 2

Views: 63

Answers (1)

Jitesh Upadhyay
Jitesh Upadhyay

Reputation: 5260

Hi have a try with Try HTML.fromhtml() or URLEncoder.encode(String) and also make sure that in yours current String please check the character at position 232, if it is to be a unwanted unnecessary white space this error may occur. Replace the unwanted unnecessary white spaces by using trim function on yours string data.

Upvotes: 1

Related Questions