Ceci est une ancienne révision du document !
Table des matières
Template:
===== classe/method ===== ==== Description ==== ==== URL ==== ==== Paramètres ==== ==== Retour ==== ==== Exemples ====
Web Services EzGED
Les web services EzGED constituent l'API ouverte permettant de s'interfacer avec EzGED.
Format de retour
Le serveur de service, écrit en python, sert le résultat au format XML. Dans le cas où vous voudriez obtenir le résultat sous forme JSON rendez-vous sur la page Web Services JSON
Liste des services
sec/authenticate
Description
Permet de s'authentifier auprès du serveur EzGED et d'obtenir un id de session.
URL
http://<adresse_du_serveur>:<port>/sec/authenticate/
Paramètres
- login requis - Le nom de compte avec lequel s'authentifier.
- pwd requis - Le mot de passe haché en md5.
- domain - Nom de domaine du serveur LDAP auprès duquel on doit s'identifier. Requis si le paramètre d'instance auth-w2kad.logins est configuré.
- realip - Adresse IP à comparée avec le paramètre SECUSR_HOST s'il est définit.
Retour
L'id de session est
<object subtype='object' type='session'>
<object subtype='string' type='property' name='sessionid' value='75776802'/>
</object>
Exemples
Appel
http://localhost:8080/sec/authenticate/?realip=aaa.bbb.ccc.ddd&login=admin&pwd=21232f297a57a5a743894a0e4a801fc3
Retour
- sec/authenticate.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='object' type='user'> <object type='property' name='allowtoprofile' value='1'/> <object type='property' name='allowtobasket' value='1'/> <object type='property' name='SECUSR_ID' value='1'/> <object type='property' name='allowtoglobalsearch' value='1'/> <object type='property' name='SECUSR_SECGRPID' value='1'/> <object type='property' name='SECUSR_HOST' value=''/> <object type='property' name='SECUSR_LOGIN' value='admin'/> <object type='property' name='allowtotrash' value='1'/> <object type='property' name='allowtojob' value='1'/> <object type='property' name='SECUSR_SUPER' value='1'/> <object type='property' name='allowtoworkflow' value='1'/> <object type='property' name='allowtolink' value='1'/> <object type='property' name='allowtodashboard' value='1'/> <object type='property' name='allowtocorrection' value='1'/> <object type='property' name='SECUSR_MAIL' value='florian@ezdev.fr'/> <object type='property' name='SECUSR_VAL' value='@DBNULLVALUE'/> <object type='property' name='allowtosignbook' value='1'/> <object type='property' name='allowtohome' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_OPENMODE' value='archive'/> <object subtype='string' type='property' name='SECUSRPAR_FTPPORT' value='21'/> <object subtype='string' type='property' name='SECUSRPAR_FMTFLOAT' value='xx2xx.xx xx'/> <object subtype='string' type='property' name='SECUSRPAR_GRIDLINES' value='20'/> <object subtype='string' type='property' name='SECUSRPAR_THUMBBYPAGE' value='10'/> <object subtype='string' type='property' name='SECUSRPAR_RESIZEBUTTONS' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_TOOLBARRIGHT' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_LANG' value='fr_FR'/> <object subtype='string' type='property' name='SECUSRPAR_PARAPH_ORDERFLD' value='PARAPHSCN_LIB'/> <object subtype='string' type='property' name='SECUSRPAR_FIXEDUSER' value='0'/> <object subtype='string' type='property' name='SECUSRPAR_MULTIUSER' value='5'/> <object subtype='string' type='property' name='SECUSRPAR_HEADERCOLLAPSED' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_FMTDATE' value='d-m-Y H:i:s'/> <object subtype='string' type='property' name='SECUSRPAR_SCPSUBDIR' value=''/> <object subtype='string' type='property' name='SECUSRPAR_SCPDIR' value=''/> <object subtype='string' type='property' name='SECUSRPAR_FTPSUBDIR' value=''/> <object subtype='string' type='property' name='SECUSRPAR_CTLFINGERPRINTS' value='0'/> <object subtype='string' type='property' name='SECUSRPAR_SKIN' value='default'/> <object subtype='string' type='property' name='SECUSRPAR_FTPPATH' value=''/> <object subtype='string' type='property' name='SECUSRPAR_WAITSUBDIR' value=''/> <object subtype='string' type='property' name='SECUSRPAR_SCPHOST' value=''/> <object subtype='string' type='property' name='SECUSRPAR_HTTPPOSTPATH' value=''/> <object subtype='string' type='property' name='SECUSRPAR_PARAPH_ORDERDIR' value='D'/> <object subtype='string' type='property' name='SECUSRPAR_FTPHOST' value=''/> <object subtype='string' type='property' name='SECUSRPAR_VIEWMODE' value='thumbs'/> <object subtype='string' type='property' name='SECUSRPAR_HTTPPOSTHOST' value=''/> <object subtype='string' type='property' name='SECUSRPAR_OPENINNEWWINDOW' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_KEEPORIGINFORMAT' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_WAITDIR' value=''/> <object subtype='string' type='property' name='SECUSRPAR_HTTPPOSTPORT' value='80'/> <object subtype='string' type='property' name='SECUSRPAR_UPLOADFILES' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_SPOOLDIR' value='C:\nchp\var\spool\ezged\instance'/> <object subtype='string' type='property' name='SECUSRPAR_WF' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_OFFICE2PDF' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_PDF2OFFICE' value='1'/> <object subtype='string' type='property' name='SECUSRPAR_THUMBSDIR' value='C:\nchp\var\spool\ezged\instance\thumbnailcache'/> <object subtype='string' type='property' name='SECUSRPAR_EXTERNALADDRESS' value='http://192.168.1.104:80/ezged'/> <object subtype='string' type='property' name='SECUSRPAR_SMTPSERVER' value='smtp.orange.fr'/> </object> <object errorcode='-4' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='Impossible de se connecter avec admin, le nombre de sessions autorisées est atteint.'/> </object> </object>
sec/authenticatebysession
Description
Permet de s'authentifier sur le serveur GED en fournissant un id de session.
URL
http://<adresse_du_serveur>:<port>/sec/authenticatebysession/
Paramètres
- sessionid requis Id de session EzGED.
Retour
L'id de session ainsi que les paramètres utilisateurs.
Exemples
doctbl/insertrow
Description
Insère une nouvelle ligne dans une table.
URL
Paramètres
- sessionid requis ID de session EzGED.
- fields[i]
Nb: i est un indice de tableau (débute à 0). Le service acceptera aussi que soient envoyés les différents paramètres fields et values sans indices. Il faudra alors veillé à ce que l'ordre des valeurs corresponde à celui des champs !
Retour
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='doctbl' type='insertrow'> <object subtype='object' type='returnid'> <object type='property' name='RETID' value='101'/> </object> </object> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
Exemples
Appel du service sans indicer les paramètres :
http://localhost:8080/doctbl/insertrow/?sessionid=1217328858&tfqn=courriers&fields=COURRIERS_OBJET&values=MAJ%20EzGED&fields=COURRIERS_FROM&values=florian
Le même appel si on utilise les indices (l'ordre d'écriture des paramètres n'est plus important) :
http://localhost:8080/doctbl/insertrow/?sessionid=1217328858&tfqn=courriers&fields[0]=COURRIERS_OBJET&values[1]=florian&fields[1]=COURRIERS_FROM&values[0]=MAJ%20EzGED
fsfile/multiloc
Description
Retourne les informations d'un fichier.
URL
http://<serveur_ezged>:<port>/fsfile/multiloc?sessionid=<id_de_session>&fsfileid=<id_du_fichier>
Paramètres
- sessionid requis ID de session EzGED.
- fsfileid requis ID du fichier dans EzGED.
Exemples
Avec l'appel suivant
http://localhost:8080/fsfile/multiloc?sessionid=409492697&fsfileid=12778
J'obtiens le retour suivant
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='list' type='fileinfo'> <object subtype='object' type='fileinfo'> <object type='property' name='lock' value='admin'/> <object type='property' name='used' value='1'/> <object type='property' name='issuers' value='{}'/> <object type='property' name='sigpath' value=''/> <object type='property' name='ripe' value='18c3f9c86821ff505fa12f8f6283b37d17a68873'/> <object type='property' name='hassig' value='0'/> <object type='property' name='user' value='admin'/> <object type='property' name='fssigripe' value=''/> <object type='property' name='ostamp' value='2015-12-10 13:27:57'/> <object type='property' name='pages' value='0'/> <object type='property' name='dimensions' value='0'/> <object type='property' name='ext' value='pdf'/> <object type='property' name='mime' value='application/pdf'/> <object type='property' name='sigripe' value=''/> <object type='property' name='newripe' value='18c3f9c86821ff505fa12f8f6283b37d17a68873'/> <object type='property' name='path' value='c:\nchp\var\nchp\instance\EMDOM\DEFTSA\00000003\18\c3\470IVB56.pdf'/> <object type='property' name='size' value='187268'/> <object type='property' name='nstamp' value='2015-12-10 13:27:58'/> <object type='property' name='nname' value='470IVB56'/> <object type='property' name='oname' value='3TNCB759-stamp.pdf'/> </object> </object> <object subtype='list' type='paths'> <object subtype='object' type='path'> <object type='property' name='PATH' value='c:\nchp\var\nchp\instance\EMDOM\DEFTSA\00000003\18\c3\470IVB56.pdf'/> <object type='property' name='VALIDITY' value='1'/> </object> </object> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
Retour dans le cas d'un fichier non trouvé dans le stockage:
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='list' type='fileinfo'/> <object subtype='list' type='paths'/> <object errorcode='-2' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='Fichier non trouvé dans le système de stockage'/> </object> </object>
doctbl/deleterowwfiles
Description
Supprime une fiche descriptive.
Nb: Ne supprime pas les fichiers liés.
URL
http://<adresse_du_serveur>:<port>/doctbl/deleterowwfiles?sessionid=<id_de_session>&tfqn=<table>&field_ID=<champ_clé_primaire>&value_ID=<valeur_clé_primaire>
Paramètres
- sessionid requis - ID de session EzgED.
- tfqn requis - Nom de la table sur laquelle se trouve la fiche à supprimer.
- field_ID requis - Nom de champ de la clé primaire.
- value_ID requis - Valeur de la clé primaire (i.e le RSID ou encore ID de la fiche descriptive).
Exemples
Appel:
http://localhost:8080/doctbl/deleterowwfiles/?sessionid=409492697&tfqn=facture&field_ID=FACTURE_ID&value_ID=3
Retour :
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='doctbl' type='deleterowwfiles'/> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
Si un des fichiers lié à la fiche descriptive est utilisé on aura le retour suivant:
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='doctbl' type='deleterowwfiles'/> <object errorcode='-10' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='A file attached is used in workflow or signbook'/> </object> </object>
Notes
En cas d'appel d'un web service avec un id de session qui n'est plus valide, le retour suivant sera obtenu
- redirection.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='redirect'> <object subtype='object' type='redirection'/> <object errorcode='-1' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='redirected'/> </object> </object>
Tutoriaux Web Service
Sans Proxy
Les appels sont directement fait sur le serveur de service python.
S'authentifier
On souhaite s'authentifier avec le login patrick et le mot de passe associé
Créer une nouvelle fiche
Supposons que nous ayons une table courriers ayant pour champs COURRIER_ID (la clé primaire), COURRIER_OBJET et COURRIER_EXPEDITEUR. Si nous voulons ajouter une ligne et affecter les valeurs comme suit :
COURRIER_OBJET : MAJ EzGED disponible
COURRIER_EXPEDITEUR : EzDEV
Il suffit alors d'appeler le web service doctbl/insertrow comme suit
http://localhost:8080/doctbl/insertrow/?sessionid=187655380&tfqn=courriers&fields[0]=COURRIERS_OBJET&values[0]=MAJ EzGED disponible&fields[1]=COURRIERS_FROM&values[1]=florian
Le web service nous renvoi l'id de la nouvelle ligne :
- retour.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='doctbl' type='insertrow'> <object subtype='object' type='returnid'> <object type='property' name='RETID' value='107'/> </object> </object> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
L'élement qui nous intéresse est le suivant, dont l'attribut value contient la clé primaire de la fiche nouvellement créée.
<object type='property' name='RETID' value='107'/>
Cette clé nous permettra, lors de l'étape suivante, de rattacher un fichier à cette fiche descriptive.
Ajouter des fichiers à une fiche
Envoyer un fichier sur le serveur
La première chose à faire est d'uploader le fichier sur le serveur EzGED. Pour cela votre client doit envoyer une requête HTTP de type POST sur le serveur web via l'URL suivante :
http://localhost/ezged3/data/pupload.php?mode=archive
Le serveur renvoi la réponse au format JSON.
{
"success":true,
"chunkpart":false,
"message":"File successfully uploaded.",
"filePath":"C:\\nchp\\var\\spool\\ezged\\instance\/enqueued\/albatros.pdf"
}
Lier un fichier à une fiche
Nous avons tous les éléments nécessaires :
Le chemin : C:\\nchp\\var\\spool\\ezged\\instance\/enqueued\/albatros.pdf
Le rsid : 1009
La table : test
La session : 743409468
Il suffit alors d'appeler le web service d'ajout de pages à un docpak :
http://localhost:8080/docpak/addpages/?sessionid=743409468&tfqn=test&rsid=1009&file=C:\\nchp\\var\\spool\\ezged\\instance\/enqueued\/albatros.pdf&start=-1
Le retour est au format XML :
- reponse.xml
<?xml version='1.0' encoding='ISO-8859-15'?> <object type='result'> <object subtype='object' type='addpages'> <object subtype='int' type='property' name='JOBQUEUE_ID' value='8979'/> </object> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
Ceci nous indique qu'un travail a bien été créé et que son identifiant est 8979.
Surveiller l'avancée du travail
http://localhost:8080/jobqueue/load/?sessionid=743409468&jobqueueid=8979
Ci-dessous une partie (seulement les infos les plus pertinentes pour nous) de la réponse :
- reponse.xml
<object subtype='object' type='generic'> <object type='property' name='JOBQUEUE_PURGEABLE' value='1'/> <object type='property' name='JOBQUEUE_RUNMISSED' value='1'/> <object type='property' name='JOBQUEUE_ID' value='8979'/> <object type='property' name='JOBQUEUE_STARTTIME' value='@DBNULLVALUE'/> <object type='property' name='JOBQUEUE_ACTIVE' value='1'/> <object type='property' name='JOBQUEUE_TSTAMP' value='@DBNULLVALUE'/> <object type='property' name='JOBQUEUE_STATUS' value='0'/> <object type='property' name='JOBQUEUE_SECUSRID' value='1'/> </object> </object> <object errorcode='0' subtype='object' type='error'> <object subtype='str' type='property' name='desc' value='ok'/> </object> </object>
L'élément JOBQUEUE_STATUS nous donne le status du travail.
| Code status | Libellé | Détails |
|---|---|---|
| 0 | NORMAL | Le travail est en attente d'être traité par le serveur |
| 1 | EN FILE | Le travail est en cours d'exécution |
| 2 | FINI PURGEABLE | Le travail est terminé, prêt à être nettoyé |
| 4 | ERREUR | Le travail est en erreur |
