使用 Flex 和 Mate 框架在运行时初始化 Web 服务 WSDL

发布于 2024-08-25 14:53:53 字数 1286 浏览 6 评论 0原文

我正在 Mate 框架之上开发 Flex 应用程序。 在此应用程序中,我使用 Web 服务来检索数据。
由于此 Web 服务不是固定位置 URL(取决于客户安装它的位置),因此我在配置文件中定义此 URL。 当 Flex 应用程序启动时,它首先读取此配置文件,然后我想使用找到的值来初始化 Web 服务。
但目前,我不知道该怎么做。

这是我的 EventMap.mxml

<EventMap>
<services:Services id="services" />

<EventHandlers type="{FlexEvent.PREINITIALIZE}">        
    <HTTPServiceInvoker instance="{services.configService}">
        <resultHandlers>
            <MethodInvoker generator="{ConfigManager}" method="loadFromXml" arguments="{resultObject}" />
        </resultHandlers>
        <faultHandlers>
            <InlineInvoker method="Alert.show" arguments="ERROR: Unable to load config.xml !" />
        </faultHandlers>            
    </HTTPServiceInvoker>

在这部分中,ConfigManager 解析配置文件并初始化一个名为 webServiceWsdl 的可绑定属性

这是我的 Services.mxml

<mx:Object>
<mx:Script>
<![CDATA[
    [Bindable] public var webservice:String;
]]>
</mx:Script>

<mx:HTTPService id="configService" url="config.xml" useProxy="false" />
<mx:WebService id="dataService" wsdl="{webservice}" useProxy="false"/>
</mx:Object>

我如何初始化此 webservice 属性?

I am developing a Flex application on top of Mate framework.
In this application, I am using a webservice to retrieve data.
As this webservice as not a fix location URL (depending on where customers installed it), I define this URL in a config file.
When the Flex application starts, it first reads this config file, then I would like to use the value I found to initialize the webservice.
But currently, I have no idea how to this.

Here is my EventMap.mxml

<EventMap>
<services:Services id="services" />

<EventHandlers type="{FlexEvent.PREINITIALIZE}">        
    <HTTPServiceInvoker instance="{services.configService}">
        <resultHandlers>
            <MethodInvoker generator="{ConfigManager}" method="loadFromXml" arguments="{resultObject}" />
        </resultHandlers>
        <faultHandlers>
            <InlineInvoker method="Alert.show" arguments="ERROR: Unable to load config.xml !" />
        </faultHandlers>            
    </HTTPServiceInvoker>

In this part, the ConfigManager parse the config file and intitialize a bindable property called webServiceWsdl

Here is my Services.mxml

<mx:Object>
<mx:Script>
<![CDATA[
    [Bindable] public var webservice:String;
]]>
</mx:Script>

<mx:HTTPService id="configService" url="config.xml" useProxy="false" />
<mx:WebService id="dataService" wsdl="{webservice}" useProxy="false"/>
</mx:Object>

How can I initialize this webservice property ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

凶凌 2024-09-01 14:53:53

创建一个单例类来封装您的配置选项,并将单例实例上的属性绑定到您的服务定义中。我们在这方面做了相当多的工作。

[Bindable]
class Config
{
    private static var instance:Config;

    public static function getInstance ():Config {
        if (!instance)
            instance = new Config();
        return instance;
    }

    public var WEBSERVICE:String = "default value";
}

在 Services.mxml 中:

<mx:WebService id="dataService" wsdl="{Config.getInstance().WEBSERVICE}" useProxy="false"/>

显然,当您从文件加载配置时,您需要更新配置实例。

Create a singleton class to encapsulate your configuration options and bind a property on the singleton instance into your service definition. We do this a fair bit.

[Bindable]
class Config
{
    private static var instance:Config;

    public static function getInstance ():Config {
        if (!instance)
            instance = new Config();
        return instance;
    }

    public var WEBSERVICE:String = "default value";
}

In Services.mxml:

<mx:WebService id="dataService" wsdl="{Config.getInstance().WEBSERVICE}" useProxy="false"/>

Obviously, you need to update your config instance when you load the config from the file.

花期渐远 2024-09-01 14:53:53

我看不出这与所讨论的有什么不同。一个是可绑定字符串,另一个是可绑定对象。

我发现,当(在上面的示例中)与 Web 服务的 wsdl 参数关联的可绑定字符串发生更改时,Web 服务永远不会更新。

因此,如果字符串的值一开始就不正确,Web 服务将发出无法找到 wsdl 的错误,并且永远不会再尝试...即使字符串的值发生更改。

普雷斯顿

I fail to see how this is different from the one in question. One is a bindable String, the other is a Bindable object.

I have found that when (in the above example) the bindable string associated with the wsdl parameter of the web service changes, the web service never updates.

As such, if the value of the string is not correct out of the gate, the web service will blow an error failing to find the wsdl, and will never try again...even when the string changes value.

Preston

稍尽春風 2024-09-01 14:53:53

您可以使用以下内容:

WebService.loadWSDL(runtimeWsdl) ;

其中 runtimeWsdl 是包含动态 wsdl 值的 String 类型变量。

You can use this:

WebService.loadWSDL(runtimeWsdl) ;

Where runtimeWsdl is a String type variable containing the dynamic wsdl value.

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