FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV 25
→
WX e WM - Lendo um retorno XML de um Webservice no Android e no iOS e arquivando os registros num array
WX e WM - Lendo um retorno XML de um Webservice no Android e no iOS e arquivando os registros num array
Débuté par adrianoboller, 14 avr. 2015 16:23 - 1 réponse
Connectez-vous…
adrianoboller
#1
Membre enregistré
3 655 messages
Popularité : +175 (223 votes)
Posté le 14 avril 2015 - 16:23
Procedure
WS_Taxi_Disponivel_New
(
LOCAL
DebugSN
)
//Posicao do Taxi
ok
,
b
Ret is
boolean
=
False
n
RetornoCodigo is
int
=
0
n
Contador is
int
=
0
s
CodClienteCelula is
string
=
""
XML_Retorno is
string
=
""
LocSt_TaxisLogados is ST_TaxisLogados
XML_Retorno
=
ws_mobile_consultar_posicoes_taxis
(
2912
,
9949
,
"SELECT"
)
// executa webservice e pega retorno
IF
DebugSN
=
"S"
THEN
fSaveText
(
"c:\posicao.txt"
,
XML_Retorno
)
END
XML_Retorno
=
WS_RemoveAcentos
(
XML_Retorno
)
////////////////////// ponto de entrada do codigo ios
//<Xml>
// <Retorno>
// <NoXml id="1">
// <ide_priori_cadast>0</ide_priori_cadast>
// <num_unidad>2</num_unidad>
// <val_latitu>-25.404832</val_latitu>
// <val_longit>-49.270872</val_longit>
// </NoXml>
// <NoXml id="2">
// <ide_priori_cadast>0</ide_priori_cadast>
// <num_unidad>3</num_unidad>
// <val_latitu>-25.387466</val_latitu>
// <val_longit>-49.24594</val_longit>
// </NoXml>
// </Retorno>
//</Xml>
ok
=
False
IF
Length
(
XML_Retorno
) >
0
THEN
ArrayDeleteAll
(
arr
_TaxisLogados
)
// limpa array
IF
IniOSMode
(
) =
True
THEN
/////////////////////////////////////////////////////////////
NoXml is
string
i is
int
=
1
LOOP
NoXml
=
XMLExtractString
(
XML_Retorno
,
"NoXml"
,i)
IF
NoXml
=
""
THEN
BREAK
END
LocSt_TaxisLogados.ST_ID
=
XMLExtractString
(
NoXml
,
"num_unidad"
)
LocSt_TaxisLogados.ST_Latitude
=
XMLExtractString
(
NoXml
,
"val_latitu"
,
1
)
LocSt_TaxisLogados.ST_Longitude
=
XMLExtractString
(
NoXml
,
"val_longit"
,
1
)
LocSt_TaxisLogados.ST_Situacao
=
XMLExtractString
(
NoXml
,
"ide_priori_cadast"
,
1
)
arr
_TaxisLogados
[
LocSt_TaxisLogados.ST_ID
] =
LocSt_TaxisLogados
n
Contador
+
+
i
+
+
ok
=
True
END
//loop
ELSE IF
InAndroidMode
(
) =
True
//<Xml>
// <Retorno>
// <NoXml id="1">
// <ide_priori_cadast>0</ide_priori_cadast>
// <num_unidad>2</num_unidad>
// <val_latitu>-25.404832</val_latitu>
// <val_longit>-49.270872</val_longit>
// </NoXml>
// <NoXml id="2">
// <ide_priori_cadast>0</ide_priori_cadast>
// <num_unidad>3</num_unidad>
// <val_latitu>-25.387466</val_latitu>
// <val_longit>-49.24594</val_longit>
// </NoXml>
// </Retorno>
//</Xml>
//Aqui é a definição de ler o xml e pegar os dados de cada taxi
//Leitura do xml
XmlDoc is
XMLDocument
//Carrega o retornoc ajustado em um XmlDoc é uma string tomando formado de xml em um xmlDoc
XmlDoc
=
XMLOpen
(
XML_Retorno
,
fromString
)
//Define o Nó Raiz de leitura - onde comeca e termina cada taxi a ser lido
NoXml is
xmlNode
//Leitura do xml em loop--- aqui que o bicho pega e começa a ler
FOR EACH NoXml OF XmlDoc.Xml.Retorno on NoXml
//incluir registros na queue/
IF
NoXml.num_unidad
<
>
Null
AND
NoXml.val_latitu
<
>
Null
AND
NoXml.val_longit
<
>
Null
THEN
ok
=
True
n
Contador
+
=
1
LocSt_TaxisLogados.ST_ID
=
NoXml.num_unidad
LocSt_TaxisLogados.ST_Latitude
=
NoXml.val_latitu
LocSt_TaxisLogados.ST_Longitude
=
NoXml.val_longit
LocSt_TaxisLogados.ST_Situacao
=
NoXml.ide_priori_cadast
//incluir - Add in Queue - incluir registro na queue // struct de memoria // tabela de memoria
arr
_TaxisLogados
[
LocSt_TaxisLogados.ST_ID
] =
LocSt_TaxisLogados
END
END
END
END
//retorno da funcao é deu certo ou deu errado com true ou false
IF
DebugSN
=
"S"
THEN
Info
(
"Qtde de Taxis Disponiveis:"
,
n
Contador
)
END
RESULT
(
ok
)
Signaler
1
0
MarcosRoberto
#2
Membre enregistré
11 messages
Popularité : +2 (2 votes)
Posté le 14 avril 2015 - 18:09
Muito bem documentada. Excelente! Parabens!
Signaler
1
0
→ Revenir à WINDEV 25
WINDEV 25
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte