retrieve XML from API REST

Highlighted
One Star

retrieve XML from API REST

Hi all,
I am new in Talend community. I have read the user guide and some tutorial. But I have some difficulty to solve my problem.
I must retrieve a XML file from WEB Rest Service. I had looked the componant tWebService but i can't call the web service because it's not deploy yet ... .
So I want to create job or create a new compenant which :
- Get XML file in entry.
- Check the XML file with XSD schema from the web Service (i can't call the web service but y have the XSD schema).
- Retrieve attributs.
- Store attributs in SGBD.

It's not realy complex in fact.But the main purpose is my XML file use Inheritance, and i don't how to manage it on TALEND, can we ?
For the moment I don't have find any method. I had tried to create metadata XML file with the XSD but i didn't success.
Maybe i think so much in JAVA. I want control everything at low lvl. It's strange to think at an upper lvl of interaction...
Here a sample XML:
<?xml version="1.0" encoding="UTF-8"?>
<Customers>
<MyCustomer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CustomerBasic" id="1" />
<MyCustomer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="CustomerPremium" id="2">
<credit="10">
</MyCustomer>
</Customers>

Here a XSD sample:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
<!-- defini an abstract Customer -->
<xsd:complexType name="AbstractCustomer" abstract="true" >
<xsd:attribute name="id" type="xsd:string"/>
<xsd:attribute name="firstname" type="xsd:string"/>
<xsd:attribute name="lastename" type="xsd:string"/>
</xsd:complexType>


<xsd:complexType name="CustomerBasic">
<xsd:complexContent>
<xsd:extension base="AbstractCustomer">

</xsd:extension>
</xsd:complexContent>
</xsd:complexType>


<xsd:complexType name="CustomerPremium">
<xsd:complexContent >
<xsd:extension base="AbstractCustomer">
<xsd:sequence minOccurs="1" maxOccurs="1">
<xsd:element name="credits" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>


<xsd:element name="Customers">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="MyCustomer" type="AbstractCustomer"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


</xsd:schema>

Valid by site

If we can't use Inheritance, we have to create one job that check the xsi:type for each MyCustomer, and
create different process for each class which extend MyCustomer. Because in my SGBD I have to create
three tables in order to store my customers. One AbstractCustomer which have the id share(because of the integrity constraint) for tables CustomerBasic
and CustomerPremium . What do you think ?

Do you have any idea ?

Thank in advance,
Highlighted
One Star

Re: retrieve XML from API REST

Hi
Is the return result of this web service is a XML file?
Or you want to get a XML respone?
1. Use tSOAP to get XML response.
2. Use tXSDValidator to validate XML file.
3. tFileInputXML to retrieve data.
Regards,
Pedro
Highlighted
One Star

Re: retrieve XML from API REST

@pedro
Yes the result is in XML.
Thank for give me a way to manage it, I will try your solution.
Regards,
Pegazus

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog