Search in sources :

Example 1 with KvmSerializable

use of org.ksoap2.serialization.KvmSerializable in project ETSMobile-Android2 by ApplETS.

the class Helper method convertToHeader.

public static Element convertToHeader(Object obj, String namespace, String name) {
    Element parentElement = new org.kxml2.kdom.Element().createElement(namespace, name);
    if (obj == null) {
        return parentElement;
    }
    if (obj instanceof KvmSerializable) {
        KvmSerializable soapObject = (KvmSerializable) obj;
        for (int i = 0; i < soapObject.getPropertyCount(); i++) {
            PropertyInfo info = new PropertyInfo();
            soapObject.getPropertyInfo(i, new Hashtable(), info);
            info.setValue(soapObject.getProperty(i));
            Element el1 = convertToHeader(info.getValue(), info.getNamespace(), info.getName());
            parentElement.addChild(Node.ELEMENT, el1);
        }
    } else {
        String value = obj.toString();
        parentElement.addChild(org.kxml2.kdom.Node.TEXT, value);
    }
    return parentElement;
}
Also used : Hashtable(java.util.Hashtable) Element(org.kxml2.kdom.Element) KvmSerializable(org.ksoap2.serialization.KvmSerializable) PropertyInfo(org.ksoap2.serialization.PropertyInfo) Element(org.kxml2.kdom.Element)

Example 2 with KvmSerializable

use of org.ksoap2.serialization.KvmSerializable in project ETSMobile-Android2 by ApplETS.

the class ExtendedSoapSerializationEnvelope method writeObjectBody.

@Override
public void writeObjectBody(XmlSerializer writer, KvmSerializable obj) throws IOException {
    if (obj instanceof AttributeContainer) {
        AttributeContainer soapObject = (AttributeContainer) obj;
        int cnt = soapObject.getAttributeCount();
        for (int counter = 0; counter < cnt; counter++) {
            AttributeInfo attributeInfo = new AttributeInfo();
            soapObject.getAttributeInfo(counter, attributeInfo);
            writer.attribute(attributeInfo.getNamespace(), attributeInfo.getName(), attributeInfo.getValue() != null ? attributeInfo.getValue().toString() : "");
        }
    }
    super.writeObjectBody(writer, obj);
}
Also used : AttributeInfo(org.ksoap2.serialization.AttributeInfo) AttributeContainer(org.ksoap2.serialization.AttributeContainer)

Aggregations

Hashtable (java.util.Hashtable)1 AttributeContainer (org.ksoap2.serialization.AttributeContainer)1 AttributeInfo (org.ksoap2.serialization.AttributeInfo)1 KvmSerializable (org.ksoap2.serialization.KvmSerializable)1 PropertyInfo (org.ksoap2.serialization.PropertyInfo)1 Element (org.kxml2.kdom.Element)1