Retrieve attachment (octet-stream) from SOAP or REST webservice

Highlighted
Five Stars

Retrieve attachment (octet-stream) from SOAP or REST webservice

Hello,

 

I've done a lot of research and I can't find a reliable solution to my issue:

I'm using talend DI 7.1.

I'm trying to call a webservice (my provider publishes it as a REST as well as a SOAP webservice) and retrieve the PDF attchment returned by this webservice.

I successfully achieved this with SOAPUI (both ways; REST and SOAP) (soapui.png). But whith this tools, you only have to double click on the attachment to display it (soapui2.png).

But I really don't know how to do this with Talend DI.

talend1.png, talend2.png and talend3.png will show you how I managed it until now.

 

I successfully call the webservice (both ways; in the screenshot, I kept only REST), which returns "OK". But how to retrieve the attachment?

 

My issue seems to be an encoding issue, as characters are modified by tRestClient. (expected.png is what Soapui get, actual.png is what is written in my tFileouputDelimited).

FYI I tried UTF-8 and ISO-8859-15 as encoding (I 'm in France) and even if characters are different, the result is not the one I expect.

I read somewhere to use a tFileFetch to retrieve the attchment, using the URL sent in the response BUT there is no URL in the response.

I read that I need to get the response as binary but I don't know how to manage this.

And I read that the response could be encode64-based but I don't know how to manage this neither.

 

Could you please help me? 

 

Don't hesitate to ask more details if needed.

Thanks

 


Accepted Solutions
Five Stars

Re: Retrieve attachment (octet-stream) from SOAP or REST webservice

Hi,

 

I wanted to give the solution to this issue. (using the SOAP webservice)

FYI I tried every component allowing to call a webservice, I guess.

The one I successfully used to achieve this, is tHttpRequest.

- First write the xml file you wish to send to the webservice as parameters. (you need to write everything from the root node)

- Read this file in a tHttpRequest (checking option "Post parameters from file" (you can put "onComponentOk" beteween writing the xml and thttpRequest component)

- Set up the httpRequest with the webservice's endpoint in the "URI" field

- Check "the out to file option " (in French: "Ecrire le contenu de la réponse dans le fichier")

- Set the path of this output

- Read this file with a tFileInputRaw (you can pu a onComponentOK between thttpRequest en tFileInputRaw) (it doesn't seem to be mandatory to check "read the file as a byte array")

- Write in a tFileOutputRaw (with a main link between Input and output).

I'm not sur the encoding of the tFileoutputRaw is relevant, but I set it to my local encoding (ISO-8859-15)

 

Even if the response is a multipart one, it works, I'm not sure why. (I'm not used to webservices)

I'm pretty sure it will work with a REST webservice. But I won't try it right now.

View solution in original post


All Replies
Highlighted
Five Stars

Re: Retrieve attachment (octet-stream) from SOAP or REST webservice

Adding last 2 screenshot with expected result and actual one.

Thanks

Highlighted
Five Stars

Re: Retrieve attachment (octet-stream) from SOAP or REST webservice

UP

Five Stars

Re: Retrieve attachment (octet-stream) from SOAP or REST webservice

Hi,

 

I wanted to give the solution to this issue. (using the SOAP webservice)

FYI I tried every component allowing to call a webservice, I guess.

The one I successfully used to achieve this, is tHttpRequest.

- First write the xml file you wish to send to the webservice as parameters. (you need to write everything from the root node)

- Read this file in a tHttpRequest (checking option "Post parameters from file" (you can put "onComponentOk" beteween writing the xml and thttpRequest component)

- Set up the httpRequest with the webservice's endpoint in the "URI" field

- Check "the out to file option " (in French: "Ecrire le contenu de la réponse dans le fichier")

- Set the path of this output

- Read this file with a tFileInputRaw (you can pu a onComponentOK between thttpRequest en tFileInputRaw) (it doesn't seem to be mandatory to check "read the file as a byte array")

- Write in a tFileOutputRaw (with a main link between Input and output).

I'm not sur the encoding of the tFileoutputRaw is relevant, but I set it to my local encoding (ISO-8859-15)

 

Even if the response is a multipart one, it works, I'm not sure why. (I'm not used to webservices)

I'm pretty sure it will work with a REST webservice. But I won't try it right now.

View solution in original post

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