2012-07-26 25 views
7

我在Symfony中編寫了一個SOAP應用程序,並且對於我的所有請求,我得到一個錯誤Procedure 'getClusterName' not presentPHP SOAP過程'functionName'不存在

奇怪的是,當我在純PHP中創建測試SOAP應用程序時,它工作正常,但Symfony中的相同代碼返回錯誤。

另一個奇怪的是,當我在SOAP服務器代碼中列出可用的服務函數$server->getFunctions()時,它返回服務函數的數組,getClusterName在該數組中。所以這個函數對服務器是已知的,但它不能調用它。

當寫在Symfony的服務我也跟着this article這裏是我的代碼:

客戶

namespace Prj\SoapBundle\Controller; 

class SoapController extends Controller 
{ 
    public function indexAction() 
    { 
     $client = new \SoapClient('http://localhost/test.wsdl'); 
     $client->getClusterName(); 

服務器

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(); 

服務

namespace Prj\SoapBundle; 

class HelloService 
{ 
    public function getClusterName() 
    { 
     return '<?xml version="1.0" encoding="utf-8"?><root>Hello!</root>'; 
    } 
} 

* .wsdl文件似乎是正確的,因爲它結合與控制器通話和正常工作與香草PHP服務。

在因特網上,這個錯誤通常是由緩存的wsdl解釋的,但這是在服務器代碼中通過將soap.wsdl_cache_enabled參數設置爲零來處理的。

回答

11

即使設置soap.wsdl_cache_enabled = 0,也請嘗試清空/tmp文件夾。

3

清除wsdl的tmp文件夾 - 前綴文件適用於我。我也在我的開發環境中建議將PHP的wsdl_cache_enabled選項更改爲0。