1
Webサービスリクエストのパラメータとして列挙型を追加します。 私はAndroid上ksoap2使用しますが、私はjava.lang.RuntimeExceptionを得た:シリアライズすることはできません:不定 パス列挙 は私が列挙を実装する際に従うHow to pass an enum value to wcf webservice私はpass enumをパラメータとしてksoap2-android経由でWebサービスを呼び出すときにRuntimeExceptionが発生しました
によってパラメータとしてDrivingLicenseTypeEnumを渡すinterface BaseEnum extends Marshal
{
public String getDesc(Enum en);
}
enum DrivingLicenseTypeEnum implements BaseEnum
{
UNDEFINED,
NSURED_DRIVER_INJURED,
INSURED_PASSENGER_INJURED,
PARTY_DRIVER_INJURED,
PARTY_PASSENGER_INJURED,
THIRD_PARTY_INJURED,
INSURED_VEHICLE_DAMAGE,
PARTY_VEHICLE_DAMAGE,
ASSET;
public String getDesc(Enum en) {
String result="";
//generate description
return result;
}
public Object readInstance(XmlPullParser arg0, String arg1, String arg2,
PropertyInfo arg3) throws IOException, XmlPullParserException {
// TODO Auto-generated method stub
return DrivingLicenseTypeEnum.valueOf(arg0.nextText());
}
public void register(SoapSerializationEnvelope arg0) {
arg0.addMapping("http://tempuri.org/", "DrivingLicenseTypeEnum", DrivingLicenseTypeEnum.class);
}
public void writeInstance(XmlSerializer arg0, Object arg1)
throws IOException {
arg0.text(((DrivingLicenseTypeEnum)arg1).name());
}
}
と(Fildorの答え)
DrivingLicenseTypeEnum c = DrivingLicenseTypeEnum.UNDEFINED;
PropertyInfo pi=new PropertyInfo();
pi.setName("driverLicenseType");
pi.setValue(c);
pi.setType(DrivingLicenseTypeEnum.class);
request.addProperty(pi);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
c.register(envelope);
この問題を解決してもらえますか? ありがとうございます。