ComposantsComponents

ComposantsComponents › Internet

tXMLRPCInput

tXMLRPCInput

Internet

Effectue une requête sur un serveur XML-RPC et lit les résultats : il appelle une méthode (Calculator.add) avec des paramètres, puis range le résultat dans les colonnes de son schéma, une ligne par élément si le résultat est un tableau. Le client est celui d'Apache XML-RPC 3.1.3, sur Commons HttpClient. Pour un service SOAP, prenez un tWebServiceInput ; pour une API REST, un tRESTClient.Requests an XML-RPC server and reads its result: it calls a method (Calculator.add) with parameters, then stores the result in the columns of its schema, one row per element if the result is an array. The client is the one of Apache XML-RPC 3.1.3, over Commons HttpClient. For a SOAP service, take a tWebServiceInput; for a REST API, a tRESTClient.

EntréeInput

Aucune : il commence le sous-job. Ou un lien Iterate : un appel par itération.None: it starts the subjob. Or an Iterate link: one call per iteration.

SortieOutput

Un lien Main : une ligne, ou une par élément d'un résultat tableau.One Main link: one row, or one per element of an array result.

Déclencheurs en sortieOutput triggers

On Subjob Ok On Subjob Error On Component Ok On Component Error Run if

UtilisationUsage

Cette page n'a pas d'exemple exécuté : le fonctionnement décrit est lu dans le modèle du composant et dans le code Java qu'il génère, pour un job fait dans Talaxie.This page has no run example: the behavior described is read in the template of the component and in the Java code it generates, for a job made in Talaxie.

row1 (Main)OnSubjobOktXMLRPCInput_1tLogRow_1tJava_1

Un appel, puis une ligne par valeur reçue ; le tJava peut lire tXMLRPCInput_1_NB_LINE.One call, then one row per value received; the tJava can read tXMLRPCInput_1_NB_LINE.

  1. Déposez le tXMLRPCInput depuis la famille Internet de la palette et donnez l'URL du serveur.Drop the tXMLRPCInput from the Internet family of the palette and give the Server url.
  2. Authentification requise ? est cochée par défaut : décochez-la pour un serveur ouvert, ou donnez l'utilisateur et le mot de passe.Need authentication? is checked by default: uncheck it for an open server, or give the user and the password.
  3. Écrivez la Méthode et une ligne de Paramètres par argument, dans l'ordre ; créez le schéma, une colonne par valeur attendue.Write the Method and one row of Parameters per argument, in order; create the schema, one column per value expected.

Paramètres simplesBasic settings

Les libellés sont ceux de l'onglet Composant, dans son ordre ; le nom technique, en gris, est celui du paramètre dans le fichier du job. Le composant n'a pas de paramètres avancés propres.Labels are those of the Component tab, in its order; the technical name, in grey, is the parameter name in the job file. The component has no advanced settings of its own.

ParamètreSetting DéfautDefault VisibleShown Description
SchémaSchemaSCHEMA videempty ToujoursAlways Colonnes remplies par position (voir Fonctionnement). Évitez les types Date et byte[] : le code généré ne compile pas (voir Pièges).Columns filled by position (see How it works). Avoid the Date and byte[] types: the generated code does not compile (see Pitfalls).
URL du serveurServer urlSERVER-URL "http://127.0.0.1:8080/xmlrpc" ToujoursAlways Adresse du point d'entrée XML-RPC, http ou https ; elle passe par new java.net.URL(…) au début du composant.Address of the XML-RPC endpoint, http or https; it goes through new java.net.URL(…) at the start of the component.
Authentification requise ?Need authentication?NEED_AUTH OuiYes ToujoursAlways HTTP Basic (setBasicUserName, setBasicPassword). Cochée par défaut, contrairement aux autres composants de la famille.HTTP Basic (setBasicUserName, setBasicPassword). Checked by default, unlike the other components of the family.
UtilisateurUsernameAUTH_USERNAME "username" Authentification requise ? cochéeNeed authentication? checked Compte sur le serveur.Account on the server.
Mot de passePasswordAUTH_PASSWORD "password" Authentification requise ? cochéeNeed authentication? checked Une valeur entre guillemets est chiffrée dans le code généré et déchiffrée au lancement.A value in quotes is encrypted in the generated code and decrypted at launch.
MéthodeMethodMETHOD "Calculator.add" ToujoursAlways Nom de la méthode, une expression Java de type texte.Name of the method, a Java expression of type text.
ParamètresParametersPARAMS videempty ToujoursAlways Colonnes (nom), valeur et Classe. Seule valeur compte : une expression Java par argument, envoyée avec son propre type (20 part en entier, "20" en texte). Le nom et la classe ne sont pas lus par le modèle.name, value and class columns. Only value matters: one Java expression per argument, sent with its own type (20 leaves as an integer, "20" as text). The name and the class are not read by the template.

FonctionnementHow it works

Code généré pour URL du serveur "http://127.0.0.1:8187/RPC2", Méthode "Calculator.add", Paramètres 20 et 22, authentification demo (extrait, mot de passe chiffré abrégé) :Code generated for Server url "http://127.0.0.1:8187/RPC2", Method "Calculator.add", Parameters 20 and 22, authentication demo (excerpt, encrypted password shortened):

org.apache.xmlrpc.client.XmlRpcClientConfigImpl configtXMLRPCInput_1= new org.apache.xmlrpc.client.XmlRpcClientConfigImpl();
configtXMLRPCInput_1.setServerURL(new java.net.URL("http://127.0.0.1:8187/RPC2"));
configtXMLRPCInput_1.setEnabledForExtensions(true);
configtXMLRPCInput_1.setConnectionTimeout(60 * 1000);
configtXMLRPCInput_1.setReplyTimeout(60 * 1000);
    configtXMLRPCInput_1.setBasicUserName("demo");
	final String decryptedPassword_tXMLRPCInput_1 = routines.system.PasswordEncryptUtil.decryptPassword("enc:routine.encryption.key.v1:…");
	configtXMLRPCInput_1.setBasicPassword(decryptedPassword_tXMLRPCInput_1);
org.apache.xmlrpc.client.XmlRpcClient clienttXMLRPCInput_1 = new org.apache.xmlrpc.client.XmlRpcClient();
// use Commons HttpClient as transport
 clienttXMLRPCInput_1.setTransportFactory(
              new org.apache.xmlrpc.client.XmlRpcCommonsTransportFactory(clienttXMLRPCInput_1));
        // set configuration
		clienttXMLRPCInput_1.setConfig(configtXMLRPCInput_1);
        // make the a regular call
        Object[] params_tXMLRPCInput_1 = new Object[] {
                20,
                22,
        };
        …
        Object reValuetXMLRPCInput_1 = clienttXMLRPCInput_1.execute("Calculator.add", params_tXMLRPCInput_1);

L'appelThe call

  • Un seul appel par exécution du composant (ou par itération).A single call per run of the component (or per iteration).
  • Délais fixés à 60 s pour la connexion et pour la réponse, sans réglage.Timeouts fixed at 60 s for the connection and for the response, with no setting.
  • Les extensions d'Apache XML-RPC sont activées (setEnabledForExtensions(true)), sans réglage.The Apache XML-RPC extensions are on (setEnabledForExtensions(true)), with no setting.
  • Une erreur du serveur (faute XML-RPC, réponse HTTP en erreur) lève une exception : pas de case Arrêter en cas d'erreur, le job s'arrête sauf lien On Component Error.An error of the server (XML-RPC fault, HTTP error response) raises an exception: no Die on error box, the job stops unless there is an On Component Error link.

Le résultatThe result

  • Résultat tableau : une ligne par élément ; sinon une seule ligne.Array result: one row per element; otherwise a single row.
  • Élément simple : son texte (String.valueOf) dans la première colonne, les autres nulles.Simple element: its text (String.valueOf) in the first column, the others null.
  • Élément structure (struct) : ses valeurs remplissent les colonnes dans l'ordre de map.values(), sans lien avec le nom des membres ; un tableau dans la structure devient un Object[].Structure element (struct): its values fill the columns in the order of map.values(), with no link to the names of the members; an array inside the structure becomes an Object[].
  • Chaque valeur est ensuite convertie depuis son texte selon le type de la colonne (ParserUtils.parseTo_Integer(…)…).Each value is then converted from its text according to the type of the column (ParserUtils.parseTo_Integer(…)…).

Variables globalesGlobal variables

NB_LINE
Integer, Nombre de lignes : lignes produites, posé à la fin du composant.Integer, Number of line: rows produced, set at the end of the component.
ERROR_MESSAGE
String : message de l'erreur, comme pour tout composant.String: message of the error, as for any component.
((Integer) globalMap.get("tXMLRPCInput_1_NB_LINE"))

PiègesPitfalls

Une colonne Date ou byte[] empêche la compilationA Date or byte[] column prevents compilation

Pour ces deux types, le modèle écrit du code qui traite la valeur reçue (de type Object) comme un texte. Schéma result (Integer), text (String), when (Date), data (byte[]) ; messages du compilateur Java 21 sur le code généré (nom du job remplacé par MyJob) :For these two types, the template writes code that treats the received value (of type Object) as a text. Schema result (Integer), text (String), when (Date), data (byte[]); messages of the Java 21 compiler on the generated code (job name replaced with MyJob):

MyJob.java:1029: error: no suitable method found for parseTo_Date(Object,<null>)
						row1.when = ParserUtils.parseTo_Date(results_tXMLRPCInput_1[2], null);
						                       ^
    method ParserUtils.parseTo_Date(String,String) is not applicable
      (argument mismatch; Object cannot be converted to String)
    method ParserUtils.parseTo_Date(Date,String) is not applicable
      (argument mismatch; Object cannot be converted to Date)
MyJob.java:1035: error: cannot find symbol
						row1.data = results_tXMLRPCInput_1[3].getBytes();
						                                     ^
  symbol:   method getBytes()
  location: class Object

Recevez ces valeurs dans une colonne String (ou Object), puis convertissez-les dans un tJavaRow ou un tConvertType.Receive these values in a String (or Object) column, then convert them in a tJavaRow or a tConvertType.

La colonne Classe ne convertit rienThe class column converts nothing

Choisir java.lang.Integer.class pour un argument écrit "20" n'en fait pas un entier : il part en texte. Écrivez l'expression dans le type voulu (20, Integer.parseInt(context.n)).Choosing java.lang.Integer.class for an argument written "20" does not make it an integer: it leaves as text. Write the expression in the wanted type (20, Integer.parseInt(context.n)).

Structures : l'ordre des colonnes n'est pas garantiStructures: the order of the columns is not guaranteed

Les valeurs d'une structure sont prises dans l'ordre de map.values(), sans lien avec le nom des colonnes ni des membres. Contrôlez l'ordre obtenu sur un premier appel avant de vous fier aux colonnes.The values of a structure are taken in the order of map.values(), with no link to the names of the columns or of the members. Check the order obtained on a first call before relying on the columns.

Voir aussiSee also