Skip to content

Instantly share code, notes, and snippets.

@itsliamjones
Created June 12, 2017 08:57
Show Gist options
  • Save itsliamjones/95091b74e976d92845c2f55abe34b7c2 to your computer and use it in GitHub Desktop.
Save itsliamjones/95091b74e976d92845c2f55abe34b7c2 to your computer and use it in GitHub Desktop.
Super simple class to pretty-print a WSDL's methods and types as HTML
<?php
/**
* Super simple class to pretty-print a WSDL's methods and types as HTML
*/
class WSDLSoapClientDebugger
{
/**
* Instance of SoapClient
*
* @var SoapClient
*/
private $client;
/**
* Class constructor
*
* @param SoapClient $client
*/
public function __construct(SoapClient $client)
{
$this->client = $client;
}
/**
* Return function list as defined by Barclay Partner Finances WSDL
*
* @return string
*/
public function functions()
{
$str = "";
foreach ($this->client->__getFunctions() as $type) {
$str .= preg_replace(
[
'/(\w+) ([a-zA-Z0-9]+)/',
'/\n /'
],
[
'<font color="green">${1}</font> <font color="blue">${2}</font>',
"\n\t"
],
$type
);
$str .= "\n\n";
}
return "<pre><h2>Functions:</h2>{$str}</pre>";
}
/**
* Return client types as defined by Barclay Partner Finances WSDL
*
* @return string
*/
public function types()
{
$str = "";
foreach ($this->client->__getTypes() as $type) {
$str .= preg_replace(
[
'/(\w+) ([a-zA-Z0-9]+)/',
'/\n /'
],
[
'<font color="green">${1}</font> <font color="blue">${2}</font>',
"\n\t"
],
$type
);
$str .= "\n\n";
}
return "<pre><h2>Types:</h2>{$str}</pre>";
}
}
$debugger = new WSDLSoapClientDebugger(
new SoapClient(
'{path/to/wsdl}',
[
'trace' => true
]
)
);
echo $debugger->functions();
echo $debugger->types();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment