如何使用 Flex 3 中的本地数据模拟服务?
我正在编写一个小型 Flex 应用程序,最终将调用 PHP 服务来执行其工作。 但与此同时,我希望它使用 XML 形式的本地数据,以便我能够独立于数据服务开发 Flex 部分。
做这个的最好方式是什么?
我想模拟这样的服务:
public class Service {
public function getIssues(project:String):ArrayCollection {}
public function addIssue(issue:Issue):void {}
// ...
}
假设我将数据存储在 assets/
中:
assets/_project1_.data.xml
assets/_project2_.data.xml
assets/_project3_.data.xml
如果我只需要加载一个,我会执行以下操作:
<mx:HTTPService id="issueService"
url="assets/issues.xml"
fault="serviceFaultHandler(event)"
result="issueResultHandler(event)"/>
并使用 调用该服务IssuerService.send()
,按预期填充我的结果。 我该如何做到这一点,就像它是一个 RemoteObject
一样,但将我的数据保留在本地?
I am writing a small flex application that will, eventually, call PHP services to perform its work. In the meantime, however, I would like to have it use local data in XML form to allow me to develop the Flex part independently of the data service.
What is the best way to do this?
I want to emulate a service like this:
public class Service {
public function getIssues(project:String):ArrayCollection {}
public function addIssue(issue:Issue):void {}
// ...
}
Suppose I have the data stored in assets/
:
assets/_project1_.data.xml
assets/_project2_.data.xml
assets/_project3_.data.xml
If I only ever needed to load one, I'd do the following:
<mx:HTTPService id="issueService"
url="assets/issues.xml"
fault="serviceFaultHandler(event)"
result="issueResultHandler(event)"/>
And invoke the service using issuerService.send()
, populating my results as expected. How do I do this as though it were a RemoteObject
instead, but keep my data local?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将 HTTP 服务包装在符合您的服务接口并返回预期对象的 PsuedoRemoteObject 类中。
You might wrap the HTTP service in a PsuedoRemoteObject class that conforms to your service interface and returns the expected objects.
最简单的方法就是在本地运行服务器。
Easiest way would just be running a server locally.