如何使用 Flex 3 中的本地数据模拟服务?

发布于 2024-07-27 16:49:30 字数 809 浏览 4 评论 0原文

我正在编写一个小型 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

Saygoodbye 2024-08-03 16:49:30

您可以将 HTTP 服务包装在符合您的服务接口并返回预期对象的 PsuedoRemoteObject 类中。

You might wrap the HTTP service in a PsuedoRemoteObject class that conforms to your service interface and returns the expected objects.

梦途 2024-08-03 16:49:30

最简单的方法就是在本地运行服务器。

Easiest way would just be running a server locally.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文