I'm trying to develop business logic for a dynamic site using nusoap on server side (because I need wsdls, and PHP SOAP extension can't generate wsdls), and PHP SOAP extenstion on client side.
However, I can't get even login and getRole functions right. When i try to invoke client, I get following message
Uncaught SoapFault exception: [Client] looks like we got no XML document in [some paths]...
Wsdl does exist on server side, and client does read it (when I put wrong url for wsdl, I get an error).
Can anyone help??
It looks like your client receives some invalid XML - either the WSDL itself or the response returned by the server. Try to invoke the client with the trace
option set to TRUE and check the actual XML send/received via the __getLastRequest()
and __getLastResponse()
methods.
I just had a similar problem; turns out my service was echo
ing out some debug data. I removed all of the echo
lines and it worked fine.
I have the same problem, and I solved with this:
The server SOAP file in php has encode utf8 with BOM, causing apache send back the BOM mark (3 bytes) before the xml response.
Encode your php file soap server with utf8 WITH OUT BOM mark.
Ignacio Gutierrez Torrero
Don't forget to use try/catch block:
try {
var_dump($client->foo());
} catch (Exception $e) {
echo($client->__getLastResponse());
echo PHP_EOL;
echo($client->__getLastRequest());
}
Chances are you have some trailing whitespace at the end of your SOAPServer class. Please have a look at the following blog post for more information: http://arnekroeger.blogspot.com/2011/02/php-soap-error-looks-like-we-got-no-xml.html
In my case, this error appeared when I included a script with blank lines after the "?>" label.
Delete these lines solves the problem
Just use trim() for you args.
$objectRequette = trim($_POST['Requette']) ;
$client = new SoapClient(null, array(
'location' => 'http://your.php',
'uri'=>'your option',
));
$result = $client->__soapCall('Misyka', array("$objectRequettea"));
Some times a BOM can generate some extra characters which creates this type of problem.
To detect if there is any UTF BOM see this link.
I have same problem.my problem solved by set always_populate_raw_post_data
to -1
on php.ini.
I find out this by adding "trace"=>1,"exceptions"=>1 on options and use try catch
and get __getLastRequest()
and __getLastResponse()
I have a way to solve this problem. This isn't a pretty solution, but it works...
How I can't do any change in my mantis server, I decided do this...
First I have to silence SoapFault:
try {
$client = new SoapClient('http://www.mymantisaddress.com/api/soap/mantisconnect.php?wsdl', array('trace'=> 1, 'exceptions' => 0));
$result = $client->__soapCall($function_name, $args);
} catch (SoapFault $e) {
//$result = array(
// 'erro' => $e->faultstring
//);
}
Second, I've noted that there was this three trailing control char in begin of my string, so I've removed it:
$str = substr($client->__getLastResponse(), 3) . "pe>";
print $str;
Third, I've to put "pe>" in the end of my string, cause it was incomplete.
The below may be the problem for some users. because i have been through it.
For latest nuSoap version, the below will solve your problem :
FIND the below code in nusoap.php
$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
in line 6132 or something around this no.
AND COMMENT IT
// $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
Since it just for debug purpose. so not to worry about any functionality issues.
来源:https://stackoverflow.com/questions/2540438/how-to-get-rid-of-uncaught-soapfault-exception-client-looks-like-we-got-no-x