我需要帮助。我正在尝试将参数传递给webservice,它显示了一个错误: 无法串行化content_of_userText 。 我的代码是:
if (button.getId() == R.id.loginButton) {
//Modelo el request
SoapObject request = new SoapObject(namespace, Metodo);
//Paràmetres
request.addProperty("correu", userText.getText());
request.addProperty("pass", passText.getText());
//Modelo el Sobre
SoapSerializationEnvelope sobre = new SoapSerializationEnvelope(SoapEnvelope.VER11);
sobre.dotNet = true;
sobre.setOutputSoapObject(request);
//Modelo el transporte
HttpTransportSE transporte = new HttpTransportSE(url);
try {
//Llamada
transporte.call(accionSoap, sobre);
//Resultado
SoapObject resultado = (SoapObject) sobre.getResponse();
Toast.makeText(this, resultado.toString(), Toast.LENGTH_SHORT).show();
}
catch (Exception e)
{
Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show();
}
谢谢!
编辑:我试试这个: request.addProperty(“correu”,userText.getText()。toString());
request.addProperty(“pass”,passText.getText()。toString());
现在的例外是:
org.ksoap2.serialization.SoapPrimitive
EDIT2:它有效!我改变了这个:
SoapObject resultado = (SoapObject) sobre.getResponse();
为此:
String resultado = sobre.getResponse().toString();
答案 0 :(得分:0)
试试这个
request.addProperty("correu", userText.getText().toString());
request.addProperty("pass", passText.getText().toString());
而不是
request.addProperty("correu", userText.getText());
request.addProperty("pass", passText.getText());