Search in sources :

Example 11 with PropertyInfo

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

the class SoapManager method isArrayNode.

/**
	 * 判断该节点下面是否有相同的节点,如果说明是数组
	 * @param childsoap
	 * @return
	 */
public boolean isArrayNode(SoapObject childsoap) {
    PropertyInfo proinfo = null;
    int count = childsoap.getPropertyCount();
    for (int i = 0; i < count; i++) {
        proinfo = new PropertyInfo();
        childsoap.getPropertyInfo(i, proinfo);
        if (SoapObject.class == proinfo.getType()) {
            if (childsoap.hasProperty(proinfo.getName())) {
                return true;
            }
        }
    }
    return false;
}
Also used : PropertyInfo(org.ksoap2.serialization.PropertyInfo)

Example 12 with PropertyInfo

use of org.ksoap2.serialization.PropertyInfo 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 13 with PropertyInfo

use of org.ksoap2.serialization.PropertyInfo 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 14 with PropertyInfo

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

the class SignetsMobileSoap method listeCours.

/**
	 * Liste de tous les cours de l'��tudiant: sigle, groupe, session,
	 * programme, cote finale, nombre de cr��dits et titre du cours, tri��e par
	 * session et sigle.
	 */
public ListeDeCours listeCours(final String codeAccesUniversel, final String motPasse) throws Exception {
    return (ListeDeCours) execute(new IWcfMethod() {

        @Override
        public ExtendedSoapSerializationEnvelope CreateSoapEnvelope() {
            ExtendedSoapSerializationEnvelope __envelope = createEnvelope();
            SoapObject __soapReq = new SoapObject("http://etsmtl.ca/", "listeCours");
            __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 {
            return (ListeDeCours) getResult(ListeDeCours.class, __result, "listeCoursResult", __envelope);
        }
    }, "http://etsmtl.ca/listeCours");
}
Also used : ListeDeCours(ca.etsmtl.applets.etsmobile.model.ListeDeCours) SoapObject(org.ksoap2.serialization.SoapObject) PropertyInfo(org.ksoap2.serialization.PropertyInfo)

Example 15 with PropertyInfo

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

the class SignetsMobileSoap method lireHoraire.

/**
	 * Liste des cours pour le trimestre et le sigle de cours partiel pass��s en
	 * param��tres. Tous les CTN1 �� l'hiver 2012, par exemple
	 */
public listeCoursHoraire lireHoraire(final String pSession, final String prefixeSigleCours) throws Exception {
    return (listeCoursHoraire) execute(new IWcfMethod() {

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

        @Override
        public Object ProcessResult(ExtendedSoapSerializationEnvelope __envelope, SoapObject __result) throws Exception {
            return (listeCoursHoraire) getResult(listeCoursHoraire.class, __result, "lireHoraireResult", __envelope);
        }
    }, "http://etsmtl.ca/lireHoraire");
}
Also used : ca.etsmtl.applets.etsmobile.model.listeCoursHoraire(ca.etsmtl.applets.etsmobile.model.listeCoursHoraire) SoapObject(org.ksoap2.serialization.SoapObject) PropertyInfo(org.ksoap2.serialization.PropertyInfo)

Aggregations

PropertyInfo (org.ksoap2.serialization.PropertyInfo)23 SoapObject (org.ksoap2.serialization.SoapObject)22 SoapPrimitive (org.ksoap2.serialization.SoapPrimitive)4 ArrayOfFicheEmploye (ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)2 ListeDeCours (ca.etsmtl.applets.etsmobile.model.ListeDeCours)2 ArrayOfFicheEmployeDate (ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmployeDate)1 ArrayOfService (ca.etsmtl.applets.etsmobile.model.ArrayOfService)1 Etudiant (ca.etsmtl.applets.etsmobile.model.Etudiant)1 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)1 ListeDeSessions (ca.etsmtl.applets.etsmobile.model.ListeDeSessions)1 ListeDesElementsEvaluation (ca.etsmtl.applets.etsmobile.model.ListeDesElementsEvaluation)1 ca.etsmtl.applets.etsmobile.model.listeCoursHoraire (ca.etsmtl.applets.etsmobile.model.listeCoursHoraire)1 ca.etsmtl.applets.etsmobile.model.listeDesActivitesEtProf (ca.etsmtl.applets.etsmobile.model.listeDesActivitesEtProf)1 ca.etsmtl.applets.etsmobile.model.listeDesCoequipiers (ca.etsmtl.applets.etsmobile.model.listeDesCoequipiers)1 ca.etsmtl.applets.etsmobile.model.listeDesProgrammes (ca.etsmtl.applets.etsmobile.model.listeDesProgrammes)1 ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux (ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux)1 ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces (ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces)1 ca.etsmtl.applets.etsmobile.model.listeSeances (ca.etsmtl.applets.etsmobile.model.listeSeances)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1