8 Replies Latest reply on Dec 10, 2007 1:37 PM by curtkauf

    Write Xml to local folder

    curtkauf
      I am returning an xml document from a .net web service and I can't seem to find the magic code to load this xml successfully into arrays that function the way I want them to. By the way that functionality is the same found in the Dashboard sample on line. So I'm using it in charts. The xml is well formed. But if I copy the xml into an xml file in my project directory I have no problem working with it. Is there a clean way to do this. Or is there a way to write a web service result to a file in the project directory? Please help! I've been working this for days now! Thanks so much for any help you can offer.

      Curt
        • 1. Re: Write Xml to local folder
          ntsiii Level 3
          No, you can't write to a local folder.

          "The xml is well formed. " How did you determine this? Where? You need to have a result handler in which you can examine (trace()) the XML in your result.

          With WebService, there are often namespace issues to deal with. Again, you need to trace the xml in the result handler.

          So first verify you are getting data, then verify the structure of that data.

          Also, you have not said what is not working.

          Tracy
          • 2. Re: Write Xml to local folder
            curtkauf Level 1
            Tracey,

            I am getting data. That is for sure. I have a results handler and I have traced it. "Well formed", I'm fairly confident it is. I will cut and past it below. This is somewhat complicated so bare with me. Also I am pretty confident that I am missing some broad concept here. But any way here is what it's doing:
            1) Calling the Webservice

            2) I trace the result it looks that same as it does over in my web service folder except that it has a line in it that the original doesn't have at the top: "<WE_DataSummaryResponse xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns:soap=" http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns=" http://tempuri.org/">"

            3) I load the result into a variable, _xmlResult = XML(oEvent.result);
            4) trace that and all looks well except I have a the same line of information at the top as I mentioned above.
            5) at this point I have tried numerous times to load this into an array or arraycollection and it won't and maybe it shouldn't, I don't know.
            6) I then put the XML into an XMLList and trace it:
            _xlDaysData = new XMLList(_xmlResult.WE_DataSummaryResult.WeeklySummary.Days);
            7) then it allows me to load this into and array. However, when I examine the array in the variable or watch windows they don't look the same as when I use a file in the local directory. Also I don't have to load it into xml first, then an xml list, then an array.

            Another thing, when I create an array from a child node of the original array, in the variable screen thee shows to be aXMList one node below the array and then it shows my child nodes as children of the xmllist and I can't seem to access then and the then of the array is always 1 because it has this one xmllist node.

            Here is the XML file from the local directory, copied directly off of the xml document that is passed from the web service.

            <?xml version="1.0" encoding="utf-8"?>
            <WeeklySummary>
            <Days ShipDate="9/28/2007 12:00:00 AM" Revenue="1222685.22" Average="150675.655000">
            <Services Service="LSCA" Shipments="218" Revenue="47282.72" Weight="299658" />
            <Services Service="DDD" Shipments="3106" Revenue="612732.30" Weight="5694310" />
            <Services Service="CNSD" Shipments="898" Revenue="195894.04" Weight="1650826" />
            <Services Service="FXCE" Shipments="208" Revenue="115753.72" Weight="443930" />
            <Services Service="SMTP" Shipments="52" Revenue="2303.76" Weight="15450" />
            <Services Service="USPS" Shipments="188" Revenue="46567.62" Weight="333222" />
            <Services Service="FXH3" Shipments="322" Revenue="27305.04" Weight="117464" />
            <Services Service="DTRL" Shipments="1662" Revenue="157566.04" Weight="401446" />
            </Days>
            <Days ShipDate="10/1/2007 12:00:00 AM" Revenue="699421.63" Average="85986.945000">
            <Services Service="DTRL" Shipments="934" Revenue="89959.46" Weight="242582" />
            <Services Service="SMTP" Shipments="52" Revenue="2303.76" Weight="15450" />
            <Services Service="USPS" Shipments="187" Revenue="46478.88" Weight="332797" />
            <Services Service="FXH3" Shipments="150" Revenue="13094.00" Weight="58021" />
            <Services Service="FXCE" Shipments="188" Revenue="108240.11" Weight="414492" />
            <Services Service="DDD" Shipments="1429" Revenue="286222.75" Weight="2592479" />
            <Services Service="CNSD" Shipments="471" Revenue="103507.56" Weight="867152" />
            <Services Service="LSCA" Shipments="179" Revenue="38089.04" Weight="233787" />
            </Days>
            <Days ShipDate="10/2/2007 12:00:00 AM" Revenue="688568.22" Average="84630.268750">
            <Services Service="FXH3" Shipments="137" Revenue="12073.99" Weight="53182" />
            <Services Service="LSCA" Shipments="132" Revenue="25313.62" Weight="157678" />
            <Services Service="SMTP" Shipments="19" Revenue="795.76" Weight="5159" />
            <Services Service="DTRL" Shipments="663" Revenue="67101.94" Weight="173447" />
            <Services Service="FXCE" Shipments="131" Revenue="71834.88" Weight="275646" />
            <Services Service="DDD" Shipments="1764" Revenue="347200.32" Weight="3201923" />
            <Services Service="CNSD" Shipments="508" Revenue="113474.09" Weight="943279" />
            <Services Service="USPS" Shipments="153" Revenue="39247.55" Weight="278518" />
            </Days>
            <Days ShipDate="10/3/2007 12:00:00 AM" Revenue="680280.70" Average="82996.777500">
            <Services Service="LSCA" Shipments="60" Revenue="10145.70" Weight="67908" />
            <Services Service="DTRL" Shipments="995" Revenue="100644.33" Weight="245213" />
            <Services Service="SMTP" Shipments="19" Revenue="795.76" Weight="5159" />
            <Services Service="DDD" Shipments="1702" Revenue="337875.05" Weight="3089493" />
            <Services Service="FXCE" Shipments="126" Revenue="64289.18" Weight="247876" />
            <Services Service="FXH3" Shipments="110" Revenue="9931.88" Weight="44754" />
            <Services Service="CNSD" Shipments="480" Revenue="106515.58" Weight="892291" />
            <Services Service="USPS" Shipments="136" Revenue="33776.74" Weight="239970" />
            </Days>
            <Days ShipDate="10/4/2007 12:00:00 AM" Revenue="595862.00" Average="72444.440000">
            <Services Service="DTRL" Shipments="823" Revenue="81621.57" Weight="210294" />
            <Services Service="FXH3" Shipments="98" Revenue="8832.68" Weight="37834" />
            <Services Service="SMTP" Shipments="4" Revenue="169.36" Weight="1257" />
            <Services Service="LSCA" Shipments="25" Revenue="1873.69" Weight="7346" />
            <Services Service="DDD" Shipments="1476" Revenue="293120.92" Weight="2739583" />
            <Services Service="FXCE" Shipments="94" Revenue="45066.24" Weight="178655" />
            <Services Service="CNSD" Shipments="516" Revenue="115094.32" Weight="964365" />
            <Services Service="USPS" Shipments="136" Revenue="33776.74" Weight="239970" />
            </Days>
            </WeeklySummary>


            Thank you Tracy!!!

            Curt
            • 3. Re: Write Xml to local folder
              ntsiii Level 3
              Ok, if you have your data, how do you want to use it?

              Specifically, why do you want it in an array, or arrayCollection?

              Tracy
              • 4. Re: Write Xml to local folder
                curtkauf Level 1
                Tracy,

                Sincerely, thanks a lot for your help. Ultimately I just need to be able to load that result that I sent you into an array that I can then slice and dice into other arrays. Like I said I have the app working perfectly from a local document of the exact same data.

                Look forward to hearing from you!

                Curt
                • 5. Re: Write Xml to local folder
                  curtkauf Level 1
                  OK, here is where my inexperience will come in. I'm just following examples that I have seen that use charts. As I said earlier in one of my posts I am largely mimicing the Dashboard application sample at Adobe, mine is a little simpler from a code stand point. I tried over and over again to just use the XML and XMLlist but didn't have any luck. So the answer to your question is, I want to populate three graphs and datagrids dynamically all from the xml data I get from the web service. Similar to the Dashboard app, when the user clicks an item in the first chart it then alters the second chart, and when you click the second chart it alters the third chart. I'm sure there is a better way.

                  By the way was my XML "Well Formed", I'm curious.

                  Thank You very much!

                  Curt
                  • 6. Re: Write Xml to local folder
                    curtkauf Level 1
                    Tracy,

                    Tell me if this is a good solution? What I have done is use an HTTPService to access the xml document in the virtual directory of the web service. It works perfectly. My question is, will this work with multiple people accessing the data....again I'm a beginner, so maybe that question gave you a good laugh. Please let me know! Thanks again!

                    Curt
                    • 7. Re: Write Xml to local folder
                      ntsiii Level 3
                      That should be fine, the web server will handle concurrent requests to view the same data without any trouble.

                      If you were changing the data then multi-user concurrency would be an issue.

                      Regarding using XMLList and XML, you wrote, "...tried over and over again ..." but that doesn't give me much to work with.
                      • 8. Re: Write Xml to local folder
                        curtkauf Level 1
                        Thanks for responding. Well the xml data will be written to the xml file after each request. In other words the user will enter a date parameter to get back all shipment data for that date. Now the user won't be editing, adding or deleting any data. just viewing based on a date parameter. Do you see any multi-user concurrency issues with this explained a little more in detail.

                        One last thing I am seeing. If I pass a date and receive back data, everything populates well. All charts dynamically change as I click on the specific items. If i change the date and run the web service again none of the charts change is this because I'm using an array rather then an ArrayCollection? Please let me know what you think this might be. This one scares me. Thanks

                        Curt