我遇到了一个问题,在我的程序中,我得到了 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:WARN/System.err(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: WARN/System.err(688): at org.kxml2.io.KXmlParser.exception(KXmlParser.java:273) 06- 20 18:12:23.108: WARN/System.err(688): 在 org.kxml2.io.KXmlParser.require(KXmlParser.java:1431) 06-20 18:12:23.108: WARN/System.err(688) : 在 org.ksoap2.SoapEnvelope.parse(Unknown Source) 06-20 18:12:23.108: WARN/System.err(688): at org.ksoap2.transport.Transport.parseResponse(Unknown Source) 06-20 18: 12:23.108: WARN/System.err(688): at org.ksoap2.transport.HttpTransportSE.call(Unknown Source) 06-20 18:12:23.118: WARN/System.err(688): at com.soap。登记。register(Register.java:189) 06-20 18:12:23.118: WARN/System.err(688): at com.soap.Register$1$1.run(Register.java:42)