- var_dump: documentation ( source)
- simplexml_load_string: documentation ( source)
- htmlspecialchars: documentation ( source)
- json_encode: documentation ( source)
<?php
$client = new SoapClient("http://www.scottnichol.com/samples/hellowsdl2.php?wsdl&debug=0",array(
"trace"=>1,
"exceptions"=>0)
);
//libxml_clear_errors();
//libxml_use_internal_errors(true);
//$req->firstname="Scott";
//$req->age="50";
//$req->gender="M";
//$parameters->person = $req;
$obj = $client->hello(array('firstname'=>"Scott",'age'=>"50",'gender'=>"M"));
//$xml = simplexml_load_string($client->__getLastResponse());
$xml = simplexml_load_string($client->__getLastRequest());
//$xml = new SimplexmlElement($client->__getLastResponse(), TRUE);
$json= json_encode($xml);
//$json= json_encode($client->__getLastResponse());
print "<pre>\n";
print "<br />\n Request : ".htmlspecialchars($client->__getLastRequest());
print "<br />\n Response: ".htmlspecialchars($client->__getLastResponse());
print "<br />\n xml: ".$xml;
print "<br />\n JSON: ".$json;
print "</pre>";
/*if (!$xml) {
$errors = libxml_get_errors();
foreach ($errors as $error) {
echo display_xml_error($error, $xml);
}
}*/
var_dump($xml);
echo "<BR>";
var_dump ($json);
?>