php 未捕获的 SoapFault 异常:[Client] 函数不是此服务的有效方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8354785/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Uncaught SoapFault exception: [Client] Function is not a valid method for this service
提问by ravikiran reddy
When I try to access a function in wsdl with some data(using soap client in php) I am getting the following error.
当我尝试使用一些数据访问 wsdl 中的函数时(在 php 中使用 soap 客户端),我收到以下错误。
Uncaught SoapFault exception: [Client] Function function_nameis not a valid method for this service
Any help?
有什么帮助吗?
回答by biphobe
If you want to execute a function that SOAP can not find - it is possible that PHP cached the wsdl file.
如果要执行 SOAP 找不到的函数 - PHP 可能缓存了 wsdl 文件。
Add this:
添加这个:
ini_set("soap.wsdl_cache_enabled", "0");
to disable the caching.
禁用缓存。
回答by spiritoo
Two possible solutions :
两种可能的解决方案:
- try to see if the function really exists with the snippet of code there : PHP SoapClient request: not a valid method for this service
- Also, once you have displayed the list of available function calls, take care that if your WSDL is generated by a Java SOAP server, you might have several functions named "service" (or with the same name). Only the first one will be recognized and used by the PHP SOAP client. You need to manually rename all your in the WSDL !
- 尝试使用代码片段查看该函数是否真的存在:PHP SoapClient request: not a valid method for this service
- 此外,一旦您显示了可用函数调用的列表,请注意,如果您的 WSDL 是由 Java SOAP 服务器生成的,那么您可能有多个名为“service”(或具有相同名称)的函数。PHP SOAP 客户端只会识别和使用第一个。您需要手动重命名您在 WSDL 中的所有内容!
回答by Suhas holla
Just add Parameters,Return type and Method of web service in comments at the top of the function. It will work. I tried its working.
只需在函数顶部的注释中添加 Web 服务的参数、返回类型和方法即可。它会起作用。我试过它的工作。
/**
* @param string the symbol of the stock
* @return float the stock price
* @soap
*/
public function getPrice($symbol)
{
//...return stock price for $symbol
}
回答by Leandro Oliveira
I had this problem and finally decided to check my php error log.
我遇到了这个问题,最后决定检查我的 php 错误日志。
In php.inienable always_populate_raw_post_data = -1
and restart the server .
在php.ini 中启用always_populate_raw_post_data = -1
并重新启动服务器。
My PHP version is 5.6.8
我的 PHP 版本是5.6.8
回答by Rvanlaak
In our situation this exception occurred when upgrading from PHP5.6 to PHP7. For us disabling the WSDL cache did also work.
在我们的情况下,这个异常发生在从 PHP5.6 升级到 PHP7 时。对我们来说,禁用 WSDL 缓存也有效。
ini_set("soap.wsdl_cache_enabled", "0");
Also see: http://lornajane.net/posts/2015/soapfault-when-switching-php-versions
另见:http: //lornajane.net/posts/2015/soapfault-when-switching-php-versions