1 Reply Latest reply on Oct 22, 2008 2:50 PM by PinkVirgo

    populating datagrid using web service. pls help me...

    PinkVirgo
      i don't know why i cant populate my data grid using data on a web service, i try to access web service by a simple return string like helloworld and it is working but when i try to get data in web service nothing happens there is no error on my builder and web page, but it dont display the data.. bellow is my web service and code. pls help i need this to work.. thanks..

      <DataTable>

      <xs:schema id="NewDataSet">

      <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Customer" msdata:UseCurrentLocale="true">

      <xs:complexType>

      <xs:choice minOccurs="0" maxOccurs="unbounded">

      <xs:element name="Customer">

      <xs:complexType>

      <xs:sequence>
      <xs:element name="num" type="xs:string" minOccurs="0"/>
      <xs:element name="name" type="xs:string" minOccurs="0"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      </xs:choice>
      </xs:complexType>
      </xs:element>
      </xs:schema>

      <diffgr:diffgram>

      <DocumentElement>

      <Customer diffgr:id="Customer1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
      <num>1</num>
      <name>String1</name>
      </Customer>

      <Customer diffgr:id="Customer2" msdata:rowOrder="1" diffgr:hasChanges="inserted">
      <num>2</num>
      <name>String2</name>
      </Customer>

      <Customer diffgr:id="Customer3" msdata:rowOrder="2" diffgr:hasChanges="inserted">
      <num>3</num>
      <name>String3</name>
      </Customer>
      </DocumentElement>
      </diffgr:diffgram>
      </DataTable>


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      [Bindable] private var ArrayData:ArrayCollection;
      private function getString(event:ResultEvent):void{
      Alert.show(event.result.toString());
      }
      private function getStringError(event:FaultEvent):void{
      Alert.show("Error");
      }
      private function button_click():void{
      Test.HelloWorld.send();
      }
      private function getData(event:ResultEvent):void{
      grid.dataProvider = event.result.diffgram.DocumentElement.Customer;
      }
      private function getDataError(event:FaultEvent):void{
      Alert.show("Error");
      }
      private function button1_click():void{
      Test.getData.send();
      }
      ]]>
      </mx:Script>
      <mx:WebService id="Test" wsdl=" http://localhost/HawkWeb/Hawkeye.asmx?wsdl">
      <mx:operation name="HelloWorld" result="getString(event)" fault="getStringError(event)" />
      <mx:operation name="getData" result="getData(event)" fault="getDataError(event)" />
      </mx:WebService>
      <mx:Button x="10" y="10" label="Get String" click="button_click()"/>
      <mx:Button x="10" y="40" label="Get Data" width="83" click="button1_click()"/>
      <mx:DataGrid id="grid" x="10" y="70" width="501">
      <mx:columns>
      <mx:DataGridColumn headerText="Num" dataField="col1"/>
      <mx:DataGridColumn headerText="Name" dataField="col2"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>