1

我需要从我的 android 应用程序连接到 WCF Web 服务以进行登录身份验证,为此,我已将ksoap2-android-assembly-2.4-jar-with-dependencies.jar添加到我的项目中。下面是我的代码。

String emailtxt = null, password;

    emailtxt = email.getText().toString().trim();
    password = pwd.getText().toString().trim();

    Log.d("email", emailtxt);
    Log.d("password", password);

    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    /*request.addProperty("arg0", emailtxt);
    request.addProperty("arg1", password);*/


    PropertyInfo pi = new PropertyInfo();
    pi.setName("UserName");
    pi.setValue(emailtxt);
    pi.setType(String.class);
    request.addProperty(pi);

    PropertyInfo pi2 = new PropertyInfo();
    pi2.setName("Password");
    pi2.setValue(password);
    pi2.setType(String.class);
    request.addProperty(pi2);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    envelope.dotNet = true;
    envelope.setOutputSoapObject(request);

    AndroidHttpTransport httpTransport = new AndroidHttpTransport(URL);
    httpTransport.debug = true;
    SoapObject result = null;
    try {
        httpTransport.call(SOAP_ACTION, envelope);
        result = (SoapObject) envelope.getResponse();
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (result == null)
        Log.d("if resp null", result + "");
    else {
        // anything below this line relates to the service return type, may
        // not apply to you
        boolean success = Boolean.valueOf(result.getProperty("success")
                .toString());

        Log.d("login resp...not null", success + "");
    }

但是我在我的 logcat 中得到了 XMLPullParserException。谁能告诉我如何解决它?谢谢你的帮助。

4

0 回答 0