将 SOAP 与 php 结合使用,利用 nusoap 库
您好,我尝试运行教程的代码,但出现错误。 肥皂服务器代码如下。
<?php
function getStockQuote($symbol) {
return "Hi jerkwad ".$symbol;
}
require('lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('StockServer', 'urn:stockquote');
$server->register("getStockQuote",
array('symbol' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:stockquote',
'urn:stockquote#getStockQuote');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
Soap 客户端是这样的。
<?php
require_once('lib/nusoap.php');
$c = new soapclient('http://localhost/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>
这是我得到的错误。
警告:SoapClient::SoapClient(http://localhost/stockserver.php) [soapclient.soapclient]: 无法打开流:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败因为连接的主机未能响应。在 C:\wamp\www\SoapClient.php 第 4 行
警告:SoapClient::SoapClient() [soapclient.soapclient]:I/O 警告:无法加载外部实体“http://localhost/stockserver.php”第 4 行上的 C:\wamp\www\SoapClient.php
致命错误:第 13 行上的 C:\wamp\www\SoapClient.php 超出了最大执行时间 30 秒
我确信我正在做一些愚蠢的事情,我是一个十足的肥皂菜鸟。
Hi i tried to run the code of a tutorial but i am getting an error.
The soap server code is the following.
<?php
function getStockQuote($symbol) {
return "Hi jerkwad ".$symbol;
}
require('lib/nusoap.php');
$server = new soap_server();
$server->configureWSDL('StockServer', 'urn:stockquote');
$server->register("getStockQuote",
array('symbol' => 'xsd:string'),
array('return' => 'xsd:string'),
'urn:stockquote',
'urn:stockquote#getStockQuote');
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA)
? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
The Soap client is this.
<?php
require_once('lib/nusoap.php');
$c = new soapclient('http://localhost/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>
and this is the error i get.
Warning: SoapClient::SoapClient(http://localhost/stockserver.php) [soapclient.soapclient]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\wamp\www\SoapClient.php on line 4
Warning: SoapClient::SoapClient() [soapclient.soapclient]: I/O warning : failed to load external entity "http://localhost/stockserver.php" in C:\wamp\www\SoapClient.php on line 4
Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\SoapClient.php on line 13
I am sure i am doing something stupid, i am a total soap noob.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码在我自己的服务器上运行得很好。它与 nusoap 无关,因为 NuSOAP 声称没有扩展要求。
您应该检查基本配置点:
localhost< /code> 通过
127.0.0.1
Your code is working just fine on my own server. It is not nusoap related, since NuSOAP claims to have no extensions requirements.
You should check basic configuration points :
localhost
by127.0.0.1