Receive file from appserver gets 0 bytes file - Send it's ok - Forum - OpenEdge Development - Progress Community

Receive file from appserver gets 0 bytes file - Send it's ok

 Forum

Receive file from appserver gets 0 bytes file - Send it's ok

This question is answered

I'm testing before making some programs, but I stumble upon on this.   (Classic Appserver 11.5, client networking 11.7, both on windows)

This is the client

DEFINE VARIABLE hServer            AS HANDLE      NO-UNDO.
DEFINE VARIABLE lRetOK             AS LOGICAL     NO-UNDO.
                           
def var mFile1 as memptr no-undo.             
def var mFile2 as memptr no-undo.

//SET-SIZE(mFileCopy) = 700000.

 CREATE SERVER hServer.

lRetOK = hServer:CONNECT("-H xxx.101.yyy.zzz -DirectConnect -S 9030 -AppService schAS1 -sessionModel Session-free") .
IF NOT lRetOK THEN
DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE (1).                
    RETURN.
END.


COPY-LOB FILE "d:\t\log.lg" TO OBJECT mFile1.

run procs\tdi\test.p on hServer (INPUT mFile1, output mFile2).

COPY-LOB OBJECT mFile2 to file "d:\t\t2.exe".

hServer:DISCONNECT().
DELETE OBJECT hServer.


CATCH myS AS Progress.Lang.SysError :
     MESSAGE myS:NumMessages myS:getmessage(1)
         VIEW-AS ALERT-BOX ERROR BUTTONS OK TITLE "SysError".
END CATCH.
CATCH myA AS Progress.Lang.AppError :
     MESSAGE myA:NumMessages myA:getmessage(1)
         VIEW-AS ALERT-BOX WARNING BUTTONS OK.
END CATCH.

FINALLY:
    SET-SIZE(mFile1) = 0.
    SET-SIZE(mFile2) = 0.
END.

This is the server process

BLOCK-LEVEL ON ERROR UNDO, THROW.

DEFINE INPUT PARAMETER mInput AS MEMPTR NO-UNDO.
DEFINE OUTPUT PARAMETER mFile AS MEMPTR NO-UNDO.


/* ***************************  Main Block  *************************** */

MESSAGE NOW "copy-lob".
COPY-LOB OBJECT mInput TO FILE "C:\t\log1.txt".
COPY-LOB FILE "c:\t\t2.exe" TO OBJECT mFile.
FILE-INFO:FILE-NAME = "C:\t\log1.txt".
MESSAGE NOW "txt tfile  size: " FILE-INFO:FILE-SIZE.
MESSAGE NOW "mFile size: " GET-SIZE(mFile).
MESSAGE NOW "End copy-lob".


CATCH myS AS Progress.Lang.SysError :  
    RETURN ERROR NEW Progress.Lang.AppError(myS:GetMessage(1), 404).
END CATCH.
CATCH myA AS Progress.Lang.AppError :   
    RETURN ERROR NEW Progress.Lang.AppError(myA:GetMessage(1), 404).
END CATCH.

FINALLY:
   set-size(mFile) = 0.
   set-size(mInput) = 0.
END.

The process runs accordingly...  d:\t\log.lg file is textfile.  

On server side, I get the file on disk with content ok.

On the client side, the resulting file t2.exe. is 0 bytes in length...

 Using notes from

https://community.progress.com/community_groups/openedge_development/f/19/p/20414/113714

TIA

Jorge

Verified Answer
  • Solved by:

    https://knowledgebase.progress.com/articles/Article/000053880

    Appserver code:

    BLOCK-LEVEL ON ERROR UNDO, THROW.
    
    DEFINE INPUT  PARAMETER mInput  AS MEMPTR    NO-UNDO.
    DEFINE OUTPUT PARAMETER mOutput AS LONGCHAR  NO-UNDO.
    
    DEFINE VARIABLE memFile AS MEMPTR NO-UNDO.
    
    
    /* ***************************  Main Block  *************************** */
    
    MESSAGE NOW "copy-lob".
    COPY-LOB OBJECT mInput TO FILE "C:\t\log1.txt".
    COPY-LOB FILE "c:\t\t2.exe" TO OBJECT memFile.
    
    
    MESSAGE NOW "txt tfile  size: " FILE-INFO:FILE-SIZE.
    mOutput = BASE64-ENCODE(memFile).
    MESSAGE NOW "End copy-lob".
    
    
    CATCH myS AS Progress.Lang.SysError :    /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myS:GetMessage(1), 404).
    END CATCH.
    CATCH myA AS Progress.Lang.AppError :      /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myA:GetMessage(1), 404).
    END CATCH.
    
    FINALLY:
        set-size(mInput) = 0.
    END.
    

    Cliente code:

    DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
    DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.

    def var mFile1 as memptr no-undo.
    def var mFile2 as LONGCHAR no-undo.


    CREATE SERVER hServer.

    lRetOK = hServer:CONNECT("-H xxx.101.yyy.zzz -DirectConnect -S 9030 -AppService schAS1 -sessionModel Session-free") .
    IF NOT lREtOK THEN
    DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE (1)
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
    RETURN.
    END.


    COPY-LOB FILE "d:\t\log.lg" TO OBJECT mFile1.

    run procs\tdi\test.p on hserver (INPUT mFile1, output mFile2).

    mFile1 = BASE64-DECODE(mFile2).

    COPY-LOB OBJECT mFile1 to file "d:\t\t2.exe".

    hServer:DISCONNECT().
    DELETE OBJECT hServer.

    CATCH myS AS Progress.Lang.SysError : /* hubo error de */
    MESSAGE myS:NumMessages myS:getmessage(1)
    VIEW-AS ALERT-BOX ERROR BUTTONS OK TITLE "SysError".
    END CATCH.
    CATCH myA AS Progress.Lang.AppError : /* hubo error de */
    MESSAGE myA:NumMessages myA:getmessage(1)
    VIEW-AS ALERT-BOX WARNING BUTTONS OK.
    END CATCH.

    FINALLY:
    SET-SIZE(mFile1) = 0.
    END.

  • Solved by:

     

    Appserver code:

    BLOCK-LEVEL ON ERROR UNDO, THROW.
    
    DEFINE INPUT  PARAMETER mInput  AS MEMPTR    NO-UNDO.
    DEFINE OUTPUT PARAMETER mOutput AS LONGCHAR  NO-UNDO.
    
    DEFINE VARIABLE memFile AS MEMPTR NO-UNDO.
    
    
    /* ***************************  Main Block  *************************** */
    
    MESSAGE NOW "copy-lob".
    COPY-LOB OBJECT mInput TO FILE "C:\t\log1.txt".
    COPY-LOB FILE "c:\t\t2.exe" TO OBJECT memFile.
    
    
    MESSAGE NOW "txt tfile  size: " FILE-INFO:FILE-SIZE.
    mOutput = BASE64-ENCODE(memFile).
    MESSAGE NOW "End copy-lob".
    
    
    CATCH myS AS Progress.Lang.SysError :    /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myS:GetMessage(1), 404).
    END CATCH.
    CATCH myA AS Progress.Lang.AppError :      /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myA:GetMessage(1), 404).
    END CATCH.
    
    FINALLY:
        set-size(mInput) = 0.
    END.
    

    Cliente code:

    DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
    DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.

    def var mFile1 as memptr no-undo. 
    def var mFile2 as LONGCHAR no-undo.


    CREATE SERVER hServer.

    lRetOK = hServer:CONNECT("-H xxx.101.yyy.zzz -DirectConnect -S 9030 -AppService schAS1 -sessionModel Session-free") .
    IF NOT lREtOK THEN
    DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE (1) 
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK. 
    RETURN.
    END.


    COPY-LOB FILE "d:\t\log.lg" TO OBJECT mFile1.

    run procs\tdi\test.p on hserver (INPUT mFile1, output mFile2).

    mFile1 = BASE64-DECODE(mFile2).

    COPY-LOB OBJECT mFile1 to file "d:\t\t2.exe".

    hServer:DISCONNECT().
    DELETE OBJECT hServer.

    CATCH myS AS Progress.Lang.SysError : /* hubo error de */
    MESSAGE myS:NumMessages myS:getmessage(1)
    VIEW-AS ALERT-BOX ERROR BUTTONS OK TITLE "SysError".
    END CATCH.
    CATCH myA AS Progress.Lang.AppError : /* hubo error de */
    MESSAGE myA:NumMessages myA:getmessage(1)
    VIEW-AS ALERT-BOX WARNING BUTTONS OK.
    END CATCH.

    FINALLY:
    SET-SIZE(mFile1) = 0. 
    END.

All Replies
  • And this is the log on appserver

    [20/01/22@09:41:03.229-0600] P-005632 T-002908 1 AS -- (Procedure: 'procs\tdi\test.p' Line:25) 22/01/2020 09:41:03.229-06:00 copy-lob

    [20/01/22@09:41:03.288-0600] P-005632 T-002908 1 AS -- (Procedure: 'procs\tdi\test.p' Line:29) 22/01/2020 09:41:03.288-06:00 txt tfile  size:  916

    [20/01/22@09:41:03.288-0600] P-005632 T-002908 1 AS -- (Procedure: 'procs\tdi\test.p' Line:30) 22/01/2020 09:41:03.288-06:00 mFile size:  63765280

    [20/01/22@09:41:03.288-0600] P-005632 T-002908 1 AS -- (Procedure: 'procs\tdi\test.p' Line:31) 22/01/2020 09:41:03.288-06:00 End copy-lob

  • Solved by:

    https://knowledgebase.progress.com/articles/Article/000053880

    Appserver code:

    BLOCK-LEVEL ON ERROR UNDO, THROW.
    
    DEFINE INPUT  PARAMETER mInput  AS MEMPTR    NO-UNDO.
    DEFINE OUTPUT PARAMETER mOutput AS LONGCHAR  NO-UNDO.
    
    DEFINE VARIABLE memFile AS MEMPTR NO-UNDO.
    
    
    /* ***************************  Main Block  *************************** */
    
    MESSAGE NOW "copy-lob".
    COPY-LOB OBJECT mInput TO FILE "C:\t\log1.txt".
    COPY-LOB FILE "c:\t\t2.exe" TO OBJECT memFile.
    
    
    MESSAGE NOW "txt tfile  size: " FILE-INFO:FILE-SIZE.
    mOutput = BASE64-ENCODE(memFile).
    MESSAGE NOW "End copy-lob".
    
    
    CATCH myS AS Progress.Lang.SysError :    /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myS:GetMessage(1), 404).
    END CATCH.
    CATCH myA AS Progress.Lang.AppError :      /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myA:GetMessage(1), 404).
    END CATCH.
    
    FINALLY:
        set-size(mInput) = 0.
    END.
    

    Cliente code:

    DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
    DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.

    def var mFile1 as memptr no-undo.
    def var mFile2 as LONGCHAR no-undo.


    CREATE SERVER hServer.

    lRetOK = hServer:CONNECT("-H xxx.101.yyy.zzz -DirectConnect -S 9030 -AppService schAS1 -sessionModel Session-free") .
    IF NOT lREtOK THEN
    DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE (1)
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.
    RETURN.
    END.


    COPY-LOB FILE "d:\t\log.lg" TO OBJECT mFile1.

    run procs\tdi\test.p on hserver (INPUT mFile1, output mFile2).

    mFile1 = BASE64-DECODE(mFile2).

    COPY-LOB OBJECT mFile1 to file "d:\t\t2.exe".

    hServer:DISCONNECT().
    DELETE OBJECT hServer.

    CATCH myS AS Progress.Lang.SysError : /* hubo error de */
    MESSAGE myS:NumMessages myS:getmessage(1)
    VIEW-AS ALERT-BOX ERROR BUTTONS OK TITLE "SysError".
    END CATCH.
    CATCH myA AS Progress.Lang.AppError : /* hubo error de */
    MESSAGE myA:NumMessages myA:getmessage(1)
    VIEW-AS ALERT-BOX WARNING BUTTONS OK.
    END CATCH.

    FINALLY:
    SET-SIZE(mFile1) = 0.
    END.

  • Solved by:

     

    Appserver code:

    BLOCK-LEVEL ON ERROR UNDO, THROW.
    
    DEFINE INPUT  PARAMETER mInput  AS MEMPTR    NO-UNDO.
    DEFINE OUTPUT PARAMETER mOutput AS LONGCHAR  NO-UNDO.
    
    DEFINE VARIABLE memFile AS MEMPTR NO-UNDO.
    
    
    /* ***************************  Main Block  *************************** */
    
    MESSAGE NOW "copy-lob".
    COPY-LOB OBJECT mInput TO FILE "C:\t\log1.txt".
    COPY-LOB FILE "c:\t\t2.exe" TO OBJECT memFile.
    
    
    MESSAGE NOW "txt tfile  size: " FILE-INFO:FILE-SIZE.
    mOutput = BASE64-ENCODE(memFile).
    MESSAGE NOW "End copy-lob".
    
    
    CATCH myS AS Progress.Lang.SysError :    /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myS:GetMessage(1), 404).
    END CATCH.
    CATCH myA AS Progress.Lang.AppError :      /* hubo error de */
        RETURN ERROR NEW Progress.Lang.AppError(myA:GetMessage(1), 404).
    END CATCH.
    
    FINALLY:
        set-size(mInput) = 0.
    END.
    

    Cliente code:

    DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
    DEFINE VARIABLE lRetOK AS LOGICAL NO-UNDO.

    def var mFile1 as memptr no-undo. 
    def var mFile2 as LONGCHAR no-undo.


    CREATE SERVER hServer.

    lRetOK = hServer:CONNECT("-H xxx.101.yyy.zzz -DirectConnect -S 9030 -AppService schAS1 -sessionModel Session-free") .
    IF NOT lREtOK THEN
    DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE (1) 
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK. 
    RETURN.
    END.


    COPY-LOB FILE "d:\t\log.lg" TO OBJECT mFile1.

    run procs\tdi\test.p on hserver (INPUT mFile1, output mFile2).

    mFile1 = BASE64-DECODE(mFile2).

    COPY-LOB OBJECT mFile1 to file "d:\t\t2.exe".

    hServer:DISCONNECT().
    DELETE OBJECT hServer.

    CATCH myS AS Progress.Lang.SysError : /* hubo error de */
    MESSAGE myS:NumMessages myS:getmessage(1)
    VIEW-AS ALERT-BOX ERROR BUTTONS OK TITLE "SysError".
    END CATCH.
    CATCH myA AS Progress.Lang.AppError : /* hubo error de */
    MESSAGE myA:NumMessages myA:getmessage(1)
    VIEW-AS ALERT-BOX WARNING BUTTONS OK.
    END CATCH.

    FINALLY:
    SET-SIZE(mFile1) = 0. 
    END.