将代理 Web 服务与 Adobe AIR/BlazeDS 结合使用
我正在尝试使用代理调用网络服务。我在 blazeds 端的代理配置设置如下:
<destination id="ws-catalog">
<properties>
<wsdl>http://feeds.adobe.com/webservices/mxna2.cfc?wsdl</wsdl>
<soap>*</soap>
</properties>
<adapter ref="soap-proxy"/>
</destination>
在 Adobe AIR 端,我的代码是:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="loadConfiguration()">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var cs:ChannelSet;
private function loadConfiguration():void
{
var amfChannel:AMFChannel = new AMFChannel("my-amf", 'http://localhost:8400/messagebroker/amf');
cs = new ChannelSet();
cs.addChannel(amfChannel);
}
protected function ws_resultHandler(event:ResultEvent):void
{
var obj:Object = event.result;
}
protected function ws_faultHandler(event:FaultEvent):void
{
var faultObj:Object = event.fault;
}
protected function button1_clickHandler(event:MouseEvent):void
{
ws.getOperation('getFeeds').send();
}
]]>
</fx:Script>
<fx:Declarations>
<s:WebService id="ws"
channelSet="{cs}"
useProxy="true"
destination="ws-catalog"
showBusyCursor="true"
result="ws_resultHandler(event)"
fault="ws_faultHandler(event)"
/>
</fx:Declarations>
<s:Button label="CallWebService" click="button1_clickHandler(event)"/>
</s:WindowedApplication>
但是现在,每当我启动 AIR 应用程序时,都会收到以下错误:
faultCode: InvokeFailed
faultDetail: Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (null)
faultString: [MessagingError message='Destination 'ws-catalog' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']
有人可以帮助我或指出类似的解决方案吗? 谢谢。
I am trying to call a webservice using proxy. My settings for proxy-config on blazeds side are as below:
<destination id="ws-catalog">
<properties>
<wsdl>http://feeds.adobe.com/webservices/mxna2.cfc?wsdl</wsdl>
<soap>*</soap>
</properties>
<adapter ref="soap-proxy"/>
</destination>
On Adobe AIR side, my code is:
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="loadConfiguration()">
<s:layout>
<s:VerticalLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
[Bindable]
private var cs:ChannelSet;
private function loadConfiguration():void
{
var amfChannel:AMFChannel = new AMFChannel("my-amf", 'http://localhost:8400/messagebroker/amf');
cs = new ChannelSet();
cs.addChannel(amfChannel);
}
protected function ws_resultHandler(event:ResultEvent):void
{
var obj:Object = event.result;
}
protected function ws_faultHandler(event:FaultEvent):void
{
var faultObj:Object = event.fault;
}
protected function button1_clickHandler(event:MouseEvent):void
{
ws.getOperation('getFeeds').send();
}
]]>
</fx:Script>
<fx:Declarations>
<s:WebService id="ws"
channelSet="{cs}"
useProxy="true"
destination="ws-catalog"
showBusyCursor="true"
result="ws_resultHandler(event)"
fault="ws_faultHandler(event)"
/>
</fx:Declarations>
<s:Button label="CallWebService" click="button1_clickHandler(event)"/>
</s:WindowedApplication>
But now, whenever I launch my AIR app, am getting following error:
faultCode: InvokeFailed
faultDetail: Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (null)
faultString: [MessagingError message='Destination 'ws-catalog' either does not exist or the destination has no channels defined (and the application does not define any default channels.)']
Can somebody help me OR point me to a similar solution?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请检查下面的代码。它可以在我的机器上运行。您需要等待几秒钟,getFeeds 返回大量数据。
Please check the code below. It works on my machine. You need to wait a couple of seconds, getFeeds returns a lot of data.
在不了解所有配置的情况下很难说。您可以检查以下几个原因:
- 未能在 services.xml 中声明 proxy-config.xml 文件
- 未能在项目中包含 services.xml
- 未能为您的目标声明通道
学习如何的最佳方法使用 BlazeDS 作为代理调用 Web 服务是下载 blazeds 交钥匙安装并采取看看样品。解压存档后,您可以在 blazedsrootfolder/tomcat/webapps/samples 中找到示例文件夹。您会发现一个示例显示您正在尝试做什么。
Hard to say without knowing all the configuration. You can check a couple of reasons like:
-failure to declare the proxy-config.xml file in services.xml
-failure to include services.xml in the project
-failure to declare a channel for your destination
The best way to learn how to invoke webservices using BlazeDS as a proxy is to download the blazeds turnkey installation and to take a look at the samples. After uncompressing the archive you can find the samples folder in blazedsrootfolder/tomcat/webapps/samples. You will find one example showing what you are trying to do.