【发布时间】:2011-06-20 13:05:43
【问题描述】:
我遇到了一个问题,在我的程序中,我得到了 xmlpullparser 异常,我用眼睛看了一下,但是由于我是 android 新手,所以我无法理解如何解决这个问题。我纠正了我的程序很多,但我还是不能,有人帮我解决这个问题
我正在使用 WSDL、KSOAP1.2。
提前谢谢....!
这是我的代码
public void register() {
Log.v(TAG, "Trying to Login");
EditText etxt_user = (EditText) findViewById(R.id.regetfirstname);
EditText etxt_pass = (EditText) findViewById(R.id.regetlastname);
EditText etxt_dob = (EditText) findViewById(R.id.regetdob);
EditText etxt_email = (EditText) findViewById(R.id.regetemail);
EditText etxt_password = (EditText) findViewById(R.id.regetpwd);
EditText etxt_confirmpassword = (EditText) findViewById(R.id.regetrepwd);
EditText etxt_mobno = (EditText) findViewById(R.id.regetmobno);
final Button regmalebtn = (Button) findViewById(R.id.regmalebtn);
Button regfemalebtn = (Button) findViewById(R.id.regfemalebtn);
// String deviceid = null;
String fname = etxt_user.getText().toString();
String lname = etxt_pass.getText().toString();
String dob = etxt_dob.getText().toString();
String contact = etxt_mobno.getText().toString();
String password;
String confirmpassword ;
String email = etxt_email.getText().toString();
password = etxt_password.getText().toString();
confirmpassword = etxt_confirmpassword.getText().toString();
final SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(request);
HttpTransportSE aht = new HttpTransportSE(URL);
try {
// boolean pstatus = false;
if (confirmpassword != null && password != null)
{
if (password.equals(confirmpassword))
{
request.addProperty("password", password);
}
}
regmalebtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// String gender = regmalebtn.getText().toString();
String gender;
gender = ((Button)findViewById(R.id.regmalebtn)).getText().toString();
gender.equals("male");
request.addProperty("gender", gender);
}
});
regfemalebtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// String gender = regmalebtn.getText().toString();
// request.addProperty("gender", gender);
String gender;
gender = ((Button)findViewById(R.id.regfemalebtn)).getText().toString();
gender.equals("female");
request.addProperty("gender", gender);
}
});
request.addProperty("email", email);
request.addProperty("contact", contact);
request.addProperty("fname", fname);
request.addProperty("lname", lname);
request.addProperty("dateofbirth", dob);
//request.addProperty("password", "password");
request.addProperty("latitude", 76);
request.addProperty("longitude", 82);
request.addProperty("device_id", "12345");
aht.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
aht.call(SOAP_ACTION, soapEnvelope);
// SoapObject result = (SoapObject)soapEnvelope.getResponse();
SoapObject resultsRequestSOAP = (SoapObject) soapEnvelope.bodyIn;
Log.v("TAG", String.valueOf(resultsRequestSOAP));
//String resultData;
// resultData = request.getProperty(0).toString();
} catch (Exception e) {
e.printStackTrace();
}
}
}
这些是 logcat 消息
06-20 18:12:23.099: 警告/系统错误(688): org.xmlpull.v1.XmlPullParserException: 预计:START_TAG {http://schemas.xmlsoap.org/soap/envelope/}信封 (位置:START_TAG @1:6 in java.io.InputStreamReader@43e88978) 06-20 18:12:23.099: 警告/System.err(688):在 org.kxml2.io.KXmlParser.exception(KXmlParser.java:273) 06-20 18:12:23.108: 警告/System.err(688):在 org.kxml2.io.KXmlParser.require(KXmlParser.java:1431) 06-20 18:12:23.108: 警告/System.err(688):在 org.ksoap2.SoapEnvelope.parse(未知 来源) 06-20 18:12:23.108: 警告/System.err(688):在 org.ksoap2.transport.Transport.parseResponse(未知 来源) 06-20 18:12:23.108: 警告/System.err(688):在 org.ksoap2.transport.HttpTransportSE.call(未知 来源) 06-20 18:12:23.118: 警告/System.err(688):在 com.soap.Register.register(Register.java:189) 06-20 18:12:23.118: 警告/System.err(688):在 com.soap.Register$1$1.run(Register.java:42)
【问题讨论】:
-
这似乎更像是您的 XML 本身的问题,而不是您的解析器的问题。
-
@dmon 你的意思是 WSDL 或其他问题
-
我认为您的问题已得到解答,请访问 [这里][1] [1]:stackoverflow.com/questions/24606552/…
标签: android web-services exception xmlpullparser