H DFTACTGRP(*NO) BNDDIR('HTTPAPI') D VATTEST PR ExtPgm('VATTEST') D countryCode 2A const D vatNumber 11A const D VATTEST PI D countryCode 2A const D vatNumber 11A const D Incoming PR D valid 1N D depth 10I 0 value D name 1024A varying const D path 24576A varying const D value 32767A varying const D attrs * dim(32767) D const options(*varsize) /copy HTTPAPI_H /copy IFSIO_H d URL s 200A varying D rc s 10i 0 d filename s 50a varying D valid s 1n D SOAP s 2000A varying /free if (%parms < 2); http_comp('Usage: CALL VATTEST PARM(country-code vat-number)'); *inlr = *on; return; endif; SOAP = ' + + + + ' + %trim(countryCode) + '+ ' + %trim(vatNumber) + '+ + + '; http_debug(*ON); filename = http_tempfile() + '.xml'; URL='http://ec.europa.eu/taxation_customs/vies/api/checkVatPort'; rc = http_url_post( URL : %addr(SOAP)+2 : %len(SOAP) : filename : HTTP_TIMEOUT : HTTP_USERAGENT : 'text/xml; charset=iso-8859-1' : '' ); if (rc <> 1); unlink(filename); http_crash(); endif; valid = *off; rc = http_parse_xml_stmf( filename : HTTP_XML_CALC : *null : %paddr(incoming) : %addr(valid) ); unlink(filename); if (rc < 0); http_crash(); endif; if (valid); http_comp('Valid = TRUE'); else; http_comp('Valid = FALSE'); endif; *inlr = *on; /end-free *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ P Incoming B D Incoming PI D valid 1N D depth 10I 0 value D name 1024A varying const D path 24576A varying const D value 32767A varying const D attrs * dim(32767) D const options(*varsize) /free if (name = 'valid'); if (%xlate('true':'TRUE': value) = 'TRUE'); valid = *on; endif; endif; /end-free P E