2013-04-12 64 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