弹性网络服务
我正在使用 Flash Builder 4.5 和 flex 4.5 语言。 我正在使用 Web 服务调用 .php 来检索 json 中的数据。
<webservice:Webservice id="webservice" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="testResult" result="onTestResult(event)"/>
...
private function onTestResult(e:ResultEvent):void{
Alert.show(ObjectUtil.toString(testResult.lastResult));
}
在 Flash Builder 的“测试操作”窗口中,我进行了调用,返回的是一个由数组组成的 json 对象。
如果我从代码中调用相同的 Web 服务,它会返回 (object)#0,因此是一个空对象。没有错误抛出,只是一个空对象。
有人有一些建议吗?
I'm using Flash Builder 4.5 and flex 4.5 language.
I'm using a webservice to retrieve data in json calling a .php.
<webservice:Webservice id="webservice" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
<s:CallResponder id="testResult" result="onTestResult(event)"/>
...
private function onTestResult(e:ResultEvent):void{
Alert.show(ObjectUtil.toString(testResult.lastResult));
}
In the "Test Operation" window of Flash Builder I made my call and the return is a json Object made by arrays.
If I call the same webservice from the code instead, it returns a (object)#0 so an empty Object. No errors thown, just an empty Object.
Anyone has some tips?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Webservice
类的 ns 前缀表明您正在使用自定义实现,而不是框架WebService
类。但是,您没有提供任何具体信息,因此我将在黑暗中采取行动:如果您的自定义服务基于
HTTPService
类,请确保您设置resultFormat='文本'
。默认值为XML
,这会给您带来问题。如果您使用的是 Framework
WebService
类,那么您不能这样做,因为它是为 SOAP Web 服务而不是 JSON 设计的。 (来自mx.rpc.soap.WebService
的文档:)如果是其他实现,请提供更多详细信息。
The ns prefix of your
Webservice
class susggests you're using a custom implementation, rather than the frameworkWebService
class. However, you don't provide any specifics, so I'm gonna take a swing in the dark:If your custom service is based off the
HTTPService
class, make sure you're setting theresultFormat='text'
. The default isXML
, which will be causing you problems.If you're using the Framework
WebService
class, well - you can't, as it's designed for SOAP webservices, not JSON. (From the Docs formx.rpc.soap.WebService
:)If it's some other implementation, please provide more details.