Simple WSDL browser

Copied this page from web site.

I wasn't able to find a simple and free (as in free beer) WSDL browser. Searching with Google turned into hundreds of results, but these were either .NET applications (and I didn't play with Mono yet and need this for my Linux machine), or commercial, or no longer existant. So I wrote my own one in 40 lines (including HTML and pretty formatting).

My requirements were pretty low: I wanted to pass a WSDL url to it and get back an interface that shows all methods and complex types, cross referenced. This is what I've come up with. It's incomplete (I don't filter out all XSD types yet), has pretty unreadable regular expressions, and lacks any eye candy. But it works for my purpose, and perhaps anybody else's.

This server isn't running PHP 5 unfortunately, which is required, so I can't provide a live demo.

$client = new SoapClient($url,
'trace' => true,
'encoding' => 'iso-8859-1'));

$label '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*';
$func_regexp '/\b(?<!\$)(' $label ')(?!\()\b/';
$func_replace '<a href="#$1">$1</a>';
$type_regexp = array('/struct (' $label ') {/',
'/^ (boolean|int|string)/m',
'/^ (' $label ')(.*)$/m',
'/^ /m',
$type_replace = array('struct <a name="$1">$1</a> {',
" \0\$1",
' <a href="#$1">$1</a>$2',
"<br />\n")

<?php foreach ($client->__getFunctions() as $func): ?>
<p><?php echo preg_replace($func_regexp$func_replace$func?></p>
<?php endforeach; ?>

<?php foreach ($client->__getTypes() as $type): ?>
<?php echo preg_replace($type_regexp$type_replace$type?>
<?php endforeach; ?>