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

99封情书 提交于 2019-12-30 03:09:08

问题


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


回答1:


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.




回答2:


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.




回答3:


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




回答4:


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



回答5:


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




回答6:


In my case, this error appeared when I included a script with blank lines after the "?>" label.

Delete these lines solves the problem




回答7:


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



回答8:


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.




回答9:


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




回答10:


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.




回答11:


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

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