note 83932 deleted from soapclient.soapclient by cmb

From: Date: Sun, 17 Nov 2019 09:02:17 +0000
Subject: note 83932 deleted from soapclient.soapclient by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213110@lists.php.net to get a copy of this message
Note Submitter: naugtur at gmail dot com ---- SoapFault exception: [Client] looks like we got no XML document in <document> has been already mentioned to occur when your server outputs something before <?xml ... > tag. For all those having problems with that, and no access to the server code: This is how to make a proxy that would clean responses for You <?php /** * Simple class taken from a note by James Ellis [in __doRequest() page of manual] */ class Proxy_Client extends SoapClient { protected $cacheDocument = ""; public function __construct($wsdl, $options) { parent::__construct($wsdl, $options); } /** * SetCacheDocument() sets the previously cached document contents */ public function SetCacheDocument($document) { $this->cacheDocument = $document; } /** * __doRequest() overrides the standard SoapClient to handle a local request */ public function __doRequest() { return $this->cacheDocument; } } //put this code in your function or wherever You have all required variables set $client = new SoapClient($wsdl_url,$settings_array); $void=$client->$method($params); //call this to get response from server $response_string=$client->__getLastResponse(); //this part removes stuff $start=strpos($response_string,'<?xml'); $end=strrpos($response_string,'>'); $response_string=substr($response_string,$start,$end-$start+1); //get your proxy prepared $proxy = new Proxy_Client($wsdl_url,$settings_array); //and fill it with the server's response $proxy->SetCacheDocument($response_string); $and_finally_the_result_is=$proxy->$method($params); print_r($and_finally_the_result_is); //this allows You to see what's there ?> $method is the method's name eg. $method='getVersion'; $params - typical params for a soap method

« previous php.notes (#213110) next »