Sending PDF to REST service - Forum - OpenEdge Development - Progress Community
 Forum

Sending PDF to REST service

This question is answered

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

Verified Answer
All Replies
  • 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.
     
     
     
  • 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

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

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