问题描述
我正在 Symfony 中编写一个 SOAP 应用程序,对于我的所有请求,我收到一个错误 Procedure 'getClusterName' not present
.
奇怪的是,当我用纯 PHP 创建一个测试 SOAP 应用程序时,它工作正常,但在 Symfony 中相同的代码返回一个错误.
另一个奇怪的事情是,当我在 SOAP 服务器代码中使用 $server->getFunctions()
列出可用的服务函数时,它返回服务函数数组和 getClusterName
在该数组中.所以这个函数是服务器知道的,但是不能调用.
在 Symfony 中编写服务时,我遵循了这篇文章和这里是我的代码:
客户:
命名空间 Prj\SoapBundle\Controller;类 SoapController 扩展控制器{公共函数 indexAction(){$client = new \SoapClient('http://localhost/test.wsdl');$client->getClusterName();
服务器:
命名空间 Prj\SoapBundle\Controller;类 SoapController 扩展控制器{公共函数 indexAction(){ini_set("soap.wsdl_cache_enabled", "0");$server = new \SoapServer($this->container->getParameter('wsdl'));$server->setClass('SoapBundle\HelloService');$server->handle();
服务:
命名空间 Prj\SoapBundle;类 HelloService{公共函数 getClusterName(){return '<?xml version="1.0" encoding="utf-8"?><root>Hello!</root>';}}
*.wsdl 文件似乎是正确的,因为它将调用与控制器绑定,并且可以正常使用 vanilla PHP 服务.
在 Internet 上,此错误通常由缓存的 wsdl 解释,但在服务器代码中通过将 soap.wsdl_cache_enabled
参数设置为零来处理此错误.
即使设置了 soap.wsdl_cache_enabled = 0
,也要尝试清空 /tmp
文件夹.>
I'm writing a SOAP application in Symfony and for all my request I'm getting an error Procedure 'getClusterName' not present
.
Strange thing is that when I create a test SOAP application in pure PHP, it works fine, but the same code in Symfony returns an error.
Another strange thing is that when in the SOAP server code I list available service functions with $server->getFunctions()
, it returns array of the service functions and getClusterName
is in that array. So the function is known to the server, but it can't call it.
When writing the service in Symfony I followed this article and here is my code:
Client:
namespace Prj\SoapBundle\Controller;
class SoapController extends Controller
{
public function indexAction()
{
$client = new \SoapClient('http://localhost/test.wsdl');
$client->getClusterName();
Server:
namespace Prj\SoapBundle\Controller;
class SoapController extends Controller
{
public function indexAction()
{
ini_set("soap.wsdl_cache_enabled", "0");
$server = new \SoapServer($this->container->getParameter('wsdl'));
$server->setClass('SoapBundle\HelloService');
$server->handle();
Service:
namespace Prj\SoapBundle;
class HelloService
{
public function getClusterName()
{
return '<?xml version="1.0" encoding="utf-8"?><root>Hello!</root>';
}
}
*.wsdl file seems to be correct because it binds the call with controller and works fine with vanilla PHP service.
On Internet this error usually explained by cached wsdl, but this is handled here in server code by setting soap.wsdl_cache_enabled
parameter to zero.
Even if setting soap.wsdl_cache_enabled = 0
, try also emptying the /tmp
folder.
这篇关于PHP SOAP 过程“functionName"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!