0

我正在寻找一种方法来捕获 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但找不到。

谢谢

4

1 回答 1

0

根本问题是Flash无法处理服务器返回状态<> 200 http://www.robsondesign.com/blog/index.php/2009/04/16/flex-flash-and-http-status-codes /

于 2011-11-10T12:43:28.507 回答