You can use this method to correct the SOAP request before sending it, if necessary. You can use the DOM API to accomplish that.
<?php
public ExtendedClient extends SoapClient {
function __construct($wsdl, $options = null) {
parent::__construct($wsdl, $options);
}
function __doRequest($request, $location, $action, $version) {
$dom = new DOMDocument('1.0');
try {
$dom->loadXML($request);
} catch (DOMException $e) {
die('Parse error with code ' . $e->code);
}
$path = new DOMXPath($dom);
$nodesToFix = $path->query('//SOAP-ENV:Envelope/SOAP-ENV:Body/path/to/node');
$this->checkNodes($path, $nodesToFix);
$request = $dom->saveXML();
return parent::__doRequest($request, $location, $action, $version);
}
function checkNodes(DOMXPath $path, DOMNodeList $nodes) {
for ($i = 0; $ < $nodes->length; $i++) {
$aNode = $nodes->item($i);
if ($node->nodeValue == null) {
$node->parentNode->removeChild($node);
}
}
}
}
?>
This gives the developer the chance to solve interoperability problems with a web service.