Welcome, Guest. Please login or register.
Did you miss your activation email?
31 Jul 2010, 11:28:01 UTC
Forum home
+  flexdeveloper.eu Forum
|-+  Flex and ActionScript 3.0
| |-+  Flex 3 Framework (Moderators: JMWhittaker, Jan K, thewarpedcoder, James)
| | |-+  XML Handling in Flex
« previous next »
Pages: [1] Print
Author Topic: XML Handling in Flex (Read 30511 times)
Ragu
Guest
« on: 18 Sep 2006, 15:50:49 UTC »

Hi
i want to create XML file in Flex and load the data into file (data coming from web service), and also loads into UI from XML file.
Thanks in advance.

Soultion in MXML and ActionScript.



Logged
flexy
Guest
« Reply #1 on: 18 Sep 2006, 16:49:31 UTC »

There is already quite a lot of information on here about loading XML and web services in Flex. Elsa's post on Different ways to handle XML data is particularly useful.

Can I ask why you wouldn't want to directly consume the web service using the WebService class? It's pretty straightforward if you already have a WSDL that describes your service, and its methods. There's  more info about web services in Flex 2 here
« Last Edit: 21 May 2008, 10:35:07 UTC by flexy » Logged
Ragu
Guest
« Reply #2 on: 18 Sep 2006, 17:16:38 UTC »

To avoid hitting WSDL for each request. For the first request ,collect data from Web service and then load into new XML file.

So i am trying to load the data from web service into XML, then read from XML.

Thanks
Logged
flexy
Guest
« Reply #3 on: 18 Sep 2006, 17:32:05 UTC »

If I'm right, Flex *should* cache your WDSL call. Also, avoid recreating your WebService object on each call, that way, the WSDL definition will remain intact on the service object, and won't get called repeatedly.

Rather than using a web service, could you not expose your data as XML in the first instance, i.e. a .NET page that reads from a database (or parses the data from your web service) and prints out XML. You could then call this in Flex using HTTPService.

I'm personally of the opinion that a call to a WSDL, creation of as XML file, then a load of the XML is a long-winded way of achieving your goal. It does, however, depend on whether you're wanting to call multiple methods on the same service for different routines.
« Last Edit: 21 May 2008, 10:39:56 UTC by flexy » Logged
Ragu
Guest
« Reply #4 on: 18 Sep 2006, 17:49:03 UTC »

Thanks lot.

i implemented directly to WSDL and populate it into UI. My managers said that try in XML.

Could you please tell me, how to load data(from web service) into ArrayCollections and loading that data into Datagrid.

Thanks

Sample Data from WebService:

Code:
SOAP Body
{
getCoreProgrammingResponse
{
CoreProgrammingResponse
{
CoreProgramming
{
string   DisplayCategory  =  America's Top Packages
BasicProgramming
{
int   ProductId  =  10049
string   ProgrammingName  =  America's Top 60
float   Price  =  29.99
boolean   IncludesLocals  =  false
boolean   IncludesRSN  =  false
Listing
{
string   CategoryName  =  WOMEN'S PROG.
Station
{
string   StationCallLetters  =  TLC
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  DISC
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  FOOD
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  TRAV
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  HIST
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  HGTV
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  HGTV
boolean   Hdflag  =  false
}
}
}
BasicProgramming
{
int   ProductId  =  10041
string   ProgrammingName  =  America's Top 120
float   Price  =  39.99
boolean   IncludesLocals  =  false
boolean   IncludesRSN  =  true
Listing
{
string   CategoryName  =  WOMEN'S PROG.
Station
{
string   StationCallLetters  =  TLC
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  DHLTH
boolean   Hdflag  =  false
}
Station
{
string   StationCallLetters  =  DISC
boolean   Hdflag  =  false
}
}
}
and going on.
« Last Edit: 20 Sep 2006, 18:24:26 UTC by Nirth » Logged
flexy
Guest
« Reply #5 on: 18 Sep 2006, 18:09:18 UTC »

You probably want to try something like this, though it will depend heavily on what operations you're requesting. Have a look at the LiveDocs section on web services


Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="wsBlogAggr.send()">
      <mx:WebService id="wsBlogAggr"
    wsdl="http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl"
    useProxy="false">
</mx:WebService>
<mx:Script>
      <![CDATA[
                        [Bindable] private var myArrayCollection:ArrayCollection = new ArrayCollection(wsBlogAggr.lastResult);
            
            
      ]]>
</mx:Script>
      
<mx:DataGrid dataProvider="{myArrayCollection}"/>
</mx:Application>
Logged
Ragu
Guest
« Reply #6 on: 18 Sep 2006, 19:51:23 UTC »

Thanks,i tried but no data populated in data grid.

Code:
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
      <mx:WebService id="myService" destination="pricerws"
    wsdl="http://mer1d3w8c451:9001/wscreateapiv2/wscreateapiv2.jws?WSDL"
    useProxy="true">
     <mx:operation name="getCoreProgramming">
                  <mx:request>
                        <CoreProgrammingRequest>
                              <PromotionId>
                                    {leaseowngroup.selectedValue}
                              </PromotionId>
                        </CoreProgrammingRequest>
                  </mx:request>
            </mx:operation>
</mx:WebService>
<mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;
      import mx.controls.Alert;
            import  mx.events.ItemClickEvent;
                        [Bindable]
                         //private var myArrayCollection:ArrayCollection = new ArrayCollection(myService.getCoreProgramming.lastResult);
                        private var myArrayCollection:ArrayCollection;     

                  public function sendpromotionid(event:ItemClickEvent):void
                  {
                        Alert.show("The Promotion Id:"+leaseowngroup.selectedValue);
                        myService.getCoreProgramming.send();
                        myArrayCollection = new ArrayCollection(myService.getCoreProgramming.lastResult);
                  }     
           
      ]]>
</mx:Script>
            <mx:Label x="0" y="0" text="Do you want to lease or own your equipment" fontSize="11" fontWeight="bold" width="323"/>
            <mx:RadioButtonGroup  id="leaseowngroup" itemClick="sendpromotionid(event)" />
            <mx:RadioButton x="64" y="27" label="Lease" id="lease_radio" groupName="leaseowngroup" value="101800"/>
            <mx:RadioButton x="139" y="27" label="Own" id="own_radio" groupName="leaseowngroup" value="100400"/>
     
<mx:DataGrid dataProvider="{myArrayCollection}" y="63"/>
</mx:Application>
« Last Edit: 21 May 2008, 10:34:20 UTC by flexy » Logged
Elsa
Guest
« Reply #7 on: 18 Sep 2006, 21:10:19 UTC »

If the data is complex you may need to use some functions to pull it out:

Complex XML and Datagrids
« Last Edit: 14 Aug 2007, 16:09:29 UTC by flexy » Logged
flexy
Guest
« Reply #8 on: 18 Sep 2006, 21:34:31 UTC »

The problem to me seem to be with your WSDL

Quote
[RPC Fault faultString="HTTP request error" faultCode="Server.Error.Request" faultDetail="Unable to load WSDL. If currently online, please verify the URI and/or format of the WSDL (http://mer1d3w8c451:9001/wscreateapiv2/wscreateapiv2.jws?WSDL)"]

Flex can't seem to find it. Without the reference to your WSDL, it works fine, so I'd make sure it's a) online and b) in a format that Flex can understand.
« Last Edit: 27 Sep 2008, 17:04:37 UTC by flexy » Logged
Ragu
Guest
« Reply #9 on: 18 Sep 2006, 22:15:58 UTC »

i am accessing other methods of wsdl and getting response from it. For accessing wsdl, we passed username/passwd.


could you pls load sample XML file and MXML code(reading that XML file contents)
i wil get clear idea on it.

Thanks.
Logged
flexy
Guest
« Reply #10 on: 19 Sep 2006, 07:18:31 UTC »

I'm sorry, you're going to need to be a bit more concise about what the problem is; people here aren't understanding!  :-/
Logged
Ragu
Guest
« Reply #11 on: 19 Sep 2006, 14:42:23 UTC »

Ok.I want to read XML file contents in Flex(MXML).

Thanks
Logged
flexy
Guest
« Reply #12 on: 19 Sep 2006, 15:20:00 UTC »

Use HTTPService to load your XML, you can then bind yourHTTPServiceID.lastResult to a datagrid's dataProvider.
Logged
Ragu
Guest
« Reply #13 on: 19 Sep 2006, 15:22:58 UTC »

Thanks Lot. I got it. I implemented working fine.
Great.
Thanking you.
Logged
Ragu
Guest
« Reply #14 on: 19 Sep 2006, 15:28:04 UTC »

Hi One more Query.

I want to create XML file in Flex and write the data into XML file.
The data coming from web service.

Thanks in advance.
Logged
flexy
Guest
« Reply #15 on: 19 Sep 2006, 17:43:26 UTC »

I think you're misunderstanding the Flex application model. Flex is a client-side technology, the Flex 'movie' is downloaded in it's entirety, and run in Flash Player locally, not on the server. To do what you are asking would require the Flex app to make a call to the server to retrieve data from the web service. From here, it would then need to load the data, parse it as XML, and then write it back to the server from the client machine. A task like this would nearly always be performed on the server, not remotely. Consequently, Flex could only ever post this to a script or service on your server, it could never have access to your server's file system. You would also come up against problems if you were trying to write the XML locally, as Flash Player has security settings in place to prevent access to the local file system without the explicit permission of the user. By default, these settings are configured to deny all access to local drives.

** Update: You could achieve this using the FileStream class in AIR though **
« Last Edit: 21 May 2008, 10:42:40 UTC by flexy » Logged
Nirth
Guest
« Reply #16 on: 20 Sep 2006, 18:28:47 UTC »

You can use MDM Zinc if you use your flex-application as application(*.exe file) version 2.5 supports ActionScript 3.0
Or you can use server side script (there are plenty of examples in PHP,ASP,Perl,Ruby in internet, try use google.com)
Logged
Pages: [1] Print
« previous next »
Share this on: Twitter Twitter Del.icio.us del.icio.us Digg Digg
Jump to:

©2006-2010 Flexdeveloper.eu/Jodie O'Rourke. All rights reserved.
Adobe®, Adobe® Flash™, Adobe® AIR™ and Adobe® Flex™ are registered trademarks of Adobe Systems Incorporated in the United States and other countries. All rights reserved.

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC