Last active
October 7, 2022 10:17
-
-
Save jonkerw85/09bece794a01bd22d8856c3b1deed267 to your computer and use it in GitHub Desktop.
IBMi XML Toolkit over HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// $url = "http://common1.frankeni.com:58700/cgi-bin/xmlcgi.pgm"; | |
$uid = ''; | |
$pwd = ''; | |
$url = 'http://10.230.18.10/cgi-bin/xmlcgi.pgm'; | |
$ixml = "<?xml version='1.0' encoding='UTF-8' ?>\n"; | |
$ixml .= '<xmlservice>'; | |
$ixml .= '<cmd>CHGLIBL LIBL({LIBRARY LIST}) CURLIB(XMLSERVICE)</cmd>'; | |
$ixml .= " <pgm name='{PGM NAME}' lib=''>"; | |
$ixml .= " <parm comment='Tenant'><data var='PRMTEN' type='20A'>XXXX</data></parm>"; | |
$ixml .= " <parm comment='Functie'><data var='PRMFUN' type='2p0'>1</data></parm>"; | |
$ixml .= " <parm comment='companyNumber'><data var='PRMBDF' type='2p0'>29</data></parm>"; | |
$ixml .= " <parm comment='reference'><data var='REF#' type='9p0'>75240005</data></parm>"; | |
$ixml .= " <parm comment='JsonInput'><data var='PRMIN' type='4000A'>[]</data></parm>"; | |
$ixml .= " <parm comment='JsonOutput'><data var='PRMOUT' type='32000A' /></parm>"; | |
$ixml .= '</pgm>'; | |
$ixml .= '</xmlservice>'; | |
$postdata = http_build_query( | |
[ | |
'db2' => '*LOCAL', | |
'uid' => $uid, | |
'pwd' => $pwd, | |
'ipc' => '*na', | |
'ctl' => '*here', | |
'xmlin' => $ixml, | |
'xmlout' => 512000, | |
] | |
); | |
$opts = ['http' => [ | |
'method' => 'POST', | |
'header' => 'Content-type: application/x-www-form-urlencoded', | |
'content' => $postdata, | |
]]; | |
if (strpos($url, 'ttps') > 0) { | |
$opts['ssl'] = [ | |
'verify_peer' => false, | |
'verify_peer_name' => false, ]; | |
} | |
$context = stream_context_create($opts); | |
$xmlout = file_get_contents($url, false, $context); | |
file_put_contents('./result.xml', utf8_encode($xmlout)); | |
// output | |
echo utf8_encode($xmlout); | |
echo "\n"; | |
// print phpinfo(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment