Flash HTTPService:从属性文件读取连接数据
我有我的 HTTPService,它看起来像这样:
<s:HTTPService
id="setCustomerInstalledPackageService"
url="http://localhost:8090/myapp/servletName"
useProxy="false" method="POST"
resultFormat="text"
result="onResult(event)"
fault="fault(event)">
</s:HTTPService>
我想通过从属性文件读取 HOST 和 PORT 来使此代码更加通用。这样,如果我更改网络服务的主机(或端口),我将不必重新编译我的闪存源。
我在网上搜索了一下,但找不到答案......有人吗?
谢谢!
i have my HTTPService, it looks like this :
<s:HTTPService
id="setCustomerInstalledPackageService"
url="http://localhost:8090/myapp/servletName"
useProxy="false" method="POST"
resultFormat="text"
result="onResult(event)"
fault="fault(event)">
</s:HTTPService>
I want to make this code more versatile by reading the HOST and PORT from a property file. This way, if I change the host (or the port) of my web-service, I will not have to re-compile my flash source.
I've Searched the web a little bit, but could not find the answer... anyone?
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否是最优雅的解决方案;如果有人知道更好的方法,我很乐意学习。
主要思想是使用一些可以在以后替换的唯一字符串来声明
HTTPService
。就我而言,我使用了__主机__和__端口__。读取配置文件后,我将这些字符串替换为从文件中获取的值。Main.mxml:
调用
initApp() 由这样声明的服务
: service-config.txt 非常简单:
希望有一天它能帮助某人......
Not sure whether this is the most elegant solution; if someone knows a better way I'd be happy to learn.
The main idea is to declare the
HTTPService
with some unique string that can be replaced afterwards. In my case, I've used __host__ and __port__. After reading the config file, I replace these strings with the values I get from the file.the Main.mxml:
The initApp() is invoked by the
The service declared this way:
and the service-config.txt is very simple:
Hope it will help someone, someday...