我有这个在新线程中启动的功能。但我在浮动中有错误:
public void addProductServer(){
String name = "sugar";
float price = 70;
String description = "good";
SoapObject request = new SoapObject(NAMESPACE, METODO_INSERT);
request.addProperty("name", name);
request.addProperty("price", price);
request.addProperty("description", description);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(URL);
try {
// In this Line belowe I get the error:
transport.call(SOAP_ACTION_INSERT, envelope);
} catch (IOException | XmlPullParserException e) {
e.printStackTrace();
}
Integer result = 0;
try {
result = (Integer) envelope.getResponse();
Log.i("Respuesta: ", result.toString());
} catch (SoapFault soapFault) {
soapFault.printStackTrace();
}
}
这是我的错误:
jared.android.ulpgc.es.practica4_recuperacion E / AndroidRuntime:FATAL EXCEPTION:Thread-1269 过程:jared.android.ulpgc.es.practica4_recuperacion,PID:27659 java.lang.RuntimeException:无法序列化:70.0
jared.android.ulpgc.es.practica4_recuperacion E/AndroidRuntime: FATAL EXCEPTION: Thread-1269
Process: jared.android.ulpgc.es.practica4_recuperacion, PID: 27659
java.lang.RuntimeException: Cannot serialize: 70.0
拜托,我需要一些帮助!
答案 0 :(得分:0)
尝试使用70f
float price = 70f;