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 !
}
}