Format the SOAP request into a readable xml

  php, soap

So after trying and trying I simply can not get this to work, A SOAP request that must then simply format the xml nicely, but nothing seems to work, tried these methods

//1
//Dumps entire contents in a long string
// $client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
// $result = $client->getVehicleDetails('spwf87','hk8*9jd'); 
//  echo('<pre>'.$result.'</pre>');
//2
//Results in StartTag: invalid element name error
// $client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
// $result = $client->getVehicleDetails('spwf87','hk8*9jd');
// $content = simplexml_load_string( $result , "SimpleXMLElement" ,LIBXML_NOCDATA | LIBXML_NOBLANKS);
// $json = json_encode($content); 
// $content = json_decode($json,TRUE);
// var_dump($content); 
//3
//Copy into a file and try
// $client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
// $result = $client->getVehicleDetails('spwf87','hk8*9jd');

// $content = simplexml_load_string($result,'SimpleXMLElement',0,LIBXML_NOCDATA);
// $vehicle = $content->VEHICLEDETAILS->VEHICLE;
// var_dump($vehicle);

// $tempLocalPath = "data.xml";
// file_put_contents($tempLocalPath, $result);
// $xml = simplexml_load_file($tempLocalPath,'SimpleXMLElement',LIBXML_NOCDATA);

// if($xml === TRUE){
//     echo('Object');
// }
// else{
//     echo('No');
// }


//4
//content here is not an object just a string so error must be there
$client = new SoapClient('http://www.autobid.co.za/halfway/vehicledetails.php?wsdl');
$result = $client->getVehicleDetails('user','pass');
$content = simplexml_load_string($result,'SimpleXMLElement',LIBXML_NOCDATA);
$vehicle = $content->VEHICLEDETAILS->VEHICLE;

Temp password,username and link provided if anyone wants to try.
XML is valid according to xmlvalidation.com, I just need this to work whether someone knows how to do it with nusoap or just soap please assist. Apparently as it is an envelope thats where the simplexml_load_string falters but not sure on that

Source: Ask PHP

LEAVE A COMMENT