HTTPService 中的动态 url 不起作用
您好,提前感谢您提供的任何帮助。
我的 AIR 应用程序查询 Web 服务以查看要构建哪些组件。 返回的 XML 示例如下:
<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>
我试图将字段中存储的 URL 传递给 mxml 组件的 HTTPService,以便组件可以检索一组数据。 封闭的应用程序很好地解析了上面的 XML,然后执行以下操作:
component.getData(url);
组件 getData 中的位置是:
public function getData(url:String):void {
ws = url;
dataService.send();
}
调用
<mx:HTTPService
id="dataService"
url="{ws}"
resultFormat="e4x"
result="resultsHandler(event);"
fault="faultHandler(event);"
useProxy="false"
/>
send() 后,我收到以下错误:
[FaultEvent failure=[RPC Failure failureString="A URL 必须用以下参数指定useProxy 设置为 false。” failureCode =“Client.URLRequired”faultDetail =“null”] messageId = null type =“fault” bubbles = false cancelable = true eventPhase = 2]
关于我做错了什么的任何线索? (再次感谢您的帮助)
TB
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于您如何定义 ws 变量。 它前面应该有一个 [Bindable] 元标记,以指定它可用于数据绑定。 例如:
当然,您也可以只显式设置 HTTPService 对象的 url,而不是使用数据绑定,如下所示:
希望这会有所帮助。
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:
Of course you could also just set the url of the HTTPService object explicitly, instead of using data binding, like this:
Hope this helps.
数据绑定通过事件系统异步工作,因此在更改可绑定变量后,绑定会在一段未指定的时间内发生。 在您的情况下,当您调用 dataService.send() 时,ws 的更新事件尚未触发。 这就是为什么直接更改 url 属性有效,而绑定则无效的原因。
如果由于应用程序设计阻止您直接访问服务而需要使用数据绑定,我建议您使用您控制的 getter 和 setter 函数绑定到属性。
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.