我正在Symfony中编写一个SOAP应用程序,对于我的所有请求,我收到了一个错误Procedure 'getClusterName' not present.
奇怪的是,当我在纯PHP中创建测试SOAP应用程序时,它工作正常,但Symfony中的相同代码返回错误.
另一个奇怪的事情是,当我在SOAP服务器代码中列出可用的服务函数时$server->getFunctions(),它返回服务函数的getClusterName数组并且在该数组中.所以该功能对于服务器是已知的,但它无法调用它.
在Symfony中编写服务时,我遵循了本文,这是我的代码:
客户:
namespace Prj\SoapBundle\Controller;
class SoapController extends Controller
{
public function indexAction()
{
$client = new \SoapClient('http://localhost/test.wsdl');
$client->getClusterName();
Run Code Online (Sandbox Code Playgroud)
服务器:
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();
Run Code Online (Sandbox Code Playgroud)
服务:
namespace Prj\SoapBundle;
class HelloService
{
public function getClusterName()
{
return '<?xml version="1.0" encoding="utf-8"?><root>Hello!</root>';
}
}
Run Code Online (Sandbox Code Playgroud)
*.wsdl文件似乎是正确的,因为它将调用与控制器绑定,并与vanilla PHP服务一起正常工作.
在Internet上,此错误通常由缓存的wsdl解释,但这是通过将soap.wsdl_cache_enabled参数设置为零来在服务器代码中处理的.