You are not logged in.

Unanswered posts



Important! This site has been replaced. All content here is read-only. Please visit our brand-new community at https://community.talend.com/. We look forward to hearing from you there!



#1 2011-11-08 12:52:55

radugrigorovici
Member
6 posts

radugrigorovici said:

[resolved] Send file to WebService

Tags: [webservice]

Hi all,

I'm trying to send a file to a Webservice, along with other parameters. For reading the file I use tFileDelimited with no separators, then pass the content to tWebServiceInput. I cannot figure out how to refer that content in the parameter list from tWebServiceInput for sending it to the WebServer.

Regards,
Radu

Offline

#2 2011-11-08 13:12:40

shong
Talend Team


shong said:

Re: [resolved] Send file to WebService

Hi
Store the content into a global variable and get it on the parameter list of tWebserviceInput, for example:
tFileInputDelimited--main--tJavaRow
    |
onsubjobok
    |
tWebserviceInput--main--tLogRow

on tJavaRow:
globalMap.put("file_content", input_row.content)    //content is the column name on tFileInputDelimited

on tWebserviceInput, set the value of parameters as below:

(String)globalMap.get("file_content")

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

#3 2011-11-09 09:47:28

radugrigorovici
Member
6 posts

radugrigorovici said:

Re: [resolved] Send file to WebService

Hi Shong,

It worked. Thanks for your help!

Best Regards,
Radu

Offline

#4 2011-11-09 10:00:41

shong
Talend Team


shong said:

Re: [resolved] Send file to WebService

radugrigorovici wrote:

Hi Shong,

It worked. Thanks for your help!

Best Regards,
Radu

Good news, thanks for your feedback!

Best regards
Shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the global leader of open source data management and application integration solutions!

Offline

#5 2011-11-09 12:41:03

radugrigorovici
Member
6 posts

radugrigorovici said:

Re: [resolved] Send file to WebService

Hi,

The file gets to the WebService in a wrong format. I guess it's not byte[] when send from WebServiceInput. I specified byte[] in FileInputDelimited's schema, and also changed the parameter expression in WebServiceInput to (byte[])globalMap.get("file_content"), but still, the received file is corrupted (is csv, xlsx,..).

Regards,
Radu

Offline

#6 2011-11-09 15:30:23

janhess
Member
1315 posts

janhess said:

Re: [resolved] Send file to WebService

Should you not just specify it as a string?

Offline

#7 2011-11-09 15:53:24

radugrigorovici
Member
6 posts

radugrigorovici said:

Re: [resolved] Send file to WebService

janhess wrote:

Should you not just specify it as a string?

I did that at first, but with similar results.

Inside the talend job it seems to be ok, it has the right length, but then the webservice receives it truncated at 6 characters.

Offline

#8 2011-11-09 16:43:23

janhess
Member
1315 posts

janhess said:

Re: [resolved] Send file to WebService

Ah! I think you need base64 encoding. I had this problem sending binary data from a webservice. Had to encode it to send from webservice and decode on receipt.

Last edited by janhess (2011-11-09 16:43:38)

Offline

#9 2011-11-10 09:27:16

radugrigorovici
Member
6 posts

radugrigorovici said:

Re: [resolved] Send file to WebService

janhess wrote:

Ah! I think you need base64 encoding. I had this problem sending binary data from a webservice. Had to encode it to send from webservice and decode on receipt.

How can I encode it? Is it a componet which I have to use or encode in java?

I should mention that I'm not a java programmer.

Regards,
Radu

Offline

#10 2011-11-10 10:02:25

janhess
Member
1315 posts

janhess said:

Re: [resolved] Send file to WebService

Use a tJavaRow for the encode/decode.
To enccode

            String s = new sun.misc.BASE64Encoder().encode(input_row.Image);
            //System.out.println("Text Decryted : " + s);
            output_row.Image = s;

To deccode
            byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(input_row.Image);
            //System.out.println("Text Decryted : " + s);
            output_row.Image = buf;

Offline

#11 2011-11-10 11:52:18

radugrigorovici
Member
6 posts

radugrigorovici said:

Re: [resolved] Send file to WebService

janhess wrote:

Use a tJavaRow for the encode/decode.
To enccode

            String s = new sun.misc.BASE64Encoder().encode(input_row.Image);
            //System.out.println("Text Decryted : " + s);
            output_row.Image = s;

To deccode
            byte[] buf = new sun.misc.BASE64Decoder().decodeBuffer(input_row.Image);
            //System.out.println("Text Decryted : " + s);
            output_row.Image = buf;

Thanks Jan! Now it works.
Best Regards!

Offline

#12 2012-02-09 17:04:25

Alexman
Guest

Alexman said:

Re: [resolved] Send file to WebService

Would be the same procedure to send an XML to a Restful Web Service or is there something better?

#13 2012-02-09 17:28:49

janhess
Member
1315 posts

janhess said:

Re: [resolved] Send file to WebService

I think it only applies to binary data. Text should be ok.

Offline

#14 2015-12-09 01:18:00

knuckles05
Member
4 posts

knuckles05 said:

Re: [resolved] Send file to WebService

Hello, I was wondering if this process for encoding goes after you send the content of the file through a String.
tFileInputDelimited--main--tJavaRow--Encoding--output



Thank you!

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy