I have the following code:
[Bindable]
private var myServerHostPort:String = "af arf";
<!--wsdl="{myServerHostPort}/channel.asmx?wsdl"-->
<!--wsdl="http://localhost/mmo/channel.asmx?wsdl"-->
<!--wsdl="@ContextRoot()/mmo/channel.asmx?wsdl"-->
<mx:WebService
id="channelList"
concurrency="single"
rootURL="{afariaServerHostPort}"
wsdl="{myServerHostPort}/mmo/channel.asmx?wsdl"
fault="faultHandler(event)"
makeObjectsBindable="true">
<mx:operation
name="GetChannelList"
makeObjectsBindable="true"
concurrency="single"
result="resultChannelListHandler(event)">
<mx:request xmlns="">
<transmitterAddress>{wsTransmitterAddress}</transmitterAddress>
<channelFolder>{wsChannelFolder}</channelFolder>
</mx:request>
</mx:operation>
</mx:WebService>
My application is defined as:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="initializeApplication()"
width="1100" height="800"
>
In the debugger, I can see the initialApplication() function being called.
private function initializeApplication():void
{
trace('initializeApplication: myServerHostPort:'+myServerHostPort);
myServerHostPort = NetworkUtil.getServerURL();
trace('initializeApplication: myServerHostPort:'+myServerHostPort);
}
In the debugger, I see the myServerHostPort = 'af arf', then it is
changed to something correct: http://localhost
After I hit F8, I get this fault reported:
faultDetail="Unable to load WSDL. If currently online, please verify
the URI and/or format of the WSDL (af arf/mmo/afaria/channel.asmx?wsdl)
You see here it is still using the original value instead of the one
set in the initializeApplication() function.
So 2 questions:
1. Why is it even calling this WebService automatically? I only want
to call it when "I" call it. For some reason it is being called
during the initialization process and I don't want it to.
2. Why is it using this old value? If it is a [Bindable] variable it
should be using that.
3. If someone can't offer a way to fix this, can you suggest
alternatives.
I have tried making the WebService calls via ActionScript myself to
bypass the issue, but the loadWSDL() never seems to complete and there
are no errors thrown.
public function initWebService():void
{
CursorManager.setBusyCursor();
WS = new mx.rpc.soap.WebService();
//location of the Web Service Description
WS.wsdl = myServerHostPort+"/channel.asmx?wsdl";
WS.endpointURI = myServerHostPort+"/channel.asmx";
//GetChannelList is the WebService method we want to use
//and we want the results returned in the e4x XML format
WS.useProxy=false;
WS.requestTimeout=2;
WS.destination = "GetChannelList";
//specify the function that will handle the results
//returned by the operation
WS.GetChannelList.addEventListener("result", resultChannelListHandler);
//specify the method that will handle any faults
WS.GetChannelList.addEventListener("fault", faultHandler);
//specify the method that will handle the
//the event of loading the WSDL
//once the WSDL is loaded we will call
//our method in the function loadHandler
WS.addEventListener("load", loadChannelListHandler);
//Load the WSDL for this WebService
WS.loadWSDL();
}//end function useWebService
private function loadChannelListHandler(e:LoadEvent):void
{
CursorManager.removeBusyCursor();
wsdlLoaded = true;
ta.text = "wsdl loaded" + "\n\n";
}
Thanks for any feedback.
Dave