将代理 Web 服务与 Adob​​e AIR/BlazeDS 结合使用

发布于 2024-12-07 09:49:22 字数 2773 浏览 1 评论 0原文

我正在尝试使用代理调用网络服务。我在 blazeds 端的代理配置设置如下:

<destination id="ws-catalog">
    <properties>
        <wsdl>http://feeds.adobe.com/webservices/mxna2.cfc?wsdl</wsdl>
        <soap>*</soap>
    </properties>
    <adapter ref="soap-proxy"/>
</destination>

在 Adob​​e 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 技术交流群。

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

发布评论

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

评论(2

记忆里有你的影子 2024-12-14 09:49:23

请检查下面的代码。它可以在我的机器上运行。您需要等待几秒钟,getFeeds 返回大量数据。

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[
        import mx.messaging.ChannelSet;
        import mx.messaging.channels.AMFChannel;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.soap.LoadEvent;
        import mx.rpc.soap.mxml.*;
        import mx.rpc.wsdl.WSDLOperation;
        [Bindable]
        private var cs:ChannelSet;
        [Bindable]
        var gateway:WebService

        private function loadConfiguration():void{
            var amfChannel:AMFChannel = new AMFChannel("my-amf", 'http://localhost:8400/samples/messagebroker/amf');
            cs = new ChannelSet();
            cs.addChannel(amfChannel);
            gateway = new WebService();
            gateway.channelSet = cs;
            gateway.destination = "ws-catalog";
            gateway.useProxy = true;
            gateway.addEventListener(ResultEvent.RESULT,ws_resultHandler);
            gateway.addEventListener(FaultEvent.FAULT,ws_faultHandler);
            gateway.loadWSDL();
        }

        protected function ws_resultHandler(event:ResultEvent):void{
            var obj:Object = event.result;
            trace("ok");
        }

        protected function ws_faultHandler(event:FaultEvent):void{
            var faultObj:Object = event.fault;
            trace("nok");
            trace(faultObj);
        }

        protected function button1_clickHandler(event:MouseEvent):void{
            gateway.getFeeds();
        }


    ]]>
</fx:Script>

<s:Button label="CallWebService" click="button1_clickHandler(event)"/>

Please check the code below. It works on my machine. You need to wait a couple of seconds, getFeeds returns a lot of data.

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[
        import mx.messaging.ChannelSet;
        import mx.messaging.channels.AMFChannel;
        import mx.rpc.events.FaultEvent;
        import mx.rpc.events.ResultEvent;
        import mx.rpc.soap.LoadEvent;
        import mx.rpc.soap.mxml.*;
        import mx.rpc.wsdl.WSDLOperation;
        [Bindable]
        private var cs:ChannelSet;
        [Bindable]
        var gateway:WebService

        private function loadConfiguration():void{
            var amfChannel:AMFChannel = new AMFChannel("my-amf", 'http://localhost:8400/samples/messagebroker/amf');
            cs = new ChannelSet();
            cs.addChannel(amfChannel);
            gateway = new WebService();
            gateway.channelSet = cs;
            gateway.destination = "ws-catalog";
            gateway.useProxy = true;
            gateway.addEventListener(ResultEvent.RESULT,ws_resultHandler);
            gateway.addEventListener(FaultEvent.FAULT,ws_faultHandler);
            gateway.loadWSDL();
        }

        protected function ws_resultHandler(event:ResultEvent):void{
            var obj:Object = event.result;
            trace("ok");
        }

        protected function ws_faultHandler(event:FaultEvent):void{
            var faultObj:Object = event.fault;
            trace("nok");
            trace(faultObj);
        }

        protected function button1_clickHandler(event:MouseEvent):void{
            gateway.getFeeds();
        }


    ]]>
</fx:Script>

<s:Button label="CallWebService" click="button1_clickHandler(event)"/>

够运 2024-12-14 09:49:23

在不了解所有配置的情况下很难说。您可以检查以下几个原因:

- 未能在 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.

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