Trace your result:

flexitXML = event.result as XML;

trace(flexitXML.toXMLString());  //This will show you your xml

 

Also, you can try:

flexitXML = XML(event.result); //the "as" should work though

 

Also, hit the url from a browser, you should see valid xml.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of generalxxaxx
Sent: Tuesday, August 28, 2007 2:36 AM
To: [email protected]
Subject: [flexcoders] Question about HTTPService and Perl

 

I am trying to connect to a Perl script on my server.
At the moment I'm mostly flopping around.
Below are snippets of the code involved.

I was hoping for hints on what bit of blatant stupidity I've overlooked.
Or, perhaps a few best practices on how to debug returning information
such as this.
Or, perhaps pointers to a method for "looking" at the returned object
to see what it is. 
Or, maybe everything is fine and it's a problem with how to properly
access the data in the xml.

Regards

===============================================
I use the following for the HTTPService
<mx:HTTPService id="srv" url="http://www.mydom.com/cgi-bin/script.pl
<http://www.mydom.com/cgi-bin/script.pl> "
useProxy="false"
resultFormat="e4x"
result="httppostResult(event);"
method="POST">
<mx:request>
<resource>{resourceParam}</resource>
<resource2>{resourceParam2}</resource2>
<resource3>{resourceParam3}</resource3>
<resource4>{resourceParam4}</resource4>
</mx:request> 
</mx:HTTPService>

<mx:Script>
<![CDATA[
[Bindable]
private var resourceParam:String = "uniits";
[Bindable]
private var resourceParam2:String = "uniits2";
[Bindable]
private var resourceParam3:String = "uniits3";
[Bindable]
private var resourceParam4:String = "uniits4";

private var flexitXML:XML;

private function httppostResult(event:ResultEvent):void {
flexitXML = event.result as XML;
// or flexitXML = new XML(event.result.toString());
resultsTextArea.text = flexitXML.toString();
resultsLabel.text = flexitXML.a.b.resource;
}
}
]]>
</mx:Script>

================================
script.pl returns
Content-type: text/xml

<?xml version="1.0" encoding="utf-8"?>
<a>
<b>
<resource2>uniits2</resource2>
<resource3>uniits3</resource3>
<resource>uniits</resource>
<resource4>uniits4</resource4>
</b>
</a>

================================
resultsTextArea.text =
<a>
<b>
<resource2>uniits2</resource2>
<resource3>uniits3</resource3>
<resource>uniits</resource>
<resource4>uniits4</resource4>
</b>
</a>

 

Reply via email to