<?php
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
class V3Soap extends SoapClient {
private $timeout;
public function __construct($wsdl, $endpoint) {
try {
throw new Exception('SOAP-ERROR: Parsing WSDL: Could not load from WSDL');
}
parent
::__construct
($wsdl, array('location' => $endpoint, 'trace' => 1));
} catch (Exception $e) {
throw new Exception('SOAP-ERROR: Parsing WSDL: Could not load from WSDL');
}
}
public function __setTimeout($timeout) {
throw new Exception("Invalid timeout value");
}
$this->timeout = $timeout;
}
public function __doRequest($request, $location, $action, $version, $one_way = FALSE) {
if (!$this->timeout) {
// Call via parent because we require no timeout
$response = parent::__doRequest($request, $location, $action, $version, $one_way);
} else { // Call via Curl and use the timeout
}
}
//Return?
if (!$one_way) {
return ($response);
}
}
// public function __doRequest($request, $location, $action, $version) {
// $dom = new DOMDocument('1.0');
//
// try {
//
// //loads the SOAP request to the Document
// $dom->loadXML($request);
// } catch (DOMException $e) {
// die('Parse error with code ' . $e->code);
// }
//
// //create a XPath object to query the request
// $path = new DOMXPath($dom);
//
// //search for a node
// $nodesToFix = $path->query('//SOAP-ENV:Envelope/SOAP-ENV:Body/path/to/node');
//
// //check if nodes are ok
// $this->checkNodes($path, $nodesToFix);
//
// //save the modified SOAP request
// $request = $dom->saveXML();
// //doRequest
// return parent::__doRequest($request, $location, $action, $version);
// }
public function checkNodes(DOMXPath $path, DOMNodeList $nodes) {
//iterate through the node list
for ($i = 0; $i < $nodes->length; $i++) {
$aNode = $nodes->item($i);
//just an example
if ($node->nodeValue == null) {
//do something. For instance, let's remove it.
$node->parentNode->removeChild($node);
}
}
}
}
?>