Tips, Tricks and Code Tips, Tricks and Code

MWS, CAF and Task...

How to UploadDownload a File from MWS To IS

Created by Liferay Admin, last modified on Wed, 7 Aug 2019, 14:15

This white paper describes how to create a portlet that uploads binary files from MWS to the Integration Server. It also shows you how to download binary files from Integration Server to MWS.

Submitted by: Mohan Panneerselvam, Software AG, May 2009

Applicable Versions: 7.1.2 to 8.x

SummaryThis document helps the reader to understand the technical details on how to upload/download a binary file from MWS to IS. We will also walk through the code to download the same file from IS to MWS.#

CAF PortletThis use case represents a requirement to upload a binary file like MS Word or MS Excel to IS for further processing. It is represented from screen shots on a local machine but is sufficient to explain the concepts. There are scenarios where we need to move a file from IS to MWS with a pop-up dialog to save/open file.#

Upload file from MWS to IS#

  1. Create a portlet Page with “File Input” component from palette. This example shows an added command button, which when clicked will do the job of reading the file and uploading it to IS.
    \
  2. Drag and drop a “File Item” into Bindings view and bind the same as the value for “File Input”.
    \
  3. Create an action in binds view. For this demonstration I created Upload File() and bound it to the action property of the Command Button.
    \
  4. Create an IS service with an input variable of “object” data type.
    \
  5. Decode the input variable using our public service base64Decode. In the example below, the “value” variable contains the byte array of the File that will be uploaded from MWS. Make sure the file uploaded is intact.
    \
  6. Connect to IS from Designer and drag and drop the IS service created above.
    \
  7. Double click the Upload File() function in the binding view to open the java code perspective.
  8. File Item object has a built-in service to get the byte array of the File uploaded from UI. Set the byte array as input to IS service as shown below.
    \
  9. Test the code by uploading the file.
    \!!!Download file from IS to MWS
  10. Read file object in IS and covert to byte and encode the object using base64Encode public service.
    \
  11. Use the code snippet below to get file object from IS service and decode.
    \
  12. Use built-in SimpleFileExporter bean to push the file to client.

9 Attachments
65385 Views
Average (0 Votes)
Comments
Hi, there are manual for wM v 9.9?, my problem its when I send the UNKNOWN to my service, the error is, unknown object can't serialize.
Posted on 2/3/16 7:58 PM.
hey theLionCode 8310,

any luck solving this issue? i'm facing it as well
Posted on 2/19/16 2:10 PM in reply to theLeonCode 8310.
also getting same error
unknown object can't serialize.
can anyone please help.

I am using webMethods 9.8
Posted on 5/17/16 2:46 AM.