Initialize webservice WSDL at runtime using Flex and Mate framework

Posted by GroovyB on Stack Overflow See other posts from Stack Overflow or by GroovyB
Published on 2010-03-17T07:29:48Z Indexed on 2010/03/17 7:31 UTC
Read the original article Hit count: 384

Filed under:
|
|
|

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 ?

© Stack Overflow or respective owner

Related posts about flex

Related posts about mate