以下划线开头的 PHP SOAP 操作
使用 PHP SOAP 实现,我无法从 WDSL 调用方法(如果它们以下划线开头)。即:
$result = $server->_-testing_-getPrices(array('Receiver'=>'John'));
不起作用!
然而,
$result = $server->getPrices(array('Receiver'=>'John'));
按预期工作,但是,我请求的 SOAP 服务器没有此操作。 PHP 在第一个错误中吐出的错误是:
Notice: Undefined property: SoapClient::$_ in D:\SERVER\www\test123.php on line 4
Notice: Use of undefined constant testing_ - assumed 'testing_' in D:\SERVER\www\test123.php on line 4
Fatal error: Call to undefined function getPrices() in D:\SERVER\www\test123.php on line 4
这是恕我直言的一个错误,或者有人知道如何解决这个问题吗?
With PHPs SOAP implementation, I can't call methods from the WDSL, if they start with an underscore. I.e.:
$result = $server->_-testing_-getPrices(array('Receiver'=>'John'));
DOESN'T WORK!
However,
$result = $server->getPrices(array('Receiver'=>'John'));
WORKS AS EXPECTED, however, the SOAP server i'm requesting to doesn't have this operation. The error that PHP spits out with the FIRST ONE is:
Notice: Undefined property: SoapClient::$_ in D:\SERVER\www\test123.php on line 4
Notice: Use of undefined constant testing_ - assumed 'testing_' in D:\SERVER\www\test123.php on line 4
Fatal error: Call to undefined function getPrices() in D:\SERVER\www\test123.php on line 4
This is IMHO a bug, or does anyone know how to go around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
PHP 函数的名称中不能包含
-
:http ://www.php.net/manual/en/functions.user-define.php 。因此,您必须使用它来调用您的方法: http://www.php .net/manual/en/soapclient.soapcall.php
PHP's functions cannot contain
-
in their names: http://www.php.net/manual/en/functions.user-defined.php .So, you have to use this to call your method: http://www.php.net/manual/en/soapclient.soapcall.php
我很确定问题不是
_
(下痛)而是-
(减号) - 你的行被视为这样的数学运算:这显然不'这是没有意义的(在这里你可以看到为什么 php 尝试将
testing_
视为未定义的常量)。只需将您的函数从_-testing_-getPrices
重命名为_testing_getPrices
,它就会按预期工作。有关详细信息,请查看文档以获取有效信息函数名称(也适用于对象的方法):
i'm pretty sure the problem isn't the
_
(undersore) but the-
(minus) - your line is treated as mathematical operation like this:wich clearly doesn't make sense (and here you see why php tries to treat
testing_
as a constant wich isn't defined). just rename your function from_-testing_-getPrices
to_testing_getPrices
and it'll work as expected.for more information, please take a look at the documentation for valid function-names (wich applies to methods of objects, too):
你的问题不是下划线,而是它后面的破折号。 PHP 命名约定阻止它成为有效的方法名称,许多其他语言也是如此,服务的设计者在使用它们时犯了一个根本性错误。
PHP 应该基于此创建有效的函数名称,我猜它会将
-
转换为_
。尝试:
调用
__getFunctions()
方法可能表明您希望需要使用,尽管我不确定这是否返回 PHP 函数名称或由逐字服务。Your problem is not the underscore, it is the dash that follows it. PHP naming conventions prevent this from being a valid method name, this is also true of many other languages and the designer of the service has made a fundamental error in using them.
PHP should have created valid function names based on this, and I'm guessing it will have converted the
-
to_
.Try:
Calling the
__getFunctions()
method may show you want you need to use, although I'm not sure if this returns the PHP function names or the ones defined by the service verbatim.我知道我迟到了,但这可能会有所帮助&也工作
I know I am late but this might help & work too