<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; result</title>
	<atom:link href="http://blog.flexexamples.com/tag/result/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Calling a simple web service from Flex using the WebService class</title>
		<link>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/</link>
		<comments>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/#comments</comments>
		<pubDate>Tue, 15 Apr 2008 06:40:24 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[WebService]]></category>
		<category><![CDATA[fault]]></category>
		<category><![CDATA[operation]]></category>
		<category><![CDATA[result]]></category>
		<category><![CDATA[send()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/</guid>
		<description><![CDATA[<p>The following example shows how you can call a ColdFusion Web Service from Flex using the &#60;mx:WebService /&#62; tag.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/source/main.mxml.html">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.utils.ObjectUtil; private var startTime:int; private var [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can call a ColdFusion Web Service from Flex using the &lt;mx:WebService /&gt; tag.</p>
<p>Full code after the jump.</p>
<p><span id="more-540"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.Alert;
            import mx.rpc.events.ResultEvent;
            import mx.rpc.events.FaultEvent;
            import mx.utils.ObjectUtil;

            private var startTime:int;
            private var endTime:int;

            private function button_click():void {
                webService.getMonths.send();
                startTime = getTimer();
                lbl.text = "";
            }

            private function getMonths_result(evt:ResultEvent):void {
                textArea.text = ObjectUtil.toString(evt.result);
                calcTime();
            }

            private function getMonths_fault(evt:FaultEvent):void {
                Alert.show(evt.type);
                calcTime();
            }

            private function calcTime():void {
                endTime = getTimer();
                lbl.text = "total time: " + (endTime - startTime) + "ms";
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:WebService id="webService"
            wsdl="http://www.flash-mx.com/ws/months.cfc?wsdl"&gt;
        &lt;mx:operation name="getMonths"
                resultFormat="object"
                result="getMonths_result(event);"
                fault="getMonths_fault(event);" /&gt;
    &lt;/mx:WebService&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Button id="button"
                label="get months from web service"
                click="button_click();" /&gt;
        &lt;mx:Spacer width="100%" /&gt;
        &lt;mx:Label id="lbl" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:TextArea id="textArea"
            editable="false"
            width="100%"
            height="100%" /&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/WebService_operation_send_test/bin/main.html" width="100%" height="300"></iframe></p>
<p>If you&#8217;re using ColdFusion, the months web service is as follows:</p>
<p class="download">months.cfc</p>
<pre class="code">
&lt;cfcomponent output="false"&gt;

    &lt;cffunction name="getMonths" access="remote" returntype="array" output="false"&gt;
        &lt;cfset var monthNames = ListToArray("January,February,March,April,May,June,July,August,September,October,November,December") /&gt;
        &lt;cfreturn monthNames /&gt;
    &lt;/cffunction&gt;

&lt;/cfcomponent&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Calling a simple web service from Flex using the WebService class on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/',contentID: 'post-540',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'fault,operation,result,send()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-webservice-class/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

