1

感谢您阅读我的问题,我正在尝试将自定义 ArrayList 传递给 SOAP 服务,这使我无法序列化异常,

这是我的代码

    // Initialize soap request + add parameters
    SoapObject request = new SoapObject(NAMESPACE, METHOD_CALL);

    UserInfo userInfo = new UserInfo();
    userInfo.name = "xyz";
    userInfo.keyName = "name";
    userInfoList.add(userInfo);

    UserInfo userInfo1 = new UserInfo();
    userInfo1.email = "xcv@gmail.com";
    userInfo1.keyEmail = "email_id";
    userInfoList.add(userInfo1);

    UserInfo userInfo2 = new UserInfo();
    userInfo2.mobile = "9876543210";
    userInfo2.keyMob = "mobileno";
    userInfoList.add(userInfo2);

    UserInfo userInfo3 = new UserInfo();
    userInfo3.regId = "xyz";
    userInfo3.keyRegId = "registrationid";
    userInfoList.add(userInfo3);

    UserInfo userInfo4 = new UserInfo();
    userInfo4.appVersion = "1.0";
    userInfo4.keyAppVersion = "appversion";
    userInfoList.add(userInfo4);


    UserInfo userInfo5 = new UserInfo();
            userInfo5.xmlString = 
           "<?xml version=\"1.0\" encoding=\"UTF-   8\"standalone=\"no\"?>"    
            + "<a><s><s>"
            + "<d>d</d>"
            + "<f>f</f>"
            + "</a>"

    userInfo5.keyXmlString = "xml_string";

    userInfoList.add(userInfo5);


    request.addProperty("method", "addDeviceInfo");
    request.addProperty("parameter", userInfoList);



    Log.e("request", "--->>>  " + request);

    // Declare the version of the SOAP request
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
            SoapEnvelope.VER11);
    Log.e("1111", "1111");
    envelope.setOutputSoapObject(request);
    Log.e("222", "222");
    envelope.dotNet = false;
    envelope.bodyOut = request;
    envelope.encodingStyle = SoapSerializationEnvelope.XSD;
    Log.e("333", "3333");
    // Needed to make the internet call
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
    Log.e("44444", "44444");
    androidHttpTransport.debug = true;

    try {
        Log.e("55555", "55555");
        // this is the actual part that will call the webservice
        androidHttpTransport.call(MainActivity.SOAP_ACTION, envelope);

        Log.e("Request", androidHttpTransport.requestDump);
        Log.e("Response", androidHttpTransport.responseDump);

    } catch (Exception e) {
        e.printStackTrace();
    }

    try {
        SoapObject result = (SoapObject) envelope.bodyIn;
        Log.e("result", "--->>   " + result);
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }

问题是我得到了一切正确但是当谈到 androidHttpTransport.call(MainActivity.SOAP_ACTION, envelope);

是说 java.lang.RuntimeException:无法序列化:[com.example.soapdemo.UserInfo@40da80a8]

这是我的用户信息类

   package com.example.soapdemo;

 import java.io.Serializable;
  import java.util.Hashtable;

  import org.apache.http.entity.SerializableEntity;
  import org.ksoap2.serialization.KvmSerializable;
  import org.ksoap2.serialization.PropertyInfo;

  public class UserInfo implements Serializable {


public String  keyName;// = "name";
public String name;
public String keyEmail;// = "email_id";
public String email;
public String keyMob;// = "mobile_no";
public String mobile;
public String keyRegId;// = "registration_id";
public String regId;
public String appVersion;
public String keyAppVersion;
public String xmlString;
public String keyXmlString;




 }

帮我解决这个问题,任何回复都非常可观提前谢谢

我已经浏览了很多页面,但无法解决这个问题,如果有人能解决这个问题并帮助我,我将不胜感激

非常感谢您

4

0 回答 0