在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 - 雅各布