Upload a large object in the request body
This example demonstrates how to upload a large object in the message response body.
To upload a large object (LOB) to a web service server, specify an input parameter using a
TEXT or BYTE data type. The large object is sent in the request body.
Any binary file contents (image, PDF, zip, etc.) may be uploaded using this method.
Example: Uploading a BYTE object and writing to a file
In this example:
- The large object is transferred in the 
BYTEinput parameter b in the message body. - The 
writeFile()method writes the content of the variable b to a file (help.pdf) on the server side. 
IMPORT os
PUBLIC FUNCTION UploadByteToFile(b BYTE)
  ATTRIBUTES (WSPost,
              WSDescription="Upload BYTE and write to file on server",
              WSPath="/help/pdf")
  RETURNS STRING
    CONSTANT filename = "help.pdf"
    DEFINE ret STRING
    TRY   
       CALL b.writeFile(filename)
       LET ret = SFMT("Data received, saved to file: %1",filename)
    CATCH
       LET ret = SFMT(" Error getting data, not saved to file: %1",filename)
    END TRY 
    RETURN ret
END FUNCTION
Example: Client app calling the function
The client needs to load a
BYTE object before calling the
function.
IMPORT util
IMPORT FGL clientGWSStub
MAIN
  DEFINE wsstatus INTEGER
  DEFINE retS STRING
 
  DEFINE b BYTE
  LOCATE b IN MEMORY
  CALL b.readFile("help.pdf")
  CALL clientGWSStub.UploadByteToFile(b) RETURNING wsstatus, retS
  CASE wsstatus
    WHEN clientGWSStub.C_SUCCESS
      DISPLAY SFMT("Got %1 ", retS)
    OTHERWISE
      DISPLAY "wsstatus is : ", wsstatus
      DISPLAY "Error in getting file uploaded"
  END CASE
END MAINIn
this example:- A 
BYTEvariablebis created to hold the large object and theLOCATEinstruction specifies where it is stored (MEMORYorFILE). - The 
readFile()method reads the contents of a PDF file (help.pdf) into theBYTEvariableb. - A call to the server function is made specifying 
bas the input parameter. The data is transferred in the request body.