0

I am getting this error when using the HTTPService POST method in the Flex SDK:

[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()

This is my flex code:

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>

Here is my PHP code:

    <?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);
}
?>

And finally my XML code:

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

Does anyone know why I might be getting this error? I noticed that I am only getting this error when I am using SimpleXML in the PHP file, and when I delete the xml code I don't get the error and I see the "print($returnValue)" message.

RMK-Jacob

RMK-Jacob
  • 209
  • 1
  • 4
  • 15
  • Can you run the PHP code without Flex/Flash in the picture? It sounds to me like the PHP Code cannot access the userdatabase.xml file. – JeffryHouser Jan 06 '13 at 01:19
  • 1
    @www.Flextras.com I am attempting to run it right now without Flex. I have been playing with it for awhile and it looks like userdatabase.xml is/might be corrupt. I don't think it was formatted correctly when it was created. – RMK-Jacob Jan 06 '13 at 02:18
  • @www.Flextras.com I have gotten rid of the error! But now I am having a problem, the $xml->asXML('http://localhost/server/userdatabase.xml'); doesn't edit the XML file. Do you know why it doesn't save to the file? – RMK-Jacob Jan 06 '13 at 03:23
  • I don't know anything about PHP; so can't help on that side of the equation. Sorry – JeffryHouser Jan 06 '13 at 04:46
  • @www.Flextras.com Ok. Its fine. Thanks for the help anyway. – RMK-Jacob Jan 06 '13 at 05:44

0 Answers0