Search in sources :

Example 1 with SoapPrimitive

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

the class WebServiceSoap method GetFiche.

public String GetFiche(final String numero, final String PathFiche) throws Exception {
    return (String) execute(new IWcfMethod() {

        @Override
        public ExtendedSoapSerializationEnvelope CreateSoapEnvelope() {
            ExtendedSoapSerializationEnvelope __envelope = createEnvelope();
            SoapObject __soapReq = new SoapObject("http://etsmtl.ca/", "GetFiche");
            __envelope.setOutputSoapObject(__soapReq);
            PropertyInfo __info = null;
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "numero";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(numero);
            __soapReq.addProperty(__info);
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "PathFiche";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(PathFiche);
            __soapReq.addProperty(__info);
            return __envelope;
        }

        @Override
        public Object ProcessResult(ExtendedSoapSerializationEnvelope __envelope, SoapObject __result) throws Exception {
            Object obj = __result.getProperty("GetFicheResult");
            if (obj != null && obj.getClass().equals(SoapPrimitive.class)) {
                SoapPrimitive j = (SoapPrimitive) __result.getProperty("GetFicheResult");
                return j.toString();
            }
            return null;
        }
    }, "http://etsmtl.ca/GetFiche");
}
Also used : SoapObject(org.ksoap2.serialization.SoapObject) SoapObject(org.ksoap2.serialization.SoapObject) PropertyInfo(org.ksoap2.serialization.PropertyInfo) SoapPrimitive(org.ksoap2.serialization.SoapPrimitive)

Example 2 with SoapPrimitive

use of org.ksoap2.serialization.SoapPrimitive in project SeaStar by 13120241790.

the class SoapManager method getSoapresult.

/**
	 * 将SoapObject转json字符串
	 * @param soapresult SoapObject
	 * @param jsonResult JSONObject
	 */
private void getSoapresult(SoapObject soapresult, JSONObject jsonResult, HashSet<String> hashset) {
    try {
        if (soapresult != null) {
            PropertyInfo proinfo = null;
            SoapObject childsoap = null;
            JSONObject childJson = null;
            String curName = null;
            int count = soapresult.getPropertyCount();
            for (int i = 0; i < count; i++) {
                //获取当前节点的信息
                proinfo = new PropertyInfo();
                soapresult.getPropertyInfo(i, proinfo);
                curName = proinfo.getName();
                //判断当前节点的类型,如果是SoapPrimitive则可以直接取值,如果是SoapObject则继续解析
                if (SoapPrimitive.class == proinfo.getType()) {
                    jsonResult.put(curName, proinfo.getValue());
                } else if (SoapObject.class == proinfo.getType()) {
                    childJson = new JSONObject();
                    childsoap = (SoapObject) soapresult.getProperty(i);
                    //判断该节点下面有相同节点,那么他就是一个数组
                    if (isArrayNode(childsoap)) {
                        hashset.add(curName);
                        NLog.e(tag, "curName : " + curName);
                    }
                    //处理相同名字的节点,到时候好替换成JSONArray
                    if (jsonResult.has(curName)) {
                        curName = curName + i;
                    }
                    //递归调用自己,获取子节点
                    getSoapresult(childsoap, childJson, hashset);
                    //将子节点添加到根节点下面
                    jsonResult.put(curName, childJson);
                }
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : JSONObject(org.json.JSONObject) SoapObject(org.ksoap2.serialization.SoapObject) JSONException(org.json.JSONException) PropertyInfo(org.ksoap2.serialization.PropertyInfo)

Example 3 with SoapPrimitive

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

the class SignetsMobileSoap method donneesAuthentificationValides.

/**
	 * Retourne 'true' si le code d'acc��s universel et le mot de passe sont
	 * valides dans AD des ��tudiants
	 */
public Boolean donneesAuthentificationValides(final String codeAccesUniversel, final String motPasse) throws Exception {
    return (Boolean) execute(new IWcfMethod() {

        @Override
        public ExtendedSoapSerializationEnvelope CreateSoapEnvelope() {
            ExtendedSoapSerializationEnvelope __envelope = createEnvelope();
            SoapObject __soapReq = new SoapObject("http://etsmtl.ca/", "donneesAuthentificationValides");
            __envelope.setOutputSoapObject(__soapReq);
            PropertyInfo __info = null;
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "codeAccesUniversel";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(codeAccesUniversel);
            __soapReq.addProperty(__info);
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "motPasse";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(motPasse);
            __soapReq.addProperty(__info);
            return __envelope;
        }

        @Override
        public Object ProcessResult(ExtendedSoapSerializationEnvelope __envelope, SoapObject __result) throws Exception {
            Object obj = __result.getProperty("donneesAuthentificationValidesResult");
            if (obj != null && obj.getClass().equals(SoapPrimitive.class)) {
                SoapPrimitive j = (SoapPrimitive) __result.getProperty("donneesAuthentificationValidesResult");
                return new Boolean(j.toString());
            }
            return null;
        }
    }, "http://etsmtl.ca/donneesAuthentificationValides");
}
Also used : SoapObject(org.ksoap2.serialization.SoapObject) SoapObject(org.ksoap2.serialization.SoapObject) PropertyInfo(org.ksoap2.serialization.PropertyInfo) SoapPrimitive(org.ksoap2.serialization.SoapPrimitive)

Example 4 with SoapPrimitive

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

the class Helper method convertToSoapObject.

public static Object convertToSoapObject(Element element) {
    if (element.getChildCount() == 0 || (element.getChildCount() == 1 && !(element.getChild(0) instanceof Element))) {
        SoapPrimitive primitive = new SoapPrimitive(element.getNamespace(), element.getName(), element.getChildCount() == 1 ? element.getText(0) : null);
        return primitive;
    } else {
        SoapObject obj = new SoapObject(element.getNamespace(), element.getName());
        for (int i = 0; i < element.getChildCount(); i++) {
            Element childElement = element.getElement(i);
            Object childObject = convertToSoapObject(childElement);
            if (childObject instanceof SoapObject) {
                SoapObject soapObj = (SoapObject) childObject;
                obj.addProperty(soapObj.getName(), childObject);
            } else {
                SoapPrimitive primitive = (SoapPrimitive) childObject;
                obj.addProperty(primitive.getName(), primitive);
            }
        }
        return obj;
    }
}
Also used : Element(org.kxml2.kdom.Element) SoapObject(org.ksoap2.serialization.SoapObject) SoapObject(org.ksoap2.serialization.SoapObject) SoapPrimitive(org.ksoap2.serialization.SoapPrimitive)

Example 5 with SoapPrimitive

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

the class SignetsMobileSoap method echo.

public String echo(final String chaine) throws Exception {
    return (String) execute(new IWcfMethod() {

        @Override
        public ExtendedSoapSerializationEnvelope CreateSoapEnvelope() {
            ExtendedSoapSerializationEnvelope __envelope = createEnvelope();
            SoapObject __soapReq = new SoapObject("http://etsmtl.ca/", "echo");
            __envelope.setOutputSoapObject(__soapReq);
            PropertyInfo __info = null;
            __info = new PropertyInfo();
            __info.namespace = "http://etsmtl.ca/";
            __info.name = "chaine";
            __info.type = PropertyInfo.STRING_CLASS;
            __info.setValue(chaine);
            __soapReq.addProperty(__info);
            return __envelope;
        }

        @Override
        public Object ProcessResult(ExtendedSoapSerializationEnvelope __envelope, SoapObject __result) throws Exception {
            Object obj = __result.getProperty("echoResult");
            if (obj != null && obj.getClass().equals(SoapPrimitive.class)) {
                SoapPrimitive j = (SoapPrimitive) __result.getProperty("echoResult");
                return j.toString();
            }
            return null;
        }
    }, "http://etsmtl.ca/echo");
}
Also used : SoapObject(org.ksoap2.serialization.SoapObject) SoapObject(org.ksoap2.serialization.SoapObject) PropertyInfo(org.ksoap2.serialization.PropertyInfo) SoapPrimitive(org.ksoap2.serialization.SoapPrimitive)

Aggregations

SoapObject (org.ksoap2.serialization.SoapObject)6 PropertyInfo (org.ksoap2.serialization.PropertyInfo)5 SoapPrimitive (org.ksoap2.serialization.SoapPrimitive)5 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 Element (org.kxml2.kdom.Element)1