我正在寻找一种方法来捕获 PHP 在 Flex 中使用HTTPService
. 不使用 AMFPHP可以做到吗?
在我当前的实现中,如果在 PHP 中抛出异常,则 aFaultEvent.FAULT
确实会在 Flex 端调度。唯一的问题是异常的消息字符串在FaultEvent
.
让我尝试借助一个示例更好地解释。假设我们在服务器端有以下 PHP 代码:
<?php
throw new Exception("Exception message");
?>
在 flex 方面,假设有一个HTTPService
实例调用了上面的 PHP 代码。此外,它在 上调用以下函数FaultEvent.FAULT
:
private function onFaultyResult(evt:FaultEvent):void {
//How do I get the exception message here?
}
如何在此函数中从 PHP 获取异常消息?
注意:trace(evt.toString())
给出:
[FaultEvent fault=[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: 192.168.1.119/exception.php"]. URL: 192.168.1.119/exception.php"] messageId="7FF021A3-8C83-CB14-081D-8C8438802204" type="fault" bubbles=false cancelable=true eventPhase=2]
我还在调试器的其他字段中查找了“异常消息”,evt
但找不到。
谢谢