Android调用WCF服务

时间:2011-07-29 10:11:51

标签: android wcf

我的应用程序正在调用wcf服务。第一次打电话&列出所有表名然后在该屏幕上从菜单选项中选择“下载”,它再次调用服务,那时它给出错误信息:无法序列化

enter image description here

我打电话给这个

  public static final String APPURL = "http://192.168.1.213:7986/XontService";
  private static final String METHOD_NAME = "LoadDownLoadTablesInJSON";
  private static final String NAMESPACE = "http://tempuri.org/";
  private static String SOAP_ACTION = "http://tempuri.org/IXontPDAService/LoadDownLoadTablesInJSON";

  private static final String METHOD_NAME1 = "LoadDownLoadTablesDataJson";
  private static String SOAP_ACTION1 = "http://tempuri.org/IXontPDAService/LoadDownLoadTablesDataJson";


  // ksoap2 calling wcf
public SoapPrimitive soapPrimitiveData(String tablename) throws IOException,XmlPullParserException {
    SoapPrimitive responsesData = null;
    SoapObject requestData = new SoapObject(NAMESPACE, METHOD_NAME1); // set

    System.out.println(" ------- " + strBusinessUnit + " -- "+ strExecutive + " -- " + strTerritoryCode + "mrthod : " + METHOD_NAME1);

    requestData.addProperty("strBusinessUnit", strBusinessUnit);
    requestData.addProperty("strExecutive", strExecutive);
    requestData.addProperty("strTableName", tablename);

    requestData.addProperty("strDate", new Date());
    requestData.addProperty("strTerritoryCode", strTerritoryCode);

    requestData.addProperty("strUField1", "");
    requestData.addProperty("strUField2", "");
    requestData.addProperty("strUField3", "");

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11); // put all required data into a soap//
                                    // envelope
    envelope.dotNet = true;
    envelope.setOutputSoapObject(requestData);
    AndroidHttpTransport httpTransport = new AndroidHttpTransport(APPURL);
    httpTransport.debug = true;

    try {
        httpTransport.call(SOAP_ACTION1, envelope);
        responsesData = (SoapPrimitive) envelope.getResponse();
        System.out.println("-- responses ---- " + responsesData);
    } catch (SocketException ex) {
        ex.printStackTrace();
    } catch (Exception e) {
       e.printStackTrace();
    }
    return responsesData;
}

请帮助..

提前致谢。

1 个答案:

答案 0 :(得分:1)

  

确保 strBusinessUnit * AND ** tablename AND strExecutive AND strTerritoryCode 是字符串

问题是

 new Date()