I’m trying to use a web service I created but it’s not working. I’m pretty sure I’m doing it all wrong but all the tutorials I found are much more complicated than what I need and I don’t have much Flex/AS experience.
So the web service I created simply returns a string and I’d like to assign that string to a variable. Here’s the code I’m using:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" xmlns:text="flash.text.*" applicationComplete="loadList();">
<mx:Label id="txtTest" />
<mx:Script>
<![CDATA[
import mx.rpc.soap.WebService;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
private var ws:WebService;
public var resultStr:String;
public function loadList():void
{
ws = new mx.rpc.soap.WebService();
ws.destination = "https://secure.mojointeractive.com/Flex/Quote.cfc?wsdl";
ws.getToParseList.addEventListener("result", updateParseList);
ws.addEventListener("fault", faultHandler);
ws.loadWSDL();
ws.getToParseList();
}
private function updateParseList(event:ResultEvent):void
{
resultStr = event.result.echoStr;
txtTest.text = resultStr;
}
private function faultHandler(event:FaultEvent):void
{
txtTest.text = "Error: " + event.fault.faultString;
}
]]>
</mx:Script>
</mx:WindowedApplication>
[MessagingError message=‘Destination ‘https://secure.mojointeractive.com/Flex/Quote.cfc?wsdl’ either does not exist or the destination has no channels defined (and the application does not define any default channels.)’]
It’s kind of sad that it’s so hard to do such a simple task (1 line in ColdFusion as I showed above). Anyways, I finally made it work but I still don’t know how or why the other codes didn’t work. Anyways, here’s the working code in case someone else needs to do the same thing: