How to get rid of “Uncaught SoapFault exception: [Client] looks like we got no XML document in…” error

╄→尐↘猪︶ㄣ 提交于 2019-11-30 08:57:38

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 echoing 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

Ratsitobaina Friedrich

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"));
Shuvankar Sarkar

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()

Grazziani

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!