/** * *@param String $xml - string of XML content *@param Boolean $returnRaw - if set to true, the raw return object will be returned... *@return XML Object / Object **/ public function runXMLCommand($xml, $returnRaw = false) { $success = false; $resultObject = null; $client = null; try { $client = new SoapClient(self::$url, self::$connection_credentials); } catch (SoapFault $fault) { $client = null; user_error("could not create soap client", E_USER_NOTICE); } if ($client) { $array = array_merge(self::$db_credentials, array("sParams" => $xml)); try { $resultObject = $client->gbCallCustomerBusinessLinkMethod($array); $success = true; } catch (SoapFault $fault) { if ($this->debug) { echo '<p style="color: red">Error Message:</p>'; echo $fault->getMessage(); } else { user_error("my crash", E_USER_WARNING); } } if ($this->debug) { echo '<hr /><hr /><hr /><p style="color: green">Request : </p><xmp>' . $this->replacer($client->__getLastRequest()) . '</xmp>'; echo '<h3>Results</h3>'; echo "<xmp>"; print_r($resultObject); echo "</xmp>"; } if ($success) { if ($returnRaw) { return $resultObject; } if ($resultObject->gbCallCustomerBusinessLinkMethodResult) { $xml = $resultObject->sResult; $xmlObj = simplexml_load_string($xml); return $xmlObj; //alternative way... if (!self::$xml_object) { self::$xml_object = new XML(); } return self::$xml_object->parse($xml, true); } else { //user_error("unexpected result", E_USER_WARNING); } } } return null; }