我正在尝试调用我创建的Web服务,但服务器返回以下错误:
致命错误:未捕获的SoapFault异常:[WSDL] SOAP-ERROR:解析WSDL:无法从“http://www.savepoints.com.br/server.php?WSDL”加载:/ home / storage / a /中标记html第2行中数据的过早结束39 / 1c / site1365816459 / public_html / cliente.php:5堆栈跟踪:#0 /home/storage/a/39/1c/site1365816459/public_html/cliente.php(5):SoapClient-> SoapClient('{{3在第5行的/home/storage/a/39/1c/site1365816459/public_html/cliente.php中抛出了#1 {main}
这里我展示了两个脚本:
server.php(它是WSDL服务器)
<?php
require('classes/nusoap/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);
?>
cliente.php
<?php
require('classes/nusoap/nusoap.php');
$c = new SoapClient('http://www.savepoints.com.br/server.php?WSDL');
$stockprice = $c->call('getStockQuote',array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is ".$stockprice.".";
?>
答案 0 :(得分:11)
使用服务器NuSOAP
和客户PHP-SOAP
。
使用:
$c = new SoapClient('http://www.savepoints.com.br/server.php?wsdl');
而不是:
$c = new SoapClient('http://www.savepoints.com.br/server.php?WSDL');
我不知道为什么,但它对我有用。