ComposantsComponents

ComposantsComponents › ESB › Web Services

tESBProviderResponse

tESBProviderResponse

ESB › Web Services

Envoie la réponse d'une opération SOAP servie par un job. Il termine le flux ouvert par un tESBProviderRequest : le document XML reçu dans sa colonne payload devient le corps de la réponse, et l'appelant, qui attendait, la reçoit. Le composant n'a aucun réglage à faire : tout se joue dans le document qu'on lui donne. Sends the response of a SOAP operation served by a job. It ends the flow opened by a tESBProviderRequest: the XML document received in its payload column becomes the body of the response, and the caller, who was waiting, receives it. The component has no setting to make: everything lies in the document it is given.

EntréeInput

Un lien Main, obligatoire, avec une colonne payload de type Document. Les autres colonnes du flux sont ignorées. One Main link, required, with a payload column of type Document. The other columns of the flow are ignored.

SortieOutput

Aucun flux Il termine sa branche. No flow It ends its branch.

Déclencheurs en sortieOutput triggers

On Component Ok Run if

UtilisationUsage

Répondre à une requêteAnswering a request

row1 (Main) row2 (Main) tESBProviderRequest_1 tXMLMap_1 tESBProviderResponse_1

Dans le tXMLMap, la sortie a une colonne payload de type Document : son arbre XML est celui de l'élément de réponse du WSDL, espace de noms compris. In the tXMLMap, the output has a payload column of type Document: its XML tree is the one of the response element of the WSDL, namespace included.

Réponse ou erreurResponse or fault

row1 (Main) out1 (Main) out2 (Main) tESBProviderRequest_1 tXMLMap_1 tESBProviderResponse_1 tESBProviderFault_1

Deux sorties aux conditions opposées : pour une requête donnée, une seule des deux branches reçoit une ligne. Chaque requête doit recevoir une réponse ou une erreur, et une seule. Two outputs with opposite conditions: for a given request, only one of the two branches receives a row. Each request must receive one response or one fault, and only one.

  1. Le composant est déjà dans le job créé depuis une opération du service (Assigner un job) quand cette opération a une réponse. Sinon, déposez-le depuis la famille ESB › Web Services. The component is already in the job created from an operation of the service (Assign Job) when that operation has a response. Otherwise, drop it from the ESB › Web Services family.
  2. Reliez-y le composant qui construit le document : un tXMLMap, un tWriteXMLField, ou un tJavaRow. Connect to it the component that builds the document: a tXMLMap, a tWriteXMLField, or a tJavaRow.
  3. Vérifiez que la colonne du flux entrant s'appelle bien payload et qu'elle est de type Document. Check that the column of the incoming flow is indeed named payload and that its type is Document.

Paramètres simplesBasic settings

Le composant n'a qu'un paramètre affiché. Son paramètre avancé Propriétés personnalisées de l'activité de service (SERVICE_ACTIVITY_CUSTOM_PROPERTIES, des couples nom et valeur joints à la réponse pour le Service Activity Monitoring) existe dans le fichier du job mais n'est jamais affiché. The component has a single displayed parameter. Its advanced parameter Service Activity Custom Properties (SERVICE_ACTIVITY_CUSTOM_PROPERTIES, name and value pairs attached to the response for Service Activity Monitoring) exists in the job file but is never displayed.

ParamètreSetting DéfautDefault VisibleShown Description
SchémaSchemaSCHEMA payload (Document) ToujoursAlways Une colonne payload, de type Document, non modifiable. C'est le schéma du lien entrant qui compte : s'il n'a pas de colonne payload de type Document, le composant ne génère aucun code et n'envoie rien. One payload column, of type Document, not editable. The schema of the incoming link is what counts: if it has no payload column of type Document, the component generates no code and sends nothing.

Variable globale : NB_LINE est déclarée par le composant, mais son modèle ne la renseigne pas. Global variable: NB_LINE is declared by the component, but its template never sets it.

Ce que le composant envoieWhat the component sends

Le document, tel quelThe document, as it is

  • Le document de payload est placé dans soap:Body. Le composant n'ajoute pas l'enveloppe au document et ne le compare pas au WSDL : un élément mal nommé ou sans son espace de noms part quand même, et c'est l'appelant qui échouera à le lire.The document of payload is put in soap:Body. The component does not add the envelope to the document and does not check it against the WSDL: a misnamed element, or one without its namespace, leaves anyway, and the caller is the one who will fail to read it.
  • L'appelant reçoit la réponse dès que la ligne atteint le composant, avant la fin du sous-job.The caller receives the response as soon as the row reaches the component, before the end of the subjob.
  • Une seule réponse par requête : un second envoi pour la même requête lève une exception.A single response per request: a second send for the same request throws an exception.

Studio et RuntimeStudio and Runtime

  • Le composant fait la même chose dans les deux cas : il remet le document au tESBProviderRequest du job, qui le transmet au service.The component does the same thing in both cases: it hands the document to the tESBProviderRequest of the job, which passes it to the service.
  • À l'exécution du job, c'est le serveur démarré par le job qui répond ; dans le Talend Runtime, c'est le service publié par le conteneur, avec ses options (sécurité, Service Activity Monitoring…). Voir tESBProviderRequest.When the job runs, the server started by the job answers; in the Talend Runtime, the service published by the container does, with its options (security, Service Activity Monitoring…). See tESBProviderRequest.
  • La présence d'un tESBProviderResponse ou d'un tESBProviderFault dans le job fait de l'opération un échange requête-réponse quand le job n'est rattaché à aucun service.The presence of a tESBProviderResponse or a tESBProviderFault in the job makes the operation a request-response exchange when the job is assigned to no service.

ExemplesExamples

Service Clients, opération getClient, publié à http://localhost:8090/services/Clients par un job exécuté dans Talaxie et appelé en local. Messages et consoles copiés tels quels ; le nom du job est remplacé par MyService et les piles d'appels sont abrégées (…). Clients service, getClient operation, published at http://localhost:8090/services/Clients by a job run in Talaxie and called locally. Messages and consoles copied as they are; the job name is replaced with MyService and the stack traces are shortened (…).

Une réponse construite dans un tJavaRowA response built in a tJavaRow

row1 (Main) row2 (Main) row3 (Main) row4 (Filter) tESBProviderRequest_1 tLogRow_1 tJavaRow_1 tFilterRow_1 tESBProviderResponse_1

Le tJavaRow crée le document de la réponse ; le tFilterRow ne laisse passer que les clients trouvés. Code du tJavaRow pour le client trouvé : The tJavaRow creates the document of the response; the tFilterRow only lets through the clients that were found. Code of the tJavaRow for the client that was found:

org.dom4j.Document doc = org.dom4j.DocumentHelper.createDocument();
org.dom4j.Element root = doc.addElement("tns:getClientResponse", "http://www.talend.org/service/");
root.addElement("id").setText(id);
root.addElement("name").setText("Alice Martin");
root.addElement("city").setText("Lyon");
output_row.payload = new routines.system.Document();
output_row.payload.setDocument(doc);
POST http://localhost:8090/services/Clients
SOAPAction: "http://www.talend.org/service/getClient"

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:getClientRequest xmlns:tns="http://www.talend.org/service/"><id>1</id></tns:getClientRequest></soap:Body></soap:Envelope>

HTTP 200 OK
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:getClientResponse xmlns:tns="http://www.talend.org/service/"><id>1</id><name>Alice Martin</name><city>Lyon</city></tns:getClientResponse></soap:Body></soap:Envelope>

Le document est repris à l'identique entre <soap:Body> et </soap:Body>, sans sa déclaration XML. The document is taken as it is between <soap:Body> and </soap:Body>, without its XML declaration.

Opération sans réponse : pas de tESBProviderResponseOperation without a response: no tESBProviderResponse

Un job rattaché à l'opération notifyClient, que le WSDL déclare sans sortie, n'a ni tESBProviderResponse ni tESBProviderFault. L'appelant reçoit un accusé de réception sans corps : A job assigned to the notifyClient operation, which the WSDL declares without an output, has neither a tESBProviderResponse nor a tESBProviderFault. The caller receives an acknowledgement without a body:

POST http://localhost:8090/services/Clients
SOAPAction: "http://www.talend.org/service/notifyClient"

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:notifyClientRequest xmlns:tns="http://www.talend.org/service/"><id>1</id><event>address changed</event></tns:notifyClientRequest></soap:Body></soap:Envelope>

HTTP 202 Accepted

PiègesPitfalls

La ligne n'atteint pas le composantThe row does not reach the component

Le job de l'exemple sans tESBProviderFault : pour le client 99, le tFilterRow rejette la ligne et rien n'est envoyé. L'appelant reçoit alors une erreur technique, HTTP 500 : The job of the example without a tESBProviderFault: for client 99, the tFilterRow rejects the row and nothing is sent. The caller then receives a technical fault, HTTP 500:

POST http://localhost:8090/services/Clients
SOAPAction: "http://www.talend.org/service/getClient"

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:getClientRequest xmlns:tns="http://www.talend.org/service/"><id>99</id></tns:getClientRequest></soap:Body></soap:Envelope>

HTTP 500 Server Error
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Could not generate the XML stream caused by: com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog&#xd;
 at [row,col {unknown-source}]: [2,0].</faultstring></soap:Fault></soap:Body></soap:Envelope>

Le tESBProviderRequest a répondu un document vide à la place du job, et rien n'est écrit dans la console. Un filtre, une jointure Inner Join sans rejet relié, un flux d'entrée vide : tout ce qui peut faire disparaître la ligne doit mener à une réponse ou à un tESBProviderFault. The tESBProviderRequest answered an empty document in place of the job, and nothing is written to the console. A filter, an Inner Join without a connected reject, an empty input flow: whatever can make the row vanish must lead to a response or to a tESBProviderFault.

Deux réponses pour une requêteTwo responses for one request

Un tReplicate envoie la même ligne à deux tESBProviderResponse. L'appelant reçoit la première réponse (HTTP 200) ; la seconde échoue dans le job, à chaque requête : A tReplicate sends the same row to two tESBProviderResponse components. The caller receives the first response (HTTP 200); the second one fails in the job, at each request:

web service [endpoint: http://localhost:8090/services/Clients] published
Exception in component tESBProviderResponse_2 (MyService)
java.lang.RuntimeException: Send Response failed! Response already sent with current request.
	at demo.myservice_0_1.MyService$ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1.doSendResponse(MyService.java:710)
	at demo.myservice_0_1.MyService$ESBProviderCallbackTalendJobWrapper_tESBProviderRequest_1.sendResponse(MyService.java:718)
	at demo.myservice_0_1.MyService.tESBProviderRequest_1_LoopProcess(MyService.java:2812)
	…

Il en va de même quand le flux porte plusieurs lignes pour une requête, par exemple après une jointure qui multiplie les lignes : seule la première part. Regroupez les lignes dans un seul document avant le composant (boucle du tXMLMap, tWriteXMLField). The same goes when the flow carries several rows for one request, for instance after a join that multiplies the rows: only the first one leaves. Group the rows into a single document before the component (loop of the tXMLMap, tWriteXMLField).

Sans tESBProviderRequestWithout a tESBProviderRequest

Dans un job sans tESBProviderRequest, le composant n'envoie rien et écrit à chaque ligne : [WARN] nonsense: tESBProviderResponse component used without tESBProviderRequest component on the job. In a job without a tESBProviderRequest, the component sends nothing and writes at each row: [WARN] nonsense: tESBProviderResponse component used without tESBProviderRequest component on the job.

Une réponse trop tardiveA response that comes too late

À l'exécution du job, une réponse envoyée après le Délai avant expiration du traitement des requêtes du tESBProviderRequest (120 secondes par défaut) est perdue : l'appelant reçoit l'erreur no response provided by Talend job. When the job runs, a response sent after the Request processing timeout of the tESBProviderRequest (120 seconds by default) is lost: the caller receives the no response provided by Talend job fault.

ConseilsTips

Partir du schéma du WSDLStart from the schema of the WSDL

Dans le tXMLMap, importez l'arbre de la réponse depuis le schéma XML du service plutôt que de le saisir : noms, ordre des éléments et espace de noms seront ceux que l'appelant attend. In the tXMLMap, import the tree of the response from the XML schema of the service rather than typing it: names, element order and namespace will be those the caller expects.

Voir ce qui partSee what leaves

Pendant la mise au point, un tLogRow placé juste avant le composant affiche le document de chaque réponse, comme il affiche la requête après le tESBProviderRequest. While tuning the job, a tLogRow placed right before the component prints the document of each response, as it prints the request after the tESBProviderRequest.

Voir aussiSee also