- how to write a soap webservice with php,getting error:looks like we got no XML document
- php soap — SoapFault looks like we got no XML document
- 2 Answers 2
- PHP SoapClient — looks like we got no XML document
- SoapFault: looks like we got no XML document php error
- PHP SOAP call giving error of «looks like we got no XML document»
how to write a soap webservice with php,getting error:looks like we got no XML document
I am new to soap webservice. I have written a server and a client file with php language and I have faced this output: looks like we got no XML document soap_server.php :
configureWSDL("webservice"); $server->wsdl->schemaTargetNamespace = $namespace; //register a function that works on server $server->register('get_message'); // create the function function get_message($your_name) < if(!$your_name)< return new soap_fault('Client','','Put Your Name!'); //echo "no name" >$result = "Welcome to ".$your_name .". Thanks for Your First Web Service Using PHP with SOAP"; return $result; > //create HTTP listener $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server ->service($HTTP_RAW_POST_DATA); exit(); ?>
'Monotosh Roy'); $url='http://localhost/webservice/soap_server.php?wsdl'; // echo file_get_contents($url); //Create object that referer a web services try < $client = new SoapClient($url); //Call a function at server and send parameters too $response = $client->get_message($param); var_dump($response); echo "ok"; > catch(SoapFault $e)
nokSoapFault Object ( [message:protected] => looks like we got no XML document [string:Exception:private] => [code:protected] => 0 [file:protected] => C:\xampp\htdocs\webservice\soap_client.php [line:protected] => 14 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\xampp\htdocs\webservice\soap_client.php [line] => 14 [function] => __call [class] => SoapClient [type] => -> [args] => Array ( [0] => get_message [1] => Array ( [0] => Array ( [your_name] => Monotosh Roy ) ) ) ) [1] => Array ( [file] => C:\xampp\htdocs\webservice\soap_client.php [line] => 14 [function] => get_message [class] => SoapClient [type] => -> [args] => Array ( [0] => Array ( [your_name] => Monotosh Roy ) ) ) ) [previous:Exception:private] => [faultstring] => looks like we got no XML document [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/ )
This XML file does not appear to have any style information associated with it. The document tree is shown below.
php soap — SoapFault looks like we got no XML document
im a beginner to programming and following a tutorial on web services with php and soap using Apache2.4 web server. the tutorial uses soap without wsdl file Client:
"http://localhost/web-services/soap_service.php", "uri" => "http://localhost", "trace" => 1, ); try < $client = new SoapClient(null, $options); $students = $client->getStudentNames(); echo $students; > catch(SoapFault $ex) < echo var_dump($ex); >?>
"http://localhost"); $server = new SoapServer(null, $options); $server->setClass('Students'); $server->handle(); ?>
public function getStudentLastName() < $studentLN = array("Cooper", "Truman", "Johnson", "Briggs", "Hayward", "Horne", "Hurley", "Moran", "Hill", "Brennan", "Smith"); return $studentLN; >public function getStudentNames() < $studentNames = "Dale Cooper, Harry Truman, Shelly Johnson, " . "Bobby Briggs, Donna Hayward, Audrey Horne, " . "James Hurley, Lucy Moran, Tommy Hill, " . "Andy Brennan, John Smith"; return $studentNames; >> ?>
object(SoapFault)#2 (10) < ["message":protected]=>string(33) "looks like we got no XML document".
- extension=php_soap.dll in php.ini is uncommented (removed 😉
- php_soap.dll is found in php\ext
- all files are encoded in UTF-8 without BOM
- no trailing white spaces after or before the php marks (as far as i can tell)
the tutorial doesnt use a wsdl file, maybe i need to change more settings in php.ini?
what could be the problem.
@ND88 Hello, i am getting exactly same what you get, try with so many possibilities, can you pls help me to get out this issue, my code : justpaste.it/5qdr6 my output : snag.gy/HzRlEv.jpg
2 Answers 2
in soap_client.php, in catch, i added «echo $client->__getLastResponse();» which gave me the following output:
Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0 Warning: Cannot modify header information - headers already sent in Unknown on line 0 Dale Cooper, Harry Truman, Shelly Johnson, Bobby Briggs, Donna Hayward, Audrey Horne, James Hurley, Lucy Moran, Tommy Hill, Andy Brennan, John Smith
that last line is the string i passed to the client.
so what i tried was to uncomment «always_populate_raw_post_data = -1» in php.ini as the error suggested & restarted my Apache2.4 web-server and now it works, getting my string with no errors:
Dale Cooper, Harry Truman, Shelly Johnson, Bobby Briggs, Donna Hayward, Audrey Horne, James Hurley, Lucy Moran, Tommy Hill, Andy Brennan, John Smith
hope i helped someone with this, as i saw alot of unanswered questions about this error.
PHP SoapClient — looks like we got no XML document
I’m trying to access a .NET SOAP web service with PHP SoapClient. The thing is i get the following error:
--uuid:a2591cd7-7b7b-44bb-b93e-2750cc651efc+id=14 Content-ID: Content-Transfer-Encoding: 8bit Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml" http://tempuri.org/IRemoteRegForDeposit/GetHelloWorldResponse uudi:6e612bfb-6d03-9c4f-ea90-2af98bad1885 Ти ми изпрати числото:1 --uuid:a2591cd7-7b7b-44bb-b93e-2750cc651efc+id=14--
$client = new CustomSoapClient($wsdl, array( 'trace' => true, 'soap_version' => SOAP_1_2, 'exceptions' => 0, 'cache_wsdl' => 0, )); $data = new stdClass(); $data->dummyNumber = '3'; $response = $client->GetHelloWorld($data);
My CustomSoapClient extends the PHP’s SoapClient and uses this class to add ws-address stuff to the soap request.
class CustomSoapClient extends SoapClient < public function __doRequest($request, $location, $saction, $version, $one_way = NULL) < $dom = new DOMDocument(); $dom->loadXML($request); $wsa = new WSASoap($dom); $wsa->addAction($saction); $wsa->addTo($location); $wsa->addMessageID(); $wsa->addReplyTo(); $request = $wsa->saveXML(); return parent::__doRequest($request, $location, $saction, $version, $one_way); > >
SoapFault: looks like we got no XML document php error
Maybe you can try to figure out this problem? Thank in advance! Upd: There is no always_populate_raw_post_data in my php.ini file Upd 2: Added this bunch of code:
try < $response = $client->addcontract($docVar, $fVar); > catch(SoapFault $fault) < trigger_error("Error SOAP: (faultcode: faultcode>, faultstring: faultstring>)", E_USER_ERROR); >
This is what it returns: Fatal error: Error SOAP: (faultcode: Client, faultstring: looks like we got no XML document) Upd 3: Added this bunch of code in catch block
echo $client->__getLastRequest(); echo $client->__getLastResponse();
And added ‘exceptions’ => 1 for SoapClient. This is what it returns in __getLastResponse(): CException Undefined offset: 1 (/var/www/yii-1.0.9.r1396/framework/base/CApplication.php:608) (/var/www/yii-1.0.9.r1396/framework/web/services/CWebService.php:103) Upd 4: found some code, there are first lines:
/** * @param object post * @param object file * @return array * @soap */ public function addcontract($post,$file) < if(isset($post)) < //We need to add the designer,partner,job,customer,document $model= Partners::model()->findByPk($post->partner_id); if($model === null) < $model = new Partners(); $model->id=$post->partner_id; >
If I try to echo/var_dump something in this code, nothing happens. But if I break;, code do not go to my soap fault error. Upd Last: I posted answer for this in separate answer post
PHP SOAP call giving error of «looks like we got no XML document»
My environment is WAMP with PHP 5.3 I have all the always_populate_raw_post_data = On I have tried doing the trace as well and also ensured that there is no extra spaces there in the code before or after the ?php tag. I have also ensured that there is no extra space in the parameter sent but still its not resolved. I have tried almost all the fixes available over the internet that i could browse in the last 6 hours or so but no results yet. Please help me out. I am, getting this error:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\wamp\www\myweb\client.php:10 Stack trace: #0 C:\wamp\www\myweb\client.php(10): SoapClient->__soapCall(‘hello’, Array) #1 thrown in C:\wamp\www\myweb\client.php on line 10
configureWSDL('hello',trim($ns)); $server->wsdl->schemaTargetNamespace=trim($ns); $server->register('hello'); function hello($name) < if(!$name)< return new soap_fault('Client','','Put your name!'); >$result = "Hello, ".$name; return $result; > $server->service(file_get_contents('php://input')); exit(); ?>
trim($name)); $client = new SoapClient('http://localhost/myweb/server.php?wsdl'); $response = $client->__soapCall('hello',$param); if($client->fault) < echo "FAULT: Code: (".$client->faultcode."
"; echo "String: ".$client->faultstring; > else < print "here"; echo $response; >?>