application flex & 4D (problèmes webService)
Bonjour,
Je me permets d'ouvrir une discussion au sujet des problèmes que je rencontre lors d'échanges échanges SOAP entre 2 applications.
Certaines erreurs et 'symptômes' classiques sont abordés sur divers forums, et bien souvent ceux-ci sont issus de problèmes liés à la sécurité flash (fichier de régulation "crossdomain.xml" manquant ou mal paramétré sur le serveur web, etc...)
Je travaille sur un front office réalisé en Flex et un back office basé sur une architecture "4D".
Je me sert d'un webService pour requêter la base de données et réactualiser périodiquement les informations présentes sur une des 'pages' de mon front office.
Ce webService est appelé toutes les 5 secondes.
Lorsque je lance l'application, tout se passe très bien généralement :) Exception faite, il arrive que l'initialisation de certains webServices échoue avec des erreurs du genre:
Citation:
- [RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (https://host1.domain.com/null/4dwsdl)"]
Mais au bout d'un certain temps, je ne reçois plus de réponse exploitable, mais que des erreurs successives via le gestionnaire (errorEvent...), avec des erreurs du genre:
Citation:
- [RPC Fault faultString="SOAP Response cannot be decoded. Raw response: " faultCode="DecodingError" faultDetail="null"]
- [RPC Fault faultString="SOAP Response Version Mismatch" faultCode="DecodingError" faultDetail="null"]
- [RPC Fault faultString="Error (tiens, là ça a l'air tronqué :)
Je tente de reproduire le problème en réalisant une application simple implémentant ce webService uniquement:
########### Le fichier vue (test_WS_getFlipBookPageIdProperties.mxml) ###########
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import services.ws_pageproperties.WS_pageProperties;
private var _controller:controller;
private var _myService:WS_pageProperties;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
// pId:
_myService = new WS_pageProperties();
_controller = new controller(this, _myService);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Placer ici les éléments non visuels (services et objets de valeur, par exemple). -->
</fx:Declarations>
<mx:TileList id="fieldList" left="10" top="25" bottom="50" width="474" color="#000000"
horizontalCenter="-277" itemRenderer="renderers.renderer_fieldList"/>
<mx:TileList id="histoList" right="10" top="25" bottom="50" width="474" color="#000000"
horizontalCenter="277" itemRenderer="renderers.renderer_histoList"/>
<s:Label left="10" bottom="10" width="120" height="30" text="Treatment time (ms): "
textAlign="center" verticalAlign="middle"/>
<s:Label id="resTime" left="130" bottom="10" width="120" height="30" color="#1724D2"
fontSize="14" text="-" textAlign="center" verticalAlign="middle"/>
</s:Application> |
########### Le fichier Contrôleur (controller.as) ###########
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
| package
{
import flash.events.TimerEvent;
import flash.utils.Timer;
import utils.timeFcts;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.rpc.AsyncToken;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import services.ws_pageproperties.WS_pageProperties;
/**
* @author user
*/
public class controller
{
private var _view:test_WS_getFlipBookPageIdProperties;
private var _service:WS_pageProperties;
private var _timer:Timer;
public function controller(view:test_WS_getFlipBookPageIdProperties, service:WS_pageProperties)
{
_view = view;
_service = service;
_service.addEventListener(ResultEvent.RESULT, WS_resultHandler);
_service.addEventListener(FaultEvent.FAULT, WS_faultHandler);
_timer = new Timer(5000, 1);
_timer.addEventListener(TimerEvent.TIMER_COMPLETE, timer_completeHandler);
_timer.start();
}
private function WS_resultHandler(event:ResultEvent):void
{
var spentTime:uint = timeFcts.GetMsTimestamp() - event.token.reqTime;
_view.resTime.text = spentTime.toString();
var i:int;
// retours webService:
var tchampType:ArrayCollection;
var tchampNom:ArrayCollection;
var tchampValeur:ArrayCollection;
var tpage_histoTS:ArrayCollection;
var tpage_histoUserId:ArrayCollection;
var tpage_histoUserInitials:ArrayCollection;
var tpage_histoRelec:ArrayCollection;
var soapResult:int;
if (event.token.type == "FlipBookPageIdProperties")
{
tchampType = event.result[0];
tchampNom = event.result[1];
tchampValeur = event.result[2];
tpage_histoTS = event.result[3];
tpage_histoUserInitials = event.result[4];
soapResult = event.result[5];
tpage_histoRelec = event.result[6];
// contrôle d'intégralité des données reçues (si les 3 premiers tableaux reçus ne contiennent pas le même nombre d'éléments: alors grôs problème!)
if ( (tchampType.length != tchampNom.length) || (tchampType.length != tchampValeur.length) )
{
Alert.show("Les tableaux retour n'ont pas le même nb d'items!\ntchampType: "+tchampType.length.toString()+"\ntchampNom: "+tchampNom.length.toString()+"\tchampValeur: "+tchampValeur.length.toString() );
}
// contrôle d'intégralité des données reçues (si les 3 seconds tableaux reçus ne contiennent pas le même nombre d'éléments: alors grôs problème!)
if ( (tpage_histoTS.length != tpage_histoUserInitials.length) || (tpage_histoTS.length != tpage_histoRelec.length) )
{
Alert.show("Les tableaux retour n'ont pas le même nb d'items!\ntpage_histoTS: "+tpage_histoTS.length.toString()+"\ntpage_histoUserInitials: "+tpage_histoUserInitials.length.toString()+"\ntpage_histoRelec: "+tpage_histoRelec.length.toString() );
}
// remplissage liste des champs
var fieldListDP:ArrayCollection = new ArrayCollection();
for (i=0; i<tchampNom.length; i++)
{
var rowObj:Object = new Object();
rowObj.Nom = tchampNom[i].toString();
rowObj.Type = tchampType[i].toString();
rowObj.Valeur = tchampValeur[i].toString();
fieldListDP.addItem(rowObj);
}
_view.fieldList.dataProvider = fieldListDP;
// remplissage liste des historiques
var histoListDP:ArrayCollection = new ArrayCollection();
for (i=0; i<tpage_histoTS.length; i++)
{
var rowObj2:Object = new Object();
rowObj2.TS = tpage_histoTS[i].toString();
rowObj2.Initials = tpage_histoUserInitials[i].toString();
rowObj2.Relecture = tpage_histoRelec[i].toString();
histoListDP.addItem(rowObj2);
}
_view.histoList.dataProvider = histoListDP;
}
else
{
Alert.show("In WS_resultHandler > unknown token type: "+event.token.type );
}
}
private function WS_faultHandler(event:FaultEvent):void
{
if (event.token.type == "FlipBookPageIdProperties")
{
Alert.show("WS_faultHandler: "+event.fault.toString() );
}
else
{
Alert.show("In WS_faultHandler > unknown token type: "+event.token.type );
}
}
private function timer_completeHandler(event:TimerEvent):void
{
var timeNow:uint = timeFcts.GetMsTimestamp();
var token:AsyncToken;
token = _service.WS_getFlipBookPageIdProperties(129281); // le paramètre passé au webService est juste un ID correspondant à un enregistrement d'une table dans la base 4D
token.type = "FlipBookPageIdProperties";
token.reqTime = timeNow;
_timer.start();
}
}
} |
J'ai quelques questions:
1) Le problème évoqué peut-il venir du réseau (problème proxy, bande passante allouée, etc…)
Personnellement, je n'ai pas la main sur le réseau, mais je sais que ça foisonne de machines virtuelles sous OSX, Windows et Linux.
(>> Et ce webService est de loin le plus complexe de tous au niveau de sa réponse, qui contient plusieurs tableaux en retour. La réponse qui revient de 4D est très grande. A Prendre en compte que tout poste client qui va se connecter à cette appli web, va instancier ce webService qui envoie une requête périodiquement à la base. Du coup, 1 requête toutes les 5 secondes, multiplié par le nombre de client connectés… :)
2) La stratégie de récupération des réponses webService avec des tokens est-elle suffisante / correctement employée ici?
Voilà, j'espère avoir été le plus clair possible.
Je vous remercie par avance pour votre retour / vos observations.