【问题标题】:KSOAP generated SOAP request don't cause any error but not workingKSOAP 生成的 SOAP 请求不会导致任何错误但无法正常工作
【发布时间】:2017-02-15 07:38:04
【问题描述】:

这是我的问题:

由 KSOAP2 3.6.1 android 生成:不会导致任何 XML/SOAP 错误,但 Web 服务将 0 记录为数据库中的 IdMaquina。插入的值是错误的(不是我发送的值)。 Webservice 响应正常。

123正文> 信封>

由 Boomrang chrome 插件生成:工作正常。插入数据库的值是正确的(它等于我发送的值)。 Webservice 响应正常。

4567正文> 信封>

用作maquinaLog定义:

{ public class maquinaLog implements KvmSerializable { public int IdMaquina;

    public maquinaLog(){}


    public maquinaLog(int idMaquinaField) {

        IdMaquina = idMaquinaField;

    }


    public Object getProperty(int arg0) {

        switch(arg0)
        {
            case 0:
                return IdMaquina;
        }

        return null;
    }

    public int getPropertyCount() {
        return 1;
    }

    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
        switch(index)
        {
            case 0:
                info.type = PropertyInfo.INTEGER_CLASS;
                info.name = "IdMaquina";
                break;
            default:break;
        }
    }

    public void setProperty(int index, Object value) {
        switch(index)
        {
            case 0:
                IdMaquina = Integer.parseInt(value.toString());
                break;
            default:
                break;
        }
    }
}
}
</code>

用于构建 SOAP 请求: { public void WebServiceCallExample(Integer idmaquina) { String NAMESPACE = "@987654321@"; String METHOD_NAME = "IngresarMaquinaLog"; String SOAP_ACTION = NAMESPACE + "IMyService/IngresarMaquinaLog"; String URL = "@987654322@";

 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);


    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    SoapSerializationEnvelope 信封 = 新 SoapSerializationEnvelope(SoapEnvelope.VER11);
    信封.dotNet = true;
    信封.implicitTypes = true;
    信封.setAddAdornments(假);

    maquinaLog ML = 新的 maquinaLog();
    ML.IdMaquina = idmaquina;

    PropertyInfo pi = new PropertyInfo();
    pi.setName("maquinaLog");
    pi.setNamespace(命名空间);
    pi.setValue(ML);
    pi.setType(ML.getClass());
    request.addProperty(pi);

    信封.setOutputSoapObject(请求);

    信封.addMapping(NAMESPACE, "maquinaLog",new maquinaLog().getClass());

    androidHttpTransport.debug = true;

    尝试
    {
        //Log.i("app", androidHttpTransport.requestDump);

        androidHttpTransport.call(SOAP_ACTION, 信封);
        Log.i("appRQS", androidHttpTransport.requestDump);
        Log.i("appRSP", androidHttpTransport.responseDump);
    }
    捕获(异常 e)
    {
        e.printStackTrace();
    }

}
}

【问题讨论】:

    标签: java android web-services soap ksoap


    【解决方案1】:

    我终于成功匹配了 Boomrang chrome 插件查询。

    在复杂的对象定义中我添加了:

    public void getPropertyInfo(int index, Hashtable arg1, PropertyInfo info) {
        switch(index)
        {
            case 0:
                info.type = PropertyInfo.INTEGER_CLASS;
                info.name = "obe:IdMaquina";
                break;
            default:break;
        }
    }
    

    我在信封中添加了一个属性:

    PropertyInfo pi = new PropertyInfo();
    pi.setName("maquinaLog");
    pi.setNamespace(NAMESPACE);
    pi.setValue(ML);
    pi.setType(ML.getClass());
    request.addProperty(pi);
    request.addAttribute("xmlns:obe","http://schemas.datacontract.org/2004/07/OberthurService.Entidades");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-09
      • 1970-01-01
      • 1970-01-01
      • 2018-11-06
      相关资源
      最近更新 更多