将 SOAP 与 php 结合使用,利用 nusoap 库

发布于 2024-12-22 00:42:44 字数 1369 浏览 0 评论 0原文

您好,我尝试运行教程的代码,但出现错误。 肥皂服务器代码如下。

<?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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

埖埖迣鎅 2024-12-29 00:42:44

你的代码在我自己的服务器上运行得很好。它与 nusoap 无关,因为 NuSOAP 声称没有扩展要求。

您应该检查基本配置点:

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 :

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文