1

所以嗨。我目前有看起来像这样的网络服务

    [WebMethod]
    public bool SyncGeneralDataToServer(string macaddress, string userid,
                                string password, string computername,
                                string dateupdated, string q1, string a1
                                , string q2, string a2, string q3, string a3
                                , string q4, string a4, string q5, string a5
                                , string location, bool onsite)
    {
        MTKBL = new MobileTKBL();
        bool result;
        try
        {
            result = MTKBL.SyncToServer(macaddress, userid,
                                     password, computername,
                                     dateupdated, q1, a1
                                    , q2, a2, q3, a3
                                    , q4, a4, q5, a5
                                    , location, onsite);
        }
        catch (Exception e)
        {
            result = false;
        }


        return result;
    }

我有一个看起来像这样的android方法

        public boolean SyncLocalGeneralDataToServer(String macaddress, String userid,
        String password, String computername,
        String dateupdated, String q1, String a1
        , String q2, String a2, String q3, String a3
        , String q4, String a4, String q5, String a5
        , String location, boolean onsite)
{
    boolean result = false;

    String SOAP_ACTION = "http://MTKAndroidService.org/SyncGeneralDataToServer";
    String METHOD_NAME = "SyncGeneralDataToServer";

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);        

    PropertyInfo[] propInfos = new PropertyInfo[17];

    propInfos[0]= setPropertyInfo("macaddress",macaddress,String.class);
    propInfos[1]= setPropertyInfo("userid",userid,String.class);
    propInfos[2]= setPropertyInfo("macaddress",password,String.class);
    propInfos[3]= setPropertyInfo("computername",computername,String.class);
    propInfos[4]= setPropertyInfo("dateupdated",dateupdated,String.class);
    propInfos[5]= setPropertyInfo("q1",q1,String.class);
    propInfos[6]= setPropertyInfo("q2",q2,String.class);
    propInfos[7]= setPropertyInfo("q3",q3,String.class);
    propInfos[8]= setPropertyInfo("q4",q4,String.class);
    propInfos[9]= setPropertyInfo("q5",q5,String.class);
    propInfos[10]= setPropertyInfo("a1",a1,String.class);
    propInfos[11]= setPropertyInfo("a2",a2,String.class);
    propInfos[12]= setPropertyInfo("a3",a3,String.class);
    propInfos[13]= setPropertyInfo("a4",a4,String.class);
    propInfos[14]= setPropertyInfo("a5",a5,String.class);
    propInfos[15]= setPropertyInfo("location",location,String.class);
    propInfos[16]= setPropertyInfo("onsite",onsite,boolean.class);

    for(int i =0; i < propInfos.length; i++)
    {
         request.addProperty(propInfos[i]);
    }

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.dotNet = true; // put this only if the web service is .NET one
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try {

        androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();
        Log.i("myApp", response.toString());
        if(response.toString().equalsIgnoreCase("true")){
            result = true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}

private PropertyInfo setPropertyInfo(String name,Object value,Object type)
{
    PropertyInfo propInfo =new PropertyInfo();
    propInfo.setName(name);
    propInfo.setValue(value);
    propInfo.setType(type);
    return propInfo;
}

我检查了属性信息值是否正确且完整。问题是 Web 服务接受请求但在数据库中插入空值。我在这里想念什么?

4

1 回答 1

1

您的命名空间 URL(.net 和 android 端)中可能有一个冒号,例如 http:// - 从命名空间中删除 http:// 部分并重试。

于 2013-08-02T14:47:00.197 回答