Problem with Flex and .net Web service

I need to pass 3 queryString parameters (via Url) to the Flex generated page.
Flex page (swf - flash file) needs to send it to .net web service in the background - which will then post back data based on parameters.

Im not good at Flex, I created web service and its working fine, but I have trouble sending parameters from Flex.

amaimediaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

julianopolitoCommented:
send your code , I'll take a look for you. Here is an example:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
	layout="vertical" 
	verticalAlign="middle"
	creationComplete="initApp()">
	<mx:Script>
		<![CDATA[
 
			import mx.controls.Alert;
			import mx.collections.ArrayCollection;
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			
			[Bindable]
			private var contatos:ArrayCollection;
			
			private function initApp():void{
				//Here is the call to the webservice method
				agendaService.GetByNames("param1","param2","param3");
			}
			private function resultHandler(e:ResultEvent):void{
				if(e.result is ArrayCollection){
					contatos = e.result as ArrayCollection;
				}
			}
			private function faultHandler(e:FaultEvent):void{
				Alert.show(e.fault.faultCode,e.fault.faultString);
			}
		]]>
	</mx:Script>
	
	<mx:WebService id="agendaService"
		wsdl="http://localhost:8082/WebService/Service.asmx?WSDL"
		showBusyCursor="true"
		result="resultHandler(event)"
		fault="faultHandler(event)">		
	</mx:WebService>
</mx:Application>

Open in new window

0
amaimediaAuthor Commented:
Ok, here it is:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
	backgroundColor="#eeeeee" creationComplete="initVars()">
	
	    <mx:Script><![CDATA[
	    	import mx.rpc.events.ResultEvent;
			import com.imedia.QueryString;
			import mx.collections.ArrayCollection;
 
        // Declare bindable properties in Application scope.
        [Bindable]
        public var sym:String;
        [Bindable]
        public var dtS:String;
        [Bindable]
        public var dtE:String;
        [Bindable]
        private var myData:ArrayCollection;
        
        
	private var qs:QueryString;
 
        // Assign values to new properties.
        private function initVars():void {
	   qs = new QueryString();
	   trace(qs.url);
        }
   
       	private function dataHandler(event:ResultEvent):void
	   {
	   		myData = event.result.diffgram.NewDataSet.Table;
	   }
	   
    ]]></mx:Script>
	
	<mx:WebService id="serviceOne"
	wsdl="http://www.stockwatch.ws/srvcs/flexServ.asmx?WSDL" 
	showBusyCursor="true">
	<mx:operation name="returnSymbol" result="dataHandler(event)"/>
	</mx:WebService>
	
	<mx:VBox>
    <mx:HBox>
    	<mx:DataGrid dataProvider="{myData}"/>
    </mx:HBox>
    <mx:HBox>
    	<mx:Button label="get it" click="serviceOne.returnSymbol(sym,dtS,dtE)"/>
    </mx:HBox>
    </mx:VBox>
 
</mx:Application>

Open in new window

0
amaimediaAuthor Commented:
I have also class named QueryString in package com.imedia - here is code:
package com.imedia 
{
	import flash.external.*;
	import flash.utils.*;
 
	public class QueryString 
	{
 
		private var _queryString:String;
		private var _all:String;
		private var _params:Object;
		
		public function get queryString():String
		{
			return _queryString;
		}
		public function get url():String
		{
			return _all;
		}
		public function get parameters():Object
		{
			return _params;
		}		
 
		
		public function QueryString()
		{
		
			readQueryString();
		}
 
		private function readQueryString():void
		{
			_params = {};
			try 
			{
				_all =  ExternalInterface.call("window.location.href.toString");
				_queryString = ExternalInterface.call("window.location.search.substring", 1);
				if(_queryString)
				{
				
					var params:Array = _queryString.split('&');
					var length:uint = params.length;
					
					for (var i:uint=0,index:int=-1; i<length; i++) 
					{
						var kvPair:String = params[i];
						if((index = kvPair.indexOf("=")) > 0)
						{
							var key:String = kvPair.substring(0,index);
							var value:String = kvPair.substring(index+1);
							_params[key] = value;
						}
					}
				}
			}catch(e:Error) { trace("Some error occured. ExternalInterface doesn't work in Standalone player."); }
		}
 
	}
}

Open in new window

0
MSSPs - Are you paying too much?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

julianopolitoCommented:
you can also use this format to specify parameters:


<mx:WebService>
		<mx:operation>
			<mx:request xmlns="">
				<param1>
					{param1}
				</param1>
				<param2>
					{param2}
				</param2>
			</mx:request>
		</mx:operation>
	</mx:WebService>

Open in new window

0
julianopolitoCommented:
let me see if I understand it better. I re-read your post and got some new info here. I'll rephrase and you tell me if I'm right.

You need to learn how to get parameters that come from the url into flex, use those as parameters for the webservice call, is that correct? Can you zip and send me all the files, including html where you publish the swf?

Anyway, reading your code again, I just saw that you already get the url string and it's parameters, and you just need to put them into the method call?


see if that is what you need. if not, send me the code and re explain that to me please.




// Declare bindable properties in Application scope.
        [Bindable]
        public var sym:String;
        [Bindable]
        public var dtS:String;
        [Bindable]
        public var dtE:String;
        [Bindable]
        private var myData:ArrayCollection;
        
        
	private var qs:QueryString;
 
        // Assign values to new properties.
        private function initVars():void {
	   qs = new QueryString();
            // set the bindable variables with the url parameters
            // so when you call serviceOne.returnSymbol(sym,dtS,dtE)
            // it will work
	   sym = qs.parameters.sym
            dtS = qs.parameters.dtS;
            dtE = qs.parameters.dtE;
        }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
amaimediaAuthor Commented:
Yes, that was it. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Flex

From novice to tech pro — start learning today.