Flex调用WebServices

 

 

 

 

 

	
	[Bindable]
			public var arrayCol:ArrayCollection;
public function Test():void
			{
				  
				
				//*
				
				var webs:WebService=new WebService();
				webs.wsdl="http://localhost/Web/WebService1.asmx?WSDL";
				webs.loadWSDL();
				 webs.showBusyCursor=true;
				 
			 	// webs.addEventListener(LoadEvent.LOAD,load);
				 webs.addEventListener(ResultEvent.RESULT,WebsResult);
				  webs.addEventListener(FaultEvent.FAULT,webFault);
				 
				webs.GetProData();
		 
				
				//*/
			 
				
			}
			
			public function webFault(event:FaultEvent):void
			{
				Alert.show(event.toString());
			}
			
			public	function  WebsResult(Result:ResultEvent):void
			{
				 arrayCol =Result.result as ArrayCollection;
			}
 
	<mx:AdvancedDataGrid id="adg1"
						 designViewDataType="tree" editable="true"
						 dataProvider="{arrayCol}">
		<mx:columns>
			<mx:AdvancedDataGridColumn headerText="CustomerID"
									   dataField="CustomerID"/>
			<mx:AdvancedDataGridColumn headerText="ShipName"
				   editable="false"
									   dataField="ShipName"/>
			<mx:AdvancedDataGridColumn headerText="Freight"
									       itemEditor="mx.controls.NumericStepper"  
									   dataField="Freight"/>
		</mx:columns>
	</mx:AdvancedDataGrid>
	 <mx:Button  label="testWeb" click="Test()"></mx:Button>
 

你可能感兴趣的:(Web,webservice,Flex)