我正在尝试创建一个Web服务,但在此之前,我试图找到一个我在互联网上找到的简单示例,但我不断收到以下错误:
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
我正在使用nusoap v1.94
我的Web服务代码如下所示:
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);
我知道一个原因是在你的服务器脚本中的php标签之前或之后有空格,但事实并非如此.这让我疯了几个小时!任何帮助将非常感激.
解决方法:
字节顺序标记(BOM)与php标记之前的空格具有相同的效果.
Here您找到一个用于检测和删除BOM的PHP代码段.务必将编辑器配置为不再插入BOM.
标签:nusoap,php,soap
来源: https://codeday.me/bug/20191007/1869225.html