网络服务错误

发布于 2024-08-30 07:54:19 字数 1511 浏览 4 评论 0原文

我是网络服务新手, 我已经创建了一个基本的股票市场网络服务,我已经成功地为其创建了服务器脚本并将其放置在我的服务器中,现在我还创建了一个客户端脚本并通过同一服务器访问它..它有效吗? boh文件可以从同一服务器访问吗?或者我必须将它们放置在不同的服务器中?如果是,那么 Y?如果否那么为什么我会得到空白页? 我正在使用 nusoap 库进行网络服务。

当我从本地计算机使用 cleint 脚本时,出现这些错误

“已弃用:分配返回值 new 的引用值是 已弃用 D:\wamp\www\pranav_test\nusoap\lib\nusoap.php 上线6506

致命错误:类“soapclient”不存在 发现于 D:\wamp\www\pranav_test\stockclient.php 第 3 行”

在服务器

<?php
function getStockQuote($symbol) {
mysql_connect('localhost','root','******');
mysql_select_db('pranav_demo');
$query = "SELECT stock_price FROM stockprices "
. "WHERE stock_symbol = '$symbol'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
return $row['stock_price'];
}
require('nusoap/lib/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);
?>

stockclient.php

<?php
require_once('nusoap/lib/nusoap.php');
$c = new soapclient('http://192.168.1.20/pranav_test/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>

stockserver.php请帮忙...

i am new to webservices,
I have created a basic stockmarket webservice, I have successfully created the server script for it and placed it in my server, Now I also creted a clent script and accessed it hruogh the same server.. Is it valid ? can boh files be accesed from the same server? or do I have to place them in different servers? If yes Then Y? If No then why do i get the blank page?
I am using nusoap library for webservice.

When I use my cleint script from my local machine I get these errors

"Deprecated: Assigning the return
value of new by reference is
deprecated in
D:\wamp\www\pranav_test\nusoap\lib\nusoap.php
on line 6506

Fatal error: Class 'soapclient' not
found in
D:\wamp\www\pranav_test\stockclient.php
on line 3"

stockserver.php at server

<?php
function getStockQuote($symbol) {
mysql_connect('localhost','root','******');
mysql_select_db('pranav_demo');
$query = "SELECT stock_price FROM stockprices "
. "WHERE stock_symbol = '$symbol'";
$result = mysql_query($query);
$row = mysql_fetch_assoc($result);
return $row['stock_price'];
}
require('nusoap/lib/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);
?>

stockclient.php

<?php
require_once('nusoap/lib/nusoap.php');
$c = new soapclient('http://192.168.1.20/pranav_test/stockserver.php');
$stockprice = $c->call('getStockQuote',
array('symbol' => 'ABC'));
echo "The stock price for 'ABC' is $stockprice.";
?>

please help...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

混吃等死 2024-09-06 07:54:20

请贴一段源代码。

是的,您可以从也位于同一服务器上的客户端访问您的网络服务。

对于测试 Web 服务,我建议使用 SoapUI,它适用于所有平台。

我建议使用 php 的内置肥皂扩展,然后使用 nusoap,它是一个相当旧的库。

Please post a piece of source code.

Yes you can access your webservice from a client which is also located on the same server.

For testing webservices I recommend SoapUI, which is available for all platforms.

I recommend to use the build in soap extension of php then nusoap, it's an rather old library.

荭秂 2024-09-06 07:54:20

我对 PHP 真的很陌生,但在使用 nusoap 时发现了同样的错误。
我的理解是,在 php 5 中,您不能使用引用(使用 & 运算符)来分配新对象的返回值,所以简单地...删除它:D...
我这样做了,它成功了。

I'm really very new to PHP but i found the same error when i was working with nusoap.
what i understood that in php 5 you can't assign the return value of new object using referencing ( using the & operator) so simply... Remove it :D...
I did that i it worked.

2024-09-06 07:54:20

使用新的 php 版本 5x 启动 Soap 客户端 - PHP5 Soap 库和 NuSoap 库存在冲突。

下载 PHP 版本 5.3.x 的最新 nusoap.php 库(您可以从 sourceforge 获取)

将客户端中的以下类调用更改为:

 $c = new soapclient

to

  $c = new nusoap_client

您可能还需要将以下内容添加到 PHP ini 文件中。

[nusoap_deprecated]
; Turn off deprecated messages on rendered pages
error_reporting = E_ALL & ~E_DEPRECATED

to initiate a soap client with the new php version 5x - there is a conflict with the PHP5 soap library and the NuSoap library.

download the latest nusoap.php library for PHP version 5.3.x (you can get this from sourceforge)

Change the following class call in your client to:

 $c = new soapclient

to

  $c = new nusoap_client

You may also want to add the following to your PHP ini file.

[nusoap_deprecated]
; Turn off deprecated messages on rendered pages
error_reporting = E_ALL & ~E_DEPRECATED
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文