And you can always just send the xml as a string.

var oRequest:Object = new Object;

oRequest.xmlstring = myXML.toXMLString();

xmlSender.send(oRequest);

 

Tracy

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of nathanpdaniel
Sent: Tuesday, May 15, 2007 10:01 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Send XML to PHP

 

If you want to send raw XML from Flex, try building your XML within 
Flex (like so)... 

<mx:XML id="myXML">
<data>{stringVar}</data>
</mx:XML>

Then, in your HTTPService object, just keep the first line with one 
exception:
<mx:HTTPService id="xmlSender" contentType="application/xml" .... />

When you call myRequest.send() - use this instead: myRequest.send
(myXML);

In your PHP you'll need to request like so:

if (isset($HTTP_RAW_POST_DATA)) {
$request_xml = $HTTP_RAW_POST_DATA;
}
else {
$request_xml = implode("\r\n", file('php://input'));
}

That's all I do :D Your error could in fact be coming from your PHP 
rather than Flex itself, such as, your PHP page is sending back an 
HTML error saying it can't decode - if there's nothing to decode, it 
will cause a problem. I'm in the midst of the same error myself, if 
I post invalid XML - or XML not compliant to the schema, it returns 
an HTML error, throwing a fault in Flex, so it looks like a Flex 
issue when it's actually a fault with what I'm sending. Hope it 
helps! -Nathan
--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "b_alen" <[EMAIL PROTECTED]> wrote:
>
> I'm sending the XML object to php in HTTPService.send(xmlObject);
> 
> But how do I receive it on the server and then store this as a new 
xml
> file on a server? I'm getting errors when I'm trying all of these on
> the server:
> 
> $raw_xml = $_POST["data"];
> //$raw_xml = $_REQUEST["data"];
> //$raw_xml = file_get_contents("php://input");
> 
> And this is on the client:
> 
> <mx:HTTPService id="xmlSender"
> url="test.php"
> method="POST" showBusyCursor="true" 
useProxy="false"
> result="handleResult(event)"
> fault="handleFault(event)" >
> 
> <mx:request>
> <data>{stringVar}</data>
> </mx:request>
> 
> </mx:HTTPService>
> 
> 
> If I put the something directly in the <data />, I get the result, 
but
> if I use the variable like above, I get:
> 
> faultCode="Client.CouldNotDecode" 
> 
> 
> Weird, and I can't find anything like that on Google. I'm trying for
> two days with no progress. 
> 
> 
> Thanks,
> 
> Alen
>

 

Reply via email to