note 83932 added to function.soap-soapclient-construct

From: Date: Thu, 19 Jun 2008 13:48:03 +0000
Subject: note 83932 added to function.soap-soapclient-construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-140582@lists.php.net to get a copy of this message
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 ---- Server IP: 82.160.94.10 Probable Submitter: 85.221.229.144 ---- Manual Page -- http://www.php.net/manual/en/function.soap-soapclient-construct.php Edit -- https://master.php.net/note/edit/83932 Del: integrated -- https://master.php.net/note/delete/83932/integrated Del: useless -- https://master.php.net/note/delete/83932/useless Del: bad code -- https://master.php.net/note/delete/83932/bad+code Del: spam -- https://master.php.net/note/delete/83932/spam Del: non-english -- https://master.php.net/note/delete/83932/non-english Del: in docs -- https://master.php.net/note/delete/83932/in+docs Del: other reasons-- https://master.php.net/note/delete/83932 Reject -- https://master.php.net/note/reject/83932 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#140582) next »