Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SOAP: looks like we got no XML document

Tags:

php

soap

nusoap

I'm trying to create a web service but before I do I'm trying to get a simple example that I found on the internet to work first but I keep getting the following error:

Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML document in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php:20 Stack trace: #0 [internal function]: SoapClient->__call('getStockQuote', Array) #1 C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php(20): SoapClient->getStockQuote(Array) #2 {main} thrown in C:\Documents and Settings\geoff\My Documents\Websites\jquery\index.php on line 20

I am using nusoap v1.94

My web service code looks like this:

function getStockQuote($symbol) {
$price = '1.23';
return $price;
}

require('nusoap.php');

$server = new soap_server();

$server->configureWSDL('stockserver', 'urn:stockquote');

$server->register("getStockQuote",
            array('symbol' => 'xsd:string'),
            array('return' => 'xsd:decimal'),
            'urn:stockquote',
            'urn:stockquote#getStockQuote');

$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
                  ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

I know one cause is to have whitespace before or after your php tags in your server script but thats not the case. It has been driving me mad for hours! Any help would be much appreciated.

like image 830
geoffs3310 Avatar asked Nov 30 '10 12:11

geoffs3310


2 Answers

A byte order mark (BOM) would have the same effect as whitespace before the php tags. Here you find a PHP snippet to detect and remove a BOM. Be sure to configure you editor to not insert the BOM again.

like image 114
rik Avatar answered Sep 21 '22 19:09

rik


Pretty late but adding my fix to benefit of others. I have got similar error when I changed my Apache server from 2.2 to 2.4 and PHP 5.4.10 to 5.6.18 on windows. Client app used php 5.6.1. To fix the problem, I have done the following:

  1. Passed SOAP version parameter to SoapClient:

    'soap_version' => SOAP_1_1

  2. On the server php.ini configuration file I have added:

    always_populate_raw_post_data = -1

like image 39
mvsagar Avatar answered Sep 18 '22 19:09

mvsagar