Scenario 2: Using a SOAP message from an XML file to get country name information and saving the information to an XML file - 6.3

Talend Open Studio for Big Data Components Reference Guide

EnrichVersion
6.3
EnrichProdName
Talend Open Studio for Big Data
task
Data Governance
Data Quality and Preparation
Design and Development
EnrichPlatform
Talend Studio

This scenario describes a three-component Job that uses a SOAP message from an input XML file to invoke a Web service for the country name information which corresponds to the country code IR, and writes the response to an XML file.

Dropping and linking the components

  1. Drop the following components from the Palette onto the design workspace: tFileInputXML, tSOAP, and tFileOutputXML.

  2. Connect the components using Row > Main links.

Configuring the input component

  1. Double-click the tFileInputXML component to open its Basic settings view.

  2. Click the [...] button next to Edit schema to open the [Schema] dialog box.

  3. Click the [+] button to add a column, give it a name, getCountryName in this example, and select Document from the Type list. Then, click OK to close the dialog box.

  4. In the File name/Stream field, enter the path to the input XML file that contains the SOAP message to be used, or browse to the path by clicking the [...] button.

    The input file contains the following SOAP message and you can see that the given country code is IR:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
        <soapenv:Header/>
        <soapenv:Body>
            <web:GetCountryByCountryCode>
                <web:CountryCode>IR</web:CountryCode>
            </web:GetCountryByCountryCode>
        </soapenv:Body>
    </soapenv:Envelope>
  5. In the Loop XPath query field, enter "/" to define the root as the loop node of the input file structure.

  6. In the Mapping table, fill the XPath query column with "." to extract all data from context node of the source, and select the Get Nodes check box to build a Document type data flow.

Configuring the Web service via the tSOAP component

  1. Double-click the tSOAP component to open its Basic settings view.

  2. In ENDPOINT field, enter or copy-paste the URL address of the Web service to be used between the quotation marks: "http://www.webservicex.net/country.asmx".

  3. In the SOAP Action field, enter or copy-paste the URL address of the SOAPAction HTTP header field that indicates that you want to retrieve the country name information: http://www.webserviceX.NET/GetCountryByCountryCode.

  4. Select the Use a message from the schema check box, and select a Document type column from the SOAP Message list to read the SOAP message from the input file to send to the Web service. In this example, the input schema has only one column, getCountryName.

  5. Select the Output in Document check box to output the response message in XML format.

Configuring the output component

  1. Double-click the tFileOutputXML component to open its Basic settings view.

  2. In the File Name field, enter the path to the output XML file.

  3. Select the Incoming record is a document check box to retrieve the incoming data flow as an XML document. Note that a Column list appears allowing you choose a column to retrieve data from. In this example, the schema contains only one column.

Executing the Job

  1. Press Ctrl+S to save your Job.

  2. Press F6, or click Run on the Run tab to execute the Job.

    The country name information that corresponds to the country code of IR is returned and the information is saved in the defined XML file.