1 Reply Latest reply on May 1, 2009 2:36 PM by emiliovick

    Update on Flex Consuming Web Service by ASP.NET


      Good evening to the community,


      I finally identified what was the error that explote the data transfer, Now Not show the message error.


      What does is load the Datagrid but the data never loads.


      If somebody can view the code and help me on identify the possible reason its going to be very appreciated




      Flex Code:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
          backgroundGradientColors="[0xFFFFFF, 0xFFFFFF]">



                      import mx.controls.Alert;
                      import mx.rpc.events.FaultEvent;
                      import mx.rpc.events.ResultEvent;
                      import mx.rpc.soap.mxml.WebService;
                      import mx.managers.CursorManager;

                      * @bindable
                      * @private
                      * @property Will hold the data passed from the web service.
                      private var _xmlData:XML;

                      * @private
                      * Connects and calls the getPlayers() method from our web service.
                      private function clickHandler(event:MouseEvent):void
                          event.target.enabled = false;

                          var service:WebService = new WebService();
                          service.addEventListener(ResultEvent.RESULT, serviceResultHandler);
                          service.addEventListener(FaultEvent.FAULT, serviceFaultHandler);

                      * @private
                      * Stores the loaded data in an XML object and displays the DataGrid.
                      private function serviceResultHandler(event:ResultEvent):void
                          _xmlData = XML(event.result);
                          this.dataGrid.visible = true;

                      * @private
                      * Displays any possible errors that might occur when
                      * trying to connect to our web service.
                      private function serviceFaultHandler(event:FaultEvent):void
                          Alert.show(String(event.fault), "Error");
                          this.loadBtn.enabled = true;


              <mx:VBox horizontalCenter="0" verticalCenter="0"
                     horizontalScrollPolicy="off" verticalScrollPolicy="off">

                     <mx:Button id="loadBtn" label="Load/Display Data" width="700"
                     <mx:DataGrid id="dataGrid" width="100%" height="200"
                         visible="false" dataProvider="{_xmlData.*}">
                             <mx:DataGridColumn headerText="ID"
                                 dataField="emp_num" width="30"/>
                             <mx:DataGridColumn headerText="Name"
                                 dataField="strstore_id" width="120"/>
                             <mx:DataGridColumn headerText="Score"
                                 dataField="strvoucher_id" width="70"/>





      <%@ WebService Language="VB" Class="placesService2" %>


      Imports System.Web
      Imports System.Web.Services
      Imports System.Web.Services.Protocols
      Imports System.Data
      Imports System.Data.SqlClient


      <WebService(Namespace:="http://placespr.com/")> _
      <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
      Public Class placesService2
          Inherits System.Web.Services.WebService
          Public Class TitleInfo
              Public strTitleName As String
              Public strstore_id As String
              Public strvoucher_id As String
          End Class
          <WebMethod()> _
         Public Function GetTitleData() As TitleInfo()


                  'create dataset
                  Dim dsTitleData As New DataSet


                  'create connection
                  Dim objCon As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("dsn").ConnectionString)
                  'create data adapter
                  Dim cmdSQL As SqlDataAdapter = New SqlDataAdapter("SELECT emp_num, store_id, voucher_id FROM voucher", objCon)
                  'fill dataset using data adapter
                  cmdSQL.Fill(dsTitleData, "emp_num")


                  'create object array, using row count as upper dim
                  Dim objTitles As TitleInfo() = New TitleInfo(dsTitleData.Tables(0).Rows.Count - 1) {}


                  'loop through dataset to add data to object array
                  Dim intRsCount As Int16
                  For intRsCount = 0 To dsTitleData.Tables(0).Rows.Count - 1
                      objTitles(intRsCount) = New TitleInfo
                      objTitles(intRsCount).strTitleName = dsTitleData.Tables(0).Rows(intRsCount)("emp_num")
                      objTitles(intRsCount).strstore_id = dsTitleData.Tables(0).Rows(intRsCount)("store_id")
                      objTitles(intRsCount).strvoucher_id = dsTitleData.Tables(0).Rows(intRsCount)("voucher_id")


                  'return object array
                  Return objTitles


              Catch exp As Exception
              End Try


          End Function


      End Class