note 57995 added to function.soap-soapclient-dorequest

From: Date: Thu, 20 Oct 2005 23:32:50 +0000
Subject: note 57995 added to function.soap-soapclient-dorequest
Groups: php.notes 
Request: Send a blank email to php-notes+get-97331@lists.php.net to get a copy of this message
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 { //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); } function checkNodes(DOMXPath $path, DOMNodeList $nodes) { //iterate through the node list for ($i = 0; $ < $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); } } } } ?> This gives the developer the chance to solve interoperability problems with a web service. ---- Manual Page -- http://www.php.net/manual/en/function.soap-soapclient-dorequest.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+57995 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57995&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+57995&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#97331) next »