AsyncTask将bool值发送给C#WebService

时间:2015-05-17 22:13:20

标签: android web-services android-asynctask

我有一个关于将bool值发送到webservice的问题。

这是背景代码

protected Void doInBackground(Void... params) {
            try {
                method = new WebServiceGlobalMethod(sendedOrReceived, "Object");

                method.request.addProperty("TC", UserInfo.TRNo);
                method.request.addProperty("IsStudent", UserInfo.IsStudent);

                method.Method();

            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

我发送2个值; TC是长号,IsStudent是bool。当IsStudent值为true时,没有问题但是当IsStudent值为false时,我的响应为null。通常,当我调用我的webservice manuel并且发送真或假时,我真的得到了我的结果。 (在我的服务中,我的变量是bool。)您如何看待这个问题?为什么我不能从webservice获得结果?

1 个答案:

答案 0 :(得分:0)

使用

method.request.addProperty("IsStudent", "" + UserInfo.IsStudent);

method.request.addProperty("IsStudent", Boolean.toString( UserInfo.IsStudent ) );