Scott, thank you! that was spot on correct! Best regards, Magne ________________________________ Fra: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx på vegne av Scott Klement Sendt: on 09.12.2009 18:46 Til: HTTPAPI and FTPAPI Projects Emne: Re: Parse innerxml in base64 format Hi Magne, Most likely the result of base64_decode() is already in ASCII. (Or Unicode?) Unfortunately, the parameters you specified to the open() API have requested that OS/400 run your data through an EBCDIC->ASCII translation table before writing it. The result will most likely be garbage, as you've noted. Try making your open() statement look like this: unlink(filename); fd = open( filename : O_CREAT + O_WRONLY + O_CCSID : S_IRUSR + S_IWUSR : 819 ); In this case, the CCSID is 819, and that assumes that the data (BEFORE it was base64 encoded on the other end) is the ISO-8859-1 variant of ASCII. If it's something else, please change the CCSID accordingly. Magne Kofoed wrote: > Hi Scott, > > I am trying to parse a xml file where a tag contains base64 data (a test tif file). > Can I use the approach in GetInnerDoc to decode the base64 data and write to the ifs file? > > Seems like I get "rubbish" in the ifs file when i use base64_decode. > And I get base64 data when i skip the base64_decode. > Do I have to use iconv to convert the data before I use base64_decode? > > > Begsr ParseContent; > > http_xmlReturnPtr(*ON); > filename = http_tempfile() + '.xml'; > > // Note: http_XmlStripCRLF(*ON/*OFF) controls whether or not > // the XML parser removes CR and LF characters from the > // Xml data that's passed to your 'Incoming' procedure. > > http_XmlStripCRLF(*ON); > rc = http_parse_xml_stmf(%trim(Ma_xml) > : HTTP_XML_CALC > : *null > : %paddr(GetInnerDoc) > : %addr(filename)); > > if (rc <> 1); > http_crash(); > endif; > ma_content = filename; > > Endsr; > > I use the GetInnerDoc subroutine. > > P GetInnerDoc B export > D GetInnerDoc PI > D filename 50a varying > D depth 10I 0 value > D name 1024A varying const > D path 24576A varying const > D value likeds(Element_Val_t) > D Attrs * dim(32767) > D const options(*varsize) > D fd s 10i 0 > D fd3 s 10I 0 > D len s 10I 0 > D buf s 32768A > D outbuf S 24576A > D outlen S 10I 0 > > /free > > if path = '/soapenv:Envelope/soapenv:Body/' > + 'rs:getContentResponse'; > if (name = 'content:content'); > fd = open( filename > : O_CREAT + O_TRUNC + O_WRONLY + O_CCSID > + O_TEXTDATA + O_TEXT_CREAT > : S_IRUSR + S_IWUSR > : 819 > : 0 ); > // FIXME: Add error handling. > > outlen = base64_decode( value.buf > : value.len > : %addr(outbuf) > : %size(outbuf) ); > > callp write(fd: %addr(outbuf): outlen); > > callp close(fd); > endif; > endif; > /end-free > P E > > The entire program and the xml file is enclosed in the zip file. > > Best regards, > > Magne > ----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------
<<winmail.dat>>
----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubscribe, please go to: http://www.scottklement.com/mailman/listinfo/ftpapi -----------------------------------------------------------------------