12

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

Eedoh
  • 4,558
  • 8
  • 32
  • 57

11 Answers11

22

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.

Henrik Opel
  • 19,138
  • 1
  • 45
  • 61
8

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.

Ben
  • 47,286
  • 44
  • 159
  • 208
4

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

3

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());
}
PHPst
  • 14,868
  • 20
  • 85
  • 158
2

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"));
Tomasz Kowalczyk
  • 10,235
  • 6
  • 49
  • 64
2

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

Delete these lines solves the problem

Denwork
  • 21
  • 1
2

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

Tash Pemhiwa
  • 7,223
  • 4
  • 40
  • 44
1

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.

C Travel
  • 4,625
  • 7
  • 29
  • 45
Grazziani
  • 7
  • 1
1

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

Mostafa
  • 623
  • 1
  • 9
  • 18
  • 1
    Please note that always_populate_raw_post_data has been removed since PHP 7.0.0 – maxime_039 Oct 24 '16 at 13:30
  • My php version 7, i get the error like PHP Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document and SoapClient->__call('login', Array), can you pls help me to find out the error, thanks @Mostafa – Gem Nov 10 '18 at 12:22
1

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.

Peter O.
  • 28,965
  • 14
  • 72
  • 87
Shuvankar Sarkar
  • 389
  • 3
  • 11
  • 2
    While this may theoretically answer the question, it would be preferable (http://meta.stackexchange.com/q/8259) for you to edit the answer to include the essential parts of the solution, and provide the link for reference. – Peter O. Feb 10 '12 at 20:09
0

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.

Rafique Mohammed
  • 3,360
  • 2
  • 34
  • 42