Web Service Android Application : Cannot serialize 1.0

前端 未结 1 1835
春和景丽
春和景丽 2021-01-17 03:52

P.S : I have looked at similar questions but haven\'t been able to understand what to do. They talk about using a marshal class, which I can\'t seem to unde

1条回答
  •  臣服心动
    2021-01-17 04:08

    Implement a Marshal for the Double

    public class MarshalDouble implements Marshal 
    {
    
    @Override
    public Object readInstance(XmlPullParser parser, String namespace, String name, 
            PropertyInfo expected) throws IOException, XmlPullParserException {
    
        return Double.parseDouble(parser.nextText());
    }
    
    public void register(SoapSerializationEnvelope cm) {
         cm.addMapping(cm.xsd, "double", Double.class, this);
    
    }
    
    @Override
    public void writeInstance(XmlSerializer writer, Object obj) throws IOException {
           writer.text(obj.toString());
        }           
    }
    

    Then call There register method in your code.

    new MarshalDouble().register(envelope);
    

    0 讨论(0)
提交回复
热议问题