Forum Post: RE: Send or Receive Binary File through REST webservice

  • Thread starter Thread starter Vinko Buzak
  • Start date Start date
Status
Not open for further replies.
V

Vinko Buzak

Guest
According to Progress Knowledge Base Article 000027108, to pass binary data via Web Services it is recommended that the Web Service be defined to pass the data via a LONGCHAR variable and the binary data should be BASE 64 encoded using the built-in BASE64-ENCODE function (the BASE64-DECODE function can be used to convert the LONGCHAR data back to binary data). This code is taken from the base64-encode function help: -------------------- DEFINE VARIABLE encdmptr AS MEMPTR NO-UNDO. DEFINE VARIABLE encdlngc AS LONGCHAR NO-UNDO. COPY-LOB FROM FILE "C:\myicons\test.ico" TO encdmptr. encdlngc = BASE64-ENCODE(encdmptr). COPY-LOB FROM encdlngc TO FILE "C:\myicons\testencode". -------------------- Here is the code example from the DECODE help page: -------------------- DEFINE VARIABLE decdmptr AS MEMPTR NO-UNDO. DEFINE VARIABLE decdlngc AS LONGCHAR NO-UNDO. COPY-LOB FROM FILE "C:\myicons\testencode" TO decdlngc. decdmptr = BASE64-DECODE(decdlngc). COPY-LOB FROM decdmptr TO FILE "C:\myicons\test.ico". -------------------- And here is another example: -------------------- DEFINE VARIABLE encdmptr AS MEMPTR NO-UNDO. DEFINE OUTPUT PARAMETER pinum AS INT. DEFINE OUTPUT PARAMETER StorageVariable AS LONGCHAR. FIND FIRST filetest NO-LOCK. ASSIGN pinum = filetest.num. /* ASSIGN StorageVariable = BASE64-ENCODE(filetest.pdafile). */ COPY-LOB FROM filetest.pdafile TO encdmptr. StorageVariable = BASE64-ENCODE(encdmptr). -------------------- Hope this helps :-)

Continue reading...
 
Status
Not open for further replies.
Back
Top