BPM, Workflow, and Case

 View Only
  • 1.  How to transfer file using a webservice?

    Posted Mon March 01, 2021 02:55 PM
    Hi All,

    Is it somehow possible to return a file in a BAW webservice as a response?

    Thx,

    ------------------------------
    Laszlo
    ------------------------------


  • 2.  RE: How to transfer file using a webservice?

    Posted Tue March 02, 2021 12:47 PM

    Due to how variables are handled in the BPM engine it is not safe to place the binary data of a file in a variable in its raw form. The issue is that some combinations of the potential file content can look like "escape" characters to the engine and cause an error. For this reason all the ECM* data types in the content management toolkit interact with the file as Base64 encoded strings.

    So if you want to return a binary file, you will need to get it into the variable encoded in a way that is acceptable (e.g. Base64). If you are working with the ECM components you already have that. If you are working with something else you will need to figure out how to get that encoding done. If you give us more information we can make some recommendations. 

    Note if it is an ECM file, you can return a URL and let the caller figure out how to download the file from that.



    ------------------------------
    Andrew Paier
    ------------------------------



  • 3.  RE: How to transfer file using a webservice?

    Posted Tue March 02, 2021 01:56 PM
    Well, my first idea was returning the file content as a BASE64 string too. Just wanted to know whether there is another solution.
    Anyway, thanks Andrew!

    ------------------------------
    Laszlo
    ------------------------------



  • 4.  RE: How to transfer file using a webservice?

    IBM Champion
    Posted Wed March 03, 2021 08:24 AM
    Hi Laszlo,

    You have 2 ways to do it:

    - BPM web service to return base64 mime type encoded string. Then whatever consumes this web service will take the base64 and decode it to a file (you can do this with Java easily). Not sure what is your setup at the other end when you say you want it to be downloadable. This isn't up to BPM. You can do whatever with your files

    - Or you can use BPM's built in filenet as the document store and use BPM web service to return the file content url instead of the actual file content. I much prefer this way. 

    Regards

    ------------------------------
    Thong Huynh
    Sydney NSW
    ------------------------------



  • 5.  RE: How to transfer file using a webservice?

    Posted Wed March 03, 2021 09:11 AM
    Hi Thong,

    Well, returning the BAE64 content is simple, but on caller's side the html page must decode it and make some coding to show it.
    The content URL isn't usable (in my case), because BAW asks user to log in to access that URL.

    Anyway, I will return the BASE64 content, and the developer of the caller web page will solve it somehow.

    ------------------------------
    Laszlo
    ------------------------------



  • 6.  RE: How to transfer file using a webservice?

    Posted Wed March 03, 2021 05:52 AM

    how to deal with document content is pretty good explained in KC:

    https://www.ibm.com/support/knowledgecenter/en/SS8JB4_20.x/com.ibm.wbpm.wle.editor.doc/topics/r_workdoccontent.html



    ------------------------------
    Tomas Dambrauskas
    ------------------------------



  • 7.  RE: How to transfer file using a webservice?

    Posted Wed March 03, 2021 06:33 AM
    Hi Thomas,

    Yes, I know how to get the content of an ECM document, the question was how to return it using a BAW-generated webservice (if possible not in BASE64 format but in downloadable format).


    ------------------------------
    Laszlo
    ------------------------------



  • 8.  RE: How to transfer file using a webservice?

    Posted Wed March 03, 2021 10:02 AM
    There are ways to display Base64 files in a browser for example this entry on stack overflow. The issue will likely be the exact format for that is going to differ based on the underlying file type, and if what you really want to do is download the file you likely need to do something more like this. However I bet that anchor has to be different for different file types, so if the type of file isn't set the client code may become complex.

    ------------------------------
    Andrew Paier
    ------------------------------



  • 9.  RE: How to transfer file using a webservice?

    Posted Wed March 03, 2021 10:13 AM
    Hi Andrew,

    Thanks for the links, that's really a great solution to create an element with inline (BASE64) file content and then show it. It solves many problem...

    ------------------------------
    Laszlo
    ------------------------------