1 Reply Latest reply on Apr 26, 2007 5:32 AM by Jokula007

    Querying SQL Server via HTPService

    Jokula007 Level 1
      Below is a copy of the code I am using. This code is used by other developers, and it works. The XML returned by the HTTPService request won't cast into an array. Any help would be greatly appreciated
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="initApp()">

      <mx:Script>
      <![CDATA[
      import mx.utils.XMLNotifier;
      import mx.utils.ArrayUtil;
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;
      import mx.utils.ObjectUtil;
      import mx.utils.XMLUtil;

      [Bindable]
      public var feedArray:Array = new Array();


      public function initApp():void
      {
      // Alert.show(String(Security.sandboxType));
      feedRequest.send();
      }

      public function handleFeedRequest(event:ResultEvent):void {

      if (event.result != null) {
      Alert.show(ObjectUtil.toString(event.result));
      feedArray = event.result.Customers.row.source as Array;
      trace(feedArray);

      }
      }

      ]]>
      </mx:Script>


      <mx:HTTPService
      id="feedRequest"
      url=" http://Localhost/MobileData"
      resultFormat="e4x"
      result="handleFeedRequest(event)"
      useProxy="false">
      <mx:request>
      <root>Customers</root>
      <SQL>exec sp_GetExplicitXML</SQL>
      </mx:request>

      </mx:HTTPService>

      <mx:Panel x="28" y="10" width="451" height="200" layout="absolute">
      <mx:DataGrid x="10" y="4" width="411" id="dGrid" height="146"
      dataProvider="{feedArray}">
      <mx:columns>
      <mx:DataGridColumn dataField="partner" headerText="Parnter"/>
      <mx:DataGridColumn dataField="name1" headerText="Name"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Panel>

      </mx:Application>
        • 1. Re: Querying SQL Server via HTPService
          Jokula007 Level 1
          I'm including the XML Output the httpService Request

          <Customers>
          <row Partner="0070009676" Name1="xxxxxxxxx"/>
          <row Partner="0074000109" Name1="xxxxxxxxx"/>
          <row Partner="0070016639" Name1="xxxxxxxxxx"/>
          <row Partner="0070013836" Name1="xxxxxxxxxxx"/>
          <row Partner="0070006135" Name1="xxxxxxxxxxx"/>
          <row Partner="0070001209" Name1="xxxxxxxxxxx"/>
          <row Partner="0070009163" Name1="xxxxxxxxxxx"/>
          <row Partner="0079999715" Name1="xxxxxxxxxxx"/>
          <row Partner="0079994715" Name1="xxxxxxxxxxx"/>
          <row Partner="0074000681" Name1="xxxxxxxxxxx"/>
          <row Partner="0074000490" Name1="xxxxxxxxxxx"/>
          <row Partner="0074000567" Name1="xxxxxxxxxxx"/>
          <row Partner="0070001669" Name1="xxxxxxxxxxx"/>
          <row Partner="0033000003" Name1="xxxxxxxxxxx"/>
          <row Partner="0079930374" Name1="xxxxxxxxxxx"/>
          <row Partner="0033000002" Name1="xxxxxxxxxxx"/>
          <row Partner="0033000001" Name1="xxxxxxxxxxx"/>
          <row Partner="0033000004" Name1="xxxxxxxxxxx"/>
          <row Partner="0033000005" Name1="xxxxxxxxxxx"/>
          <row Partner="0074000647" Name1="xxxxxxxxxxx"/>
          <row Partner="0079930366" Name1="xxxxxxxxxxx"/>
          </Customers>