1
votes

Hello and thanks in advance for any help you can provide.

My AIR application queries a webservice to see what components to build. A sample of the XML returned is:

<item>
 <type>EventList</type>
 <url><![CDATA[http://dashboard/cgi-bin/dataService.pl?type=ManagedEvents]]></url>
 <index>4</index>
 <title>Index 4 eventlist</title>
 <description>Application 4</description>
</item>

I am trying to pass the URL stored in the field to a mxml component's HTTPService so that component can retrieve a set of data. The enclosing application parsed the above XML fine and then does:

component.getData(url);

Where in the component getData is:

public function getData(url:String):void {
    ws = url;
    dataService.send();
}

and

<mx:HTTPService 
        id="dataService"
        url="{ws}"
        resultFormat="e4x"
        result="resultsHandler(event);"
        fault="faultHandler(event);"
        useProxy="false"
    />

Once the send() is called, I get the following error:

[FaultEvent fault=[RPC Fault faultString="A URL must be specified with useProxy set to false." faultCode="Client.URLRequired" faultDetail="null"] messageId=null type="fault" bubbles=false cancelable=true eventPhase=2]

Any clues as to what I'm doing wrong? (Thanks again for the help)

TB

2
I've got a crossdomain.xml file that works. in the above, ws is defined as <code>[Bindable] public var ws:String;</code>Todd
Interestingly, if I change getData above to: getData(url:String):void { dataService.url = item; dataService.send();} it works. Does this imply databinding problem with {ws}?Todd

2 Answers

1
votes

Data binding works asynchronously through the event system, and because of that the binding happens some unspecified amount of time after you alter the bindable variable. In your case, the update event for ws hasn't fired yet when you call dataService.send(). This is why directly altering the url property works, and binding doesn't.

If you need to use databinding because your application design prevents you from accessing the service directly, I'd recommend binding to a property with getter and setter functions that you control.

2
votes

It depends on how you have defined the ws variable. It should have a [Bindable] metatag before it to specify that it can be used for data binding. For example:

[Bindable]
public var ws:String;

Of course you could also just set the url of the HTTPService object explicitly, instead of using data binding, like this:

public function getData(url:String):void {
    dataService.url = url;
    dataService.send();
}

Hope this helps.