I'm using http_post_xml() and a callback procedure to parse the response:
After running this through debug, the resulting length LEN is 33243, but the value of variable DECODED is blanks.
I'm assuming the response data is UTF8 as indicated in the HTTP Debug header.
The encoded data length of the <base64LabelImage> element ( in http debug text file) is 44325
rc = http_post_xml(
'
https://elstestserver2.endicia.com/LabelService/EwsLabelService.asmx'
: %addr(SOAP) + 2
: %len(SOAP)
: *null
: %paddr(EndOfElement)
: %addr(userData)
: HTTP_TIMEOUT
: *omit
: 'text/xml; charset=UTF-8; +
SOAPaction="www.envmgr.com/LabelService/GetPostageLabel"'
);
P EndOfElement B
D EndOfElement PI
D userData * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 65535A varying const
D attrs * dim(32767)
D const options(*varsize)
dcl-s encoded varchar(65535);
dcl-s decoded char(65535);
dcl-s outSize uns(10);
dcl-s len uns(10);
select;
when name = 'Status';
response.status = value;
when name = 'TrackingNumber';
response.trackNbr = value;
when name = 'Base64LabelImage';
encoded = value;
outSize = %len(decoded);
len = base64_decode( %addr(encoded:*data)
: %len(%trim(encoded))
: %addr(decoded)
: outSize
);
response.label = %subst(decoded:1:len);
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Monday, July 20, 2020 10:53 AM
To: rpg400-l@xxxxxxxxxxxxxxxxxx
Subject: Re: Base64 decode
More information, please?
On 7/20/2020 8:52 AM, Greg Wilburn wrote:
It's been a while since I've had to decode something... I'm consuming a web service that is returning a Base64 encoded value... the web service is SOAP XML and returns a corresponding XML response encoding=UTF-8.
I've tried using Scott Klement's Base64 service program... I'm not getting an error, but the resulting value is blank?
Do I need to do something with the data before decoding?
TIA
Greg
As an Amazon Associate we earn from qualifying purchases.