Sending PDF to REST service

Posted by goo on 31-Jan-2020 07:33

12.0

I am going to make a new Endpoint that retrives a pdf document from the database using an appserver call.

1. What would be prefered way of sending a pdf file from AppServer to my Pasoe webserver? yes- we have splitt db from pasoe. 

I have seeen some using:

* run copyfile.p on server (output mFileCopy).......

* using a temp-table with blob/clob record

Is there a commen way in 12 to do this?

2. Is there something I need to think of when using oResponse and oBody when sending PDF?

Whould it be ok doing:

Assign

oResponse = new OpenEdge.Web.WebResponse()

oResponse:StatusCode = int(StatusCodeEnum:OK)

.

and use something like https://knowledgebase.progress.com/articles/Article/how-to-send-a-binary-file-with-the-HTTP-client-as-part-of-a-MIME-message

passing the PDF? 

Would I need to send it binary?

//Geir Otto

Posted by Stefan Drissen on 03-Feb-2020 13:01

Looking at knowledgebase.progress.com/.../P118192 I would guess that you are killing your document server side with set-size( mfile ) = 0.

All Replies

Posted by Peter Judge on 31-Jan-2020 14:06

There's a small example at github.com/.../content_types for returning PDFs from a webhandler.
 
You can also call from AppServer to PASOE (and vice versa) using normal ABL.
 
 
 

Posted by goo on 03-Feb-2020 12:51

Could you explain what I am doing wrong here?

serverside:

BLOCK-LEVEL ON ERROR UNDO, THROW.

DEFINE INPUT PARAMETER ipDocumentId AS CHARACTER NO-UNDO. /*Either rowid or base64encoded filename*/

DEFINE OUTPUT PARAMETER mFile AS MEMPTR NO-UNDO.

DEFINE VARIABLE ridDocumentId AS ROWID NO-UNDO.

DEFINE VARIABLE oArkiv AS CLASS server.oo.BusinessLogic.Arkivhandler NO-UNDO.

ridDocumentId = TO-ROWID(ipDocumentId) NO-ERROR.

IF ERROR-STATUS:ERROR OR ridDocumentId = ? THEN

DO:

 oArkiv = NEW server.oo.BusinessLogic.Arkivhandler().

 mFile = oArkiv:getFileFromDisk(ipDocumentId).

 MESSAGE '--->mpFile:size:' GET-SIZE(mFile)

   VIEW-AS ALERT-BOX.

END.

CATCH eAny AS Progress.Lang.Error :

 MESSAGE 'Feilet i ' PROGRAM-NAME(1) ' ' eAny:GetMessage(1)

   VIEW-AS ALERT-BOX.  

END CATCH.

FINALLY:

 set-size(mFile) = 0.

END.

Client side (PASOE Appserver calling another appserver):

 METHOD PUBLIC memptr getDocumentById(input ipDocumentId as char):

   def var hServer as handle no-undo.

   hServer = JBoxSession:Instance:AppServerHandle.

   MESSAGE 'before.....mpCall'

   VIEW-AS ALERT-BOX.

  run download_bydocumentid.p on hServer (input ipDocumentid, output mpFile).

  MESSAGE 'after ...mpCall....:size:' get-size(mpFile)

   VIEW-AS ALERT-BOX.

   return mpFile.

   CATCH eAny AS Progress.Lang.Error :

     ASSIGN

       hasError      = TRUE

       MessageStatus = eAny:GetMessage(1)

       .

   END CATCH.

 END METHOD.

I get no error, but get-size gives 0, why??

serverside gives me:

[20/02/03@13:40:41.390+0100] P-005728 T-005748 1 AS -- (Procedure: 'download_bydocumentid.p' Line:27) inne i  download_bydocumentid.p

[20/02/03@13:40:41.402+0100] P-005728 T-005748 1 AS -- (Procedure: 'download_bydocumentid.p' Line:37) --->mpFile:size: 111877

Posted by Stefan Drissen on 03-Feb-2020 13:01

Looking at knowledgebase.progress.com/.../P118192 I would guess that you are killing your document server side with set-size( mfile ) = 0.

Posted by goo on 03-Feb-2020 13:50

aaah... I was afaid it would not be cleaned after finished.... Thanks BIG!!

This thread is closed