<?php
ini_set
('soap.wsdl_cache_ttl', 3600);
$url = filter_input(INPUT_GET, 'url', FILTER_VALIDATE_URL, FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED);
if (!
is_null($url)) {
    if (!
$url || !preg_match('|^https?://|', $url)) {
        die(
'Invalid URL.');
    }

    
try {
        
$client = @new SoapClient($url,
                                  array(
'trace' => true,
                                        
'encoding' => 'iso-8859-1',
                                        
'exceptions' => true));
    }
catch (SoapFault $e) {
        die(
$e->getMessage());
    }

    
$label = '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
    
$types = '(boolean|date|double|int|long|string|anyType)';
    
$func_regexp = '/\b(?<!\$)(' . $label . ')(?!\()\b/';
    
$func_replace = '<a href="#$1">$1</a>';
    
$type_regexp = array('/struct (' . $label . ') {/',
                         
'/^ ' . $types . '/m',
                         
'/^' . $types . ' (' . $label . ')$/m',
                         
'/^ (' . $label . ')(.*)$/m',
                         
'/\0/',
                         
'/^ /m',
                         
'/\n/');
    
$type_replace = array('struct <a name="$1">$1</a> {',
                          
" \0\$1",
                          
"\$1 <a name=\"$2\">$2</a>",
                          
' <a href="#$1">$1</a>$2',
                          
'',
                          
'&nbsp;&nbsp;&nbsp;&nbsp;',
                          
"<br />\n");
}
?>
<html>
<head>
<title>WSDL Browser</title>
</head>
<body>

<h1>WSDL Browser</h1>

<p>WSDL resources are cached for <?php echo ini_get('soap.wsdl_cache_ttl') / 60 ?> minutes.</p>

<h2>Enter WSDL url:</h2>
<form action="wsdl_browser.php">
<input name="url" type="text" size="100" value="<?php echo htmlspecialchars($_GET['url']) ?>" /><br />
<input type="submit" value="Browse">
</form>

<?php if (!empty($_GET['url'])): ?>
<h2>Functions</h2>
<?php foreach ($client->__getFunctions() as $func): ?>
<p><?php echo preg_replace($func_regexp, $func_replace, $func) ?></p>
<?php endforeach; ?>

<h2>Types</h2>
<?php foreach ($client->__getTypes() as $type): ?>
<p>
<?php echo preg_replace($type_regexp, $type_replace, $type) ?>
</p>
<?php endforeach; endif; ?>

</body>
</html>