Android:XmlpullParser 异常

发布于 2024-11-16 07:00:27 字数 4633 浏览 3 评论 0原文

我遇到了一个问题,在我的程序中,我遇到了 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 英寸 java.io.InputStreamReader@43e88978) 06-20 18:12:23.099: 警告/系统错误(688):位于 org.kxml2.io.KXmlParser.异常(KXmlParser.java:273) 06-20 18:12:23.108: 警告/系统错误(688):位于 org.kxml2.io.KXmlParser.require(KXmlParser.java:1431) 06-20 18:12:23.108: 警告/系统错误(688):位于 org.ksoap2.SoapEnvelope.parse(未知 来源)06-20 18:12:23.108: 警告/系统错误(688):位于 org.ksoap2.transport.Transport.parseResponse(未知 来源)06-20 18:12:23.108: 警告/系统错误(688):位于 org.ksoap2.transport.HttpTransportSE.call(未知 来源)06-20 18:12:23.118: 警告/系统错误(688):位于 com.soap.Register.register(Register.java:189) 06-20 18:12:23.118: 警告/系统错误(688):位于 com.soap.Register$1$1.run(Register.java:42)

I got stuck with a problem, In my program I am getting the xmlpullparser exception and I goggled it but as I am new to android I couldn't able to understand how to solve the issue. I corrected my program a lot still I couldn't, some one help me to solve this

I am using WSDL,KSOAP1.2.

Thanks in advance....!

Here is my code

   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();
    }


}

}

These are the logcat messages

06-20 18:12:23.099:
WARN/System.err(688):
org.xmlpull.v1.XmlPullParserException:
expected: START_TAG
{http://schemas.xmlsoap.org/soap/envelope/}Envelope
(position: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): at
org.kxml2.io.KXmlParser.require(KXmlParser.java:1431)
06-20 18:12:23.108:
WARN/System.err(688): at
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(Register.java:189)
06-20 18:12:23.118:
WARN/System.err(688): at
com.soap.Register$1$1.run(Register.java:42)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

昨迟人 2024-11-23 07:00:27
public static void getAllXML(String url) throws 
XmlPullParserException, IOException, URISyntaxException{ 
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser parser = factory.newPullParser(); 
parser.setInput(new InputStreamReader(getUrlData(url)));  
XmlUtils.beginDocument(parser,"results");
int eventType = parser.getEventType();
do{
  XmlUtils.nextElement(parser);
  parser.next();
  eventType = parser.getEventType();
  if(eventType == XmlPullParser.TEXT){
  Log.d("test",parser.getText());
}
} while (eventType != XmlPullParser.END_DOCUMENT) ;       
}
public InputStream getUrlData(String url) 
throws URISyntaxException, ClientProtocolException, IOException {
 DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(new URI(url));
  HttpResponse res = client.execute(method);
return  res.getEntity().getContent();
}
public static void getAllXML(String url) throws 
XmlPullParserException, IOException, URISyntaxException{ 
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser parser = factory.newPullParser(); 
parser.setInput(new InputStreamReader(getUrlData(url)));  
XmlUtils.beginDocument(parser,"results");
int eventType = parser.getEventType();
do{
  XmlUtils.nextElement(parser);
  parser.next();
  eventType = parser.getEventType();
  if(eventType == XmlPullParser.TEXT){
  Log.d("test",parser.getText());
}
} while (eventType != XmlPullParser.END_DOCUMENT) ;       
}
public InputStream getUrlData(String url) 
throws URISyntaxException, ClientProtocolException, IOException {
 DefaultHttpClient client = new DefaultHttpClient();
HttpGet method = new HttpGet(new URI(url));
  HttpResponse res = client.execute(method);
return  res.getEntity().getContent();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文