0

在 Flex SDK 中使用 HTTPService POST 方法时出现此错误:

[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: http://localhost/MAMP/secondPHP.php" errorID=2032]. URL: http://localhost/MAMP/secondPHP.php"]
    at mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AbstractInvoker.as:345]
    at mx.rpc::Responder/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\Responder.as:68]
    at mx.rpc::AsyncRequest/fault()[E:\dev\4.y\frameworks\projects\rpc\src\mx\rpc\AsyncRequest.as:113]
    at DirectHTTPMessageResponder/errorHandler()[E:\dev\4.y\frameworks\projects\rpc\src\mx\messaging\channels\DirectHTTPChannel.as:410]
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

这是我的弹性代码:

private function returnValue(evt:ResultEvent):void {
            label.text = "" + evt.result;
        }

        protected function add(event:MouseEvent):void
        {
            // TODO Auto-generated method stub
            new_friend.send();
        }

    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    <s:HTTPService id="new_friend" result="returnValue(event)" method="POST" url="http://localhost/server/secondPHP.php" useProxy="false">
        <s:request xmlns="">
            <method>ADD</method>
        </s:request>
    </s:HTTPService>
</fx:Declarations>

这是我的PHP代码:

    <?php
$method = $_POST["method"];

if ($method == "ADD") {
    $xml = new SimpleXMLElement("http://localhost/server/userdatabase.xml", null, true);

    $xml->Users->addChild("User", "testuser");
    $xml->asXML('http://localhost/server/userdatabase.xml');    

    $returnValue = "Added";
    print($returnValue);
}
?>

最后是我的 XML 代码:

    <?xml version="1.0" encoding="UTF-8"?>
<Users>
<User>SomeUser</User>
</Users>

有谁知道我为什么会收到这个错误?我注意到只有在 PHP 文件中使用 SimpleXML 时才会出现此错误,而当我删除 xml 代码时,我没有收到错误消息,而是看到“print($returnValue)”消息。

RMK-雅各布

4

0 回答 0