I have a pdf that that must be converted in to base64 so it can be mapped into an xml element with the XMLWriterService.
From the Lansa Integrator documentation i understand it can be done by the HashService:
5.8.3 HASH
The HASH command generates the hash of the specified field or file. The hash value is returned in the command message response field
I tried this in integrator with :
HASH FILE(/tmp/NL00000007.PDF) HASHENCODING(*BASE64)
Although the message response field is long enough it contains only 28 characters.
It is not clear to me what parameters are to be used or if this is even the right way to do this.
Any suggestions?
How to convert a pdf to base64 to use in the XMLWriterService
-
caseywhite
- Posts: 192
- Joined: Thu May 26, 2016 1:17 am
Re: How to convert a pdf to base64 to use in the XMLWriterService
If you are going to use LANSA Integrator I would suggest using the XMLBindFileService. It is newer and you can use the visual mapping of XML from Integrator studio. Either way though I think both services should automatically convert a BLOB data type to Base64 for you so you don't need to use the HASH service.
If your PDF is stored in the IFS just do the following where field UPLFIL is defined as a BLOB data type. That field doesn't need to be in a file.
#UPLFIL := #SA_DIR + '/' + #SA_FILNAM
You would send the field #UPLFIL. In the case of the XMLBindFileService it should just convert the BLOB data to Base64. I haven't used the XML Writer in a very long time so can't confirm how it would work but I suspect it would do the same thing.
If your PDF is stored in the IFS just do the following where field UPLFIL is defined as a BLOB data type. That field doesn't need to be in a file.
#UPLFIL := #SA_DIR + '/' + #SA_FILNAM
You would send the field #UPLFIL. In the case of the XMLBindFileService it should just convert the BLOB data to Base64. I haven't used the XML Writer in a very long time so can't confirm how it would work but I suspect it would do the same thing.
Re: How to convert a pdf to base64 to use in the XMLWriterService
Indeed works as you suggest with XMLBindFileService.
Thanks
Thanks