Base64 encoding is character set dependent. If you encode your data with an encoder for some EBCDIC CCSID and your online encoder expects it to be UTF8 it won't work.

The ILEastic project has a Base64 encoder for UTF8. This will definitely work better with the online encoders. I have successfully used it for JWT signing where you also have to Base64 encode the parts of the JWT token.

Best regards

Mihael


On 16.05.19 23:36, Greg Wilburn wrote:
Is this the easiest way to Base64 encode and XML document (either in an RPG variable or on the IFS) for use in a SOAP web service?

I've used Scott's BASE64R4 service program for smaller things like API keys, etc.

I've been trying to mock-up a test scenario, and I'm not getting the results I expected - pretty sure I'm doing something wrong with the varchar fields. The code I'm copying was using much smaller fixed length fields.

xmlData and xmlData64 are both varchar(2048)... however the data is nowhere near that large (utflen=710).

http_setCCSIDs( 1208: 0 );
utflen = HTTP_xlatedyn( %len(%trim(xmlData))
: %addr(xmlData)
: TO_ASCII
: p_xmlDataUTF );

b64len = base64_encode( p_xmlDataUTF
: utflen
: %addr(xmlData64)
: %size(xmlData64) );

dealloc p_xmlDataUTF;


My resulting data in xmlData64 does not match the online encoders.

Thanks,
Greg

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].