【发布时间】:2017-02-15 07:38:04
【问题描述】:
这是我的问题:
由 KSOAP2 3.6.1 android 生成:不会导致任何 XML/SOAP 错误,但 Web 服务将 0 记录为数据库中的 IdMaquina。插入的值是错误的(不是我发送的值)。 Webservice 响应正常。
由 Boomrang chrome 插件生成:工作正常。插入数据库的值是正确的(它等于我发送的值)。 Webservice 响应正常。
用作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