12 Replies Latest reply on Dec 18, 2006 3:45 PM by mswendener

    Flex2 Newbee Help

    SD_Sr.ISA

      I have been trying to populate a combo box from a HTTPservice bound to an .asp file, it works great for a list box, this has given me a bad beating! I will purchase Flex as soon as this is resolved. Here is some code starting with the .asp. Thanks in advance for the help.....

      Note: I can make it work with a .xml file!

      james.cox@us.schneider-electric.com

      ***ASP File
      <%
      On Error Resume Next
      Set objDO_Prod = CreateObject("myTools.PopArray")
      objDO_Prod.Return_Records = True
      objDO_Prod.Max_Allowable_Records = 1000
      objDO_Prod.Include_Field_Names = False
      objDO_Prod.Conn_String = "Driver={SYBASE SYSTEM11};Srvr=mlndb02;Uid=wu;Pwd=web_user;Database=warehouse"

      sql = " SELECT *"
      sql = sql & " FROM t_employee"
      sql = sql & " ORDER BY f_last"
      objDO_Prod.SQL_Statment = sql
      SqlArray = objDO_Prod.ExecuteSQL
      If objDO_Prod.Status = True Then
      'build xml
      mxmlStr = "<users>"
      For i = 1 to UBound(SqlArray, 2)
      mxmlStr = mxmlStr & "<user><userid>" & SqlArray(1,i) & "</userid><username>" & SqlArray(3,i) & "</username><emailaddress>" & SqlArray(23,i) & "</emailaddress></user>" & vbcrlf
      Next
      mxmlStr = mxmlStr & "</users>"
      Response.Write(mxmlStr)
      End If
      %>

      ***MX File

      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      xmlns="*"
      initialize="simpleHTS.send()"
      creationComplete="createEmplist()">
      <mx:HTTPService
      id="simpleHTS"
      url="List_Emp6.asp"
      useProxy="false"
      method="POST"
      resultFormat="object">
      </mx:HTTPService>
      <mx:HBox>
      <mx:ComboBox id="country" dataProvider="{emps}"/>
      </mx:HBox>
      <mx:Script>
      <![CDATA[
      import mx.utils.ArrayUtil;
      import mx.collections.ArrayCollection;
      [Bindable]
      var emps:ArrayCollection;

      function createEmplist()
      {
      emps = ArrayCollection(simpleHTS.lastResult.users.user.userid);
      }
      ]]>
      </mx:Script>
      </mx:Application>
        • 1. Re: Flex2 Newbee Help
          nated
          If you edit the line in your createEmplist() function from :
          emps = ArrayCollection(simpleHTS.lastResult.users.user.userid);

          TO:
          emps = ArrayCollection(simpleHTS.lastResult.users.user);

          That should fix your problem. But, if your database only has one user, try adding another user first - for some reason, if there's only one item in the list, it won't convert it to an ArrayCollection either. An easier way may be to just make your emps variable an Array, since a combo box can still use an Array as it's dataprovider. Then use ArrayUtil.toArray() instead of ArrayCollection() in your createEmplist() function.
          Hope this helps!
          • 2. Re: Flex2 Newbee Help
            SD_Sr.ISA Level 1
            Thanks You but no luck, same error, how would the combo know which of the 3 fields to use?
            Note in the asp 'build xml portion needs review
            • 3. Re: Flex2 Newbee Help
              leotemp Level 1
              You dont need to convert your output to an array to use it in a combobox, If you would, please post the output of the asp file (the xml rendered by it) or at least a sample large enough to examine
              • 4. Re: Flex2 Newbee Help
                SD_Sr.ISA Level 1
                <******************** .asp output

                10005935Aguilar 10002493AinslieWayne.Ainslie@us.schneider-electric.com 10004844Albertson 10004671Aldrup 10001691AllesBrenda.Alles@us.schneider-electric.com 10002049AllesDoug.Alles@us.schneider-electric.com 10003279Anderson 10003487Anderson 10011747Anderson 10005575Anderson 10003520Appling 10043232Augustin 10015847BaconJoseph.Bacon@us.schneider-electric.com 10004718Bailey 10002092Baker 10003121Balderson 10002787Barney 10003684Bartek 10002226BealsMike.Beals@us.schneider-electric.com 10005945BenesAlan.Benes@us.schneider-electric.com 10001799Bergmeier 10002818Bietz 10001823Blecha 10001747Bloebaum 10041828Bloomquist 10005553Bogle 10001489Boller 10004619Borgmann 10002757Borgmann 10014152BorlandTodd.Borland@us.schneider-electric.com 10004915BougesJan.Bouges@us.schneider-electric.com 10009981BowersPatrick.Bowers@us.schneider-electric.com 10004731Branting 10015168BrantingShannon.Branting@us.schneider-electric.com 10001486Brethouwer 10004026Brethouwer 10004252Brethouwer 10004085Bristol 10005522Brooks 10001462Brown 10004702Brown 10004071BrozekDennis.Brozek@us.schneider-electric.com 10003366BrunkowMike.Brunkow@us.schneider-electric.com 10004040Buhr 10001905Burbach 10002296BuresDave.Bures@us.schneider-electric.com


                <******** asp source
                <users><user><userid>10005935</userid><username>Aguilar</username><emailaddress> </emailaddress></user>
                <user><userid>10002493</userid><username>Ainslie</username><emailaddress>Wayne.Ainslie@us. schneider-electric.com</emailaddress></user>
                <user><userid>10004844</userid><username>Albertson</username><emailaddress> </emailaddress></user>
                <user><userid>10004671</userid><username>Aldrup</username><emailaddress> </emailaddress></user>
                <user><userid>10001691</userid><username>Alles</username><emailaddress>Brenda.Alles@us.sch neider-electric.com</emailaddress></user>
                <user><userid>10002049</userid><username>Alles</username><emailaddress>Doug.Alles@us.schne ider-electric.com</emailaddress></user>
                <user><userid>10003279</userid><username>Anderson</username><emailaddress> </emailaddress></user>
                <user><userid>10003487</userid><username>Anderson</username><emailaddress> </emailaddress></user>
                <user><userid>10011747</userid><username>Anderson</username><emailaddress> </emailaddress></user>
                </users>
                • 5. Re: Flex2 Newbee Help
                  leotemp Level 1
                  Try this, I just kinda whiped it out so if it doesnt work double check my spelling and such, should be more of a concept example. I think one of the hardest things about being new to flex is understanding how much of the work it does for you if you let it. Also, if you want to trigger a function for your data in a HTTPservice, its best to use the HTTPservice's "result" property all though in this example i dont think its needed..

                  EXAMPLE:
                  <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="{simpleHTS.send()}">

                  <mx:HTTPService id="simpleHTS" url="List_Emp6.asp" method="POST"/>

                  <mx:ComboBox id="country" dataProvider="{this.simpleHTS.lastResult.users.user}" labelField="username"/>

                  </mx:Application>
                  • 6. Re: Flex2 Newbee Help
                    SD_Sr.ISA Level 1
                    <*** No luck here is the error
                    [RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
                    at mx.rpc.http::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::processResult()
                    at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
                    at mx.rpc::Responder/result()
                    at mx.rpc::AsyncRequest/acknowledge()
                    at ::DirectHTTPMessageResponder/completeHandler()
                    at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                    at flash.events::EventDispatcher/dispatchEvent()
                    at flash.net::URLLoader/flash.net:URLLoader::onComplete()

                    • 7. Re: Flex2 Newbee Help
                      leotemp Level 1
                      your xml is malformed, at least thats what that error means, double check that all your xml tags are matched with a indentical closing tag. Your example output looks fine so im not sure about that, 9 times out of 10 the issue is in the output not the flex. Try encapsulating you data in cdata like this <![CDATA[ ]]>
                      example:
                      <xmlTag><![CDATA[YOUR_DATA_HERE]]></xmlTag>
                      • 8. Re: Flex2 Newbee Help
                        SD_Sr.ISA Level 1
                        Do you mean put this in the asp script so it shows up when I view source of the page?
                        • 9. Re: Flex2 Newbee Help
                          SD_Sr.ISA Level 1
                          <** view source now looks like this
                          <users><user><userid><![CDATA[10005935]]></userid><username><![CDATA[Aguilar]]></username> <emailaddress><![CDATA[ ]]></emailaddress></user>
                          <user><userid><![CDATA[10002493]]></userid><username><![CDATA[Ainslie]]></username><emaila ddress><![CDATA[Wayne.Ainslie@us.schneider-electric.com]]></emailaddress></user>
                          <user><userid><![CDATA[10004844]]></userid><username><![CDATA[Albertson]]></username><emai laddress><![CDATA[ ]]></emailaddress></user>
                          <user><userid><![CDATA[10004671]]></userid><username><![CDATA[Aldrup]]></username><emailad dress><![CDATA[ ]]></emailaddress></user>
                          <user><userid><![CDATA[10001691]]></userid><username><![CDATA[Alles]]></username><emailadd ress><![CDATA[Brenda.Alles@us.schneider-electric.com]]></emailaddress></user>

                          No direct output from page?

                          ???????????

                          • 10. Re: Flex2 Newbee Help
                            SD_Sr.ISA Level 1
                            This if correct, resaulted in the same error.
                            • 11. Re: Flex2 Newbee Help
                              mswendener
                              I Too am having the same issue with my Flex app pulling Data from ASP...?? I dump my ASP output to a xml file and hard code that file into flex and it Works... but Dynamically it it Fails with the Following Message:

                              [RPC Fault faultString="Error #1090: XML parser failure: element is malformed." faultCode="Client.CouldNotDecode" faultDetail="null"]
                              at mx.rpc.http::HTTPService/ http://www.adobe.com/2006/flex/mx/internal::processResult()
                              at mx.rpc::AbstractInvoker/ http://www.adobe.com/2006/flex/mx/internal::resultHandler()
                              at mx.rpc::Responder/result()
                              at mx.rpc::AsyncRequest/acknowledge()
                              at ::DirectHTTPMessageResponder/completeHandler()
                              at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
                              at flash.events::EventDispatcher/dispatchEvent()
                              at flash.net::URLLoader/flash.net:URLLoader::onComplete()

                              As a noted above and on Other Boards the formating of the XML response it most likely the cause... Could Flex be truncating or not waiting long enough for the responsefrom ASP...???

                              Why would the same info work if static and fail in a HTTPrequest ??

                              Thanks
                              • 12. Re: Flex2 Newbee Help
                                mswendener Level 1
                                I was able to narrow down the problem to ASP... but not the code... the webserver itself. it was not correctly running asp pages. ofter reinstalling the .net framework the error went away.
                                to Reinstall .net framework. run the following comands:
                                "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" -i
                                "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe" -r


                                That corrected my problem with the above script.