Skip to content

Instantly share code, notes, and snippets.

@felipecwb
Last active July 4, 2018 02:43
Show Gist options
  • Save felipecwb/4e63f35bafb61cd509ae to your computer and use it in GitHub Desktop.
Save felipecwb/4e63f35bafb61cd509ae to your computer and use it in GitHub Desktop.
Soap Server information description.
<?php
$wsdl = isset($_GET['wsdl']) ? $_GET['wsdl'] : 'http://localhost/?wsdl';
try {
// Set the WSDL
$soap = new SoapClient($wsdl);
} catch (SoapFault $e) {
die('Unable to read the WSDL: ' . $e->getMessage());
}
// colors at your choice
$colors = array(
'scalarType' => '#0a0',
'classType' => '#00a',
'var' => '#950',
'text' => '#000',
'background' => '#fff'
);
// regex patterns and htmlText to translate
$pattern = new stdClass();
// functions
$pattern->func = new stdClass();
$pattern->func->regex = '/(\S+) (\S+)\((?(?=\S+ \$\S+)(\S+\s)(\$\S+)|)\)/';
$pattern->func->htmlText = '<font color="' . $colors['classType'] . '">${1}</font> ${2}'
. '(<font color="' . $colors['classType'] . '">${3}</font>'
. '<font color="' . $colors['var'] . '">${4}</font>)';
// types
$pattern->type = new stdClass();
$pattern->type->regex = array(
'/(\S+) (\S+);/',
'/(\S+) \{/',
'/\n /',
'/(struct|integer|int|long|string|boolean|bool|float|decimal)/'
);
$pattern->type->htmlText = array(
'<font color="' . $colors['classType'] . '">${1}</font> ${2};',
'<font color="' . $colors['classType'] . '">${1}</font> {',
PHP_EOL . " ",
'<font color="' . $colors['scalarType'] . '"><b>${1}</b></font>'
);
echo '<pre style="padding: 20px; '
. "background: {$colors['background']}; "
. "color: {$colors['text']}\">" . PHP_EOL;
echo "<h3>WSDL: <a href=\"{$wsdl}\" target=\"_blank\">{$wsdl}</a></h3>";
echo "<hr><h2>Functions:</h2>";
// parse functions
$functions = $soap->__getFunctions();
foreach ($functions as $function) {
$function = preg_replace(
$pattern->func->regex,
$pattern->func->htmlText,
$function
);
echo $function;
echo PHP_EOL;
}
echo PHP_EOL . '<hr>';
echo '<h2>Types:</h2>';
// parse types
$types = $soap->__getTypes();
foreach ($types as $type) {
$type = preg_replace(
$pattern->type->regex,
$pattern->type->htmlText,
$type
);
echo $type;
echo PHP_EOL . PHP_EOL;
}
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment