<?php /** * Script to convert WSDL > PHP * * @author Jan Chren <dev.rindeal AT outlook.com> * @copyright Copyright (c) 2015, Jan Chren. All Rights Reserved. * @license Please view the LICENSE file * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once __DIR__ . '/../../../vendor/autoload.php'; define('OUTPUT_DIR', __DIR__ . '/Wsdl'); // old files MUST be deleted, before regenerating new ones $files = glob(OUTPUT_DIR . '/*'); foreach ($files as $file) { if (!is_dir($file)) { unlink($file); } } $generator = new \Wsdl2PhpGenerator\Generator(); $generator->generate(new \Wsdl2PhpGenerator\Config(['soapClientClass' => '\\Rindeal\\Allegro\\Client\\HttpClient\\SoapClientBase', 'inputFile' => 'https://webapi.allegro.pl/service.php?wsdl', 'outputDir' => OUTPUT_DIR, 'namespaceName' => 'Rindeal\\Allegro\\Client\\HttpClient\\Wsdl', 'constructorParamsDefaultToNull' => true]));
<?php require_once __DIR__ . '/vendor/autoload.php'; $wsdls = array(array('inputFile' => 'http://europe.ipx.com/api/services2/OnlineLookupApi10?wsdl', 'outputDir' => __DIR__ . '/src/OnlineLoockup', 'namespaceName' => 'Pmovil\\Ipx\\OnlineLoockup'), array('inputFile' => 'http://europe.ipx.com/api/services2/IdentificationApi31?wsdl', 'outputDir' => __DIR__ . '/src/Identification', 'namespaceName' => 'Pmovil\\Ipx\\Identification'), array('inputFile' => 'https://europe.ipx.com/api/services2/SmsApi52?wsdl', 'outputDir' => __DIR__ . '/src/Sms', 'namespaceName' => 'Pmovil\\Ipx\\Sms')); $generator = new \Wsdl2PhpGenerator\Generator(); foreach ($wsdls as $wsdl) { rrmdir($wsdl['outputDir']); $generator->generate(new \Wsdl2PhpGenerator\Config($wsdl)); unlink($wsdl['outputDir'] . '/autoload.php'); } function rrmdir($dir) { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { if ($object != "." && $object != "..") { if (filetype($dir . "/" . $object) == "dir") { rmdir($dir . "/" . $object); } else { unlink($dir . "/" . $object); } } } reset($objects); rmdir($dir); } }
<?php if ($argc !== 2) { echo "Error: Invalid number of arguments."; exit(1); } $caosVersion = $argv[1]; require_once __DIR__ . "/vendor/autoload.php"; if (file_exists(__DIR__ . '/src/main')) { $files = glob(__DIR__ . '/src/main/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); } // delete file } rmdir(__DIR__ . '/src/main'); } $generator = new \Wsdl2PhpGenerator\Generator(); $generator->generate(new \Wsdl2PhpGenerator\Config(array('inputFile' => 'http://esb.services.wisc.edu/esbv2/CHUB/WebService/chub-ws-' . $caosVersion . '/chub.wsdl', 'outputDir' => 'src/main/', 'namespaceName' => 'edu\\wisc\\services\\caos')));
} $wsdlxe = new simpleXMLElement($wsdlcontents); // Remove doc elements (causing issues with wsdl parser). $docels = $wsdlxe->xpath('//wsdl:documentation'); $docelsarr = []; foreach ($docels as $docel) { $docelsarr[] = $docel; } foreach ($docelsarr as $docel) { unset($docel[0]); } // Create local wsdl. $wsdlxe->asXML(__DIR__ . '/wsdl.xml'); $whitelist = ['Html', 'Apollo', 'UrlResponse', 'ServerConfiguration', 'Success']; $htmlels = $wsdlxe->xpath('//xs:complexType | //xs:element'); $soapclasses = ['SASDefaultAdapter']; foreach ($htmlels as $htmlel) { $name = '' . $htmlel->attributes()['name']; foreach ($whitelist as $witem) { if (stripos($name, $witem) !== false) { $soapclasses[] = $name; break; } } } $localwsdl = $CFG->wwwroot . '/mod/collaborate/wsdl.xml'; $generator = new \Wsdl2PhpGenerator\Generator(); $generator->generate(new \Wsdl2PhpGenerator\Config(array('inputFile' => $localwsdl, 'outputDir' => $outputdir, 'namespaceName' => 'mod_collaborate\\soap\\generated', 'classNames' => implode(',', $soapclasses)))); // Remove the autoloader, we don't need it! unlink($outputdir . '/autoload.php'); echo "\n" . 'Done' . "\n";