/**
* Description of mySC
*
* @author houssem.blibech
*/
class mySC {
private $_objSC;
private $_wsdl;
/**
*
* @param type $wsdl
*/
function __construct($wsdl) {
try {
$options = array("trace" => 1, "exceptions" => 1);
$this->_wsdl = $wsdl;
$this->_objSC = new SoapClient($this->_wsdl, $options);
watchdog('WS', 'create a new SoapClient object for [%name] service.', array('%name' => $wsdl));
} catch (Exception $e) {
echo '<pre>';
echo 'Exception : ' . $e->__toString() . '<br/>';
echo '</pre>';
watchdog('WS', 'Cannot create a new SoapClient object for [%name] service.', array('%name' => $wsdl));
}
}
/**
* Execute web service methode
* @param type $method
* @param type $params
* @return type
*/
public function RequestSW($method, $params = array()) {
try {
$value = $this->_objSC->__soapCall($method, array($params));
watchdog('WS', 'Call the [%name] method with this parameters [%params].', array('%name' => $method, '%params' => implode('#', $params)));
$this->LogMyWS($this->_objSC);
} catch (Exception $e) {
echo '<pre>';
echo 'Exception : ' . $e->__toString() . '<br/>';
echo '</pre>';
watchdog('WS', 'Cannot call the [%name] method with this parameters [%params].', array('%name' => $method, '%params' => var_dump($params)));
$this->LogMyWS($this->_objSC);
}
return $value;
}
/**
*
*/
public function GetFunctions(){
$functions = $this->_objSC->__getFunctions();
echo "<pre>";
echo "Liste des fonctions : <br />";
echo var_dump($functions);
echo "</pre>";
}
/**
* Log des Request / Response des WS
*
* @param Object $SOAPObject
*/
private function LogMyWS($SOAPObject){
// Log WS
$output = "RequestHeaders : ";
$output .= $SOAPObject->__getLastRequestHeaders();
$output .= "<br />";
$output .= "\n";
$output .= "Request : ";
$output .= $SOAPObject->__getLastRequest();
$output .= "<br />";
$output .= "\n";
$output .= "ResponseHeaders : ";
$output .= $SOAPObject->__getLastResponseHeaders();
$output .= "<br />";
$output .= "\n";
$output .= "Response : ";
$output .= $SOAPObject->__getLastResponse();
watchdog('WS', '%log', array('%log' => $output));
}
}