0

I am new to webmethods and need some guidance. I am tasked to read the PDF document from SFTP server and base64 encode it. I have managed to GET the file from SFTP location and now struggling to encode it. Below is the code snippet to read the file:

INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
MAP

I later modified the code to include base64 encoding, no output is produced. Code is shown below:

INVOKE pub.client.sftp:login
INVOKE pub.client.sftp:cd
INVOKE pub.client.sftp:ls
INVOKE pub.client.sftp:get
INVOKE pub.string:base64Encode
MAP

when i debug the code, it executes SFTP GET and stops. No information about encoding.

enter image description here

enter image description here

Please guide me to achieve this requirement. Thank you for your help in advance.

pitsa
  • 93
  • 2
  • 7

2 Answers2

1

Try something like this, Sequence after sftp:get, invoke the pub.io:streamToBytes and then invoke pub.string:base64Encode

Don't forget to map field in pipeline.

alexringo
  • 137
  • 1
  • 5
0

The pub.string:base64Encode expect a byte[] Input, you can try to convert the stream to byte[] with pub.io:streamToBytes

Michael Knoth
  • 58
  • 1
  • 2
  • 10
  • Thank you for your response. I tried using pub.io:streamToBytes and get below error: com.wm.app.b2b.server.ServiceException: [ISS.0086.9167] stream is a required field – pitsa Jun 02 '20 at 08:42
  • Did you map the output of sftp.get to the input of streamToBytes as shown in alexringo Answer? – Michael Knoth Sep 22 '20 at 12:54