2013-04-12 34 views
0

我有一個Zend前端,它們都是通過SOAP進行通信的Zend前端。後端的異常應該在前端上拋出Exception/SoapFault。這適用於錯誤消息,但錯誤代碼會以某種方式丟失。我需要代碼才能夠在前端以不同的語言顯示錯誤。我嘗試了很多,但無法讓它工作。ZendSoapServer拋出異常/ SoapFault時丟失錯誤代碼

這是我SoapController的後端handleSoap功能:

private function handleSOAP($class) { 
    $options = array('uri' => 'urn:'.$class.'','location' => $this->_WSDL_URI); 
    $server = new Zend_Soap_Server(null, $options); 
    $server->setEncoding('ISO-8859-1'); 
    $server->setClass($class); 
    $server->registerFaultException('Exception'); 
    $server->handle(); 
} 

在前端的SoapCallerClass:

 public function __construct() { 
      $this->client = new Zend_Soap_Client($this->_WSDL_URI); 
      $this->client->setWsdlCache(WSDL_CACHE_NONE); 
      $this->client->setEncoding('ISO-8859-1'); 
    } 

    public function __call($method,$params) { 
     try { 
     $this->client->mySoapFunction();  
     } catch (Exception $e) { 
     throw $e; // No error code inside ! 
     } 
    } 

回答

0

我看着傳遞到前端的SOAPFault對象。使用getMessage()將返回原始消息。使用getCode返回0,但該對象具有一個名爲faultcode和faultmessage的屬性,該屬性包含異常的原始代碼&消息。

Lucian