11 Replies Latest reply on Aug 12, 2009 8:24 AM by senprojjwal

    RSS Feeds in Flex

    lravinarayanan Level 1

      i have a page that displays live rss feeds. The thing is that, it works correctly when the project is just a Flex Project and run as a flex application. But when i create a Flex project that runs on a server (Tomcat 5.5) with Blaze DS, the rss feeds are not available any more.

       

      i also tried using the crossdomain.xml file but still its not working. The Feeds are loaded using an HTTP Service, also i am using Blaze DS in my application for remoting.

       

      Do I anything to load RSS feeds in application servers, other than while running it as a simple Flex Application?

       

      Thanks Ravi

        • 1. Re: RSS Feeds in Flex
          Barna Biro Level 3

          Hi again,

           

          Did you try debugging the application to see if you get any warning or something? If you say that it's not working with the crossdomain.xml policy file then you could try accessing the feed with a server-side script that does not require any policy, it should be able to access and read the data without a problem. Once the data is read, you'd send it back to Flex.

           

          In your HTTPService, component, did you specify the resultFormat? It should be set to e4x. If you'd post some code, I'm sure that it would help find a solution much faster.

           

          With best regards,

          Barna Biro

          Blog: http://blog.wisebisoft.com

          • 2. Re: RSS Feeds in Flex
            lravinarayanan Level 1

            hi...i have used the result format as e4x..

            here is the code i had used:

             

            <?xml version="1.0" encoding="utf-8"?>

            <mx:Application

            xmlns:mx="http://www.adobe.com/2006/mxml"

            layout="absolute"

            creationComplete="httpService.send()"

            backgroundColor="#CCCCCC"

            themeColor="#999999" viewSourceURL="srcview/index.html">

             

            <mx:Script>

            <![CDATA[

            import flash.net.navigateToURL;

            import mx.events.ListEvent;

            import mx.controls.Alert;

            import mx.utils.ObjectUtil;

            import mx.rpc.events.FaultEvent;

            import mx.rpc.events.ResultEvent;

             

            namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";

            use namespace rdf;

            namespace purl = "http://purl.org/rss/1.0/";

            use namespace purl;

            namespace dc = "http://purl.org/dc/elements/1.1/";

            use namespace dc;

             

            [Bindable]

            private var loading : Boolean = true;

             

            private function onResult( event : ResultEvent ) : void

            {

            list.dataProvider = XML( event.result )..item;

            loading = false;

            }

             

            private function onFault( event : FaultEvent ) : void

            {

            Alert.show( ObjectUtil.toString( event.fault ), "Service Error" );

            loading = false;

            }

             

            private function onItemDoubleClick( event : ListEvent ) : void

            {

            var url : String = event.itemRenderer.data.link.toString()

            navigateToURL( new URLRequest( url ), "_blank" );

            }

             

            ]]>

            </mx:Script>

             

            <mx:HTTPService

            id="httpService"

            url="http://www.infosys.com/index.xml"

            resultFormat="e4x"

            result="onResult( event )" />

             

            <mx:ApplicationControlBar dock="true">

             

            <mx:Text

            width="100%"

            text="Select an item to see the description.

            Double-click to open the url in a new window."

            selectable="false" />

             

            </mx:ApplicationControlBar>

             

            <mx:List

            width="100%"

            height="100%"

            id="list"

            variableRowHeight="true"

            itemRenderer="ListItemRenderer"

            doubleClickEnabled="true"

            itemDoubleClick="onItemDoubleClick(event)" />

             

            <mx:ProgressBar

            visible="{ loading }"

            includeInLayout="{ loading }"

            indeterminate="true"

            horizontalCenter="0"

            verticalCenter="0"

            labelPlacement="center" />

             

            </mx:Application>

             

            ListItemRenderer is a VBox component that displays the description on the double click of a feed.

             

            • 3. Re: RSS Feeds in Flex
              lravinarayanan Level 1

               

              "faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'"

              this is the error i am receiving when i run my application.

              Also,

              the crossdomain.xml file -

               

                      <?xml version="1.0"?>

              <!DOCTYPE cross-domain-policy

              SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">

              <cross-domain-policy>

              <allow-access-from domain="*" />

               

              </cross-domain-policy>

              • 4. Re: RSS Feeds in Flex
                Barna Biro Level 3

                Try replacing your crossdomain.xml file's body with this:

                 

                <?xml version="1.0"?>
                <!DOCTYPE cross-domain-policy SYSTEM "/xml/dtds/cross-domain-policy.dtd">
                <cross-domain-policy>
                 <site-control permitted-cross-domain-policies="all"/>
                 <allow-access-from domain="*" to-ports="*" />
                 <allow-http-request-headers-from domain="*" headers="*"/>
                </cross-domain-policy>
                

                 

                If it works then edit it and apply your own security settings.

                • 5. Re: RSS Feeds in Flex
                  lravinarayanan Level 1

                  i updated the crossdomain.xml with what you had given. but when i tried opening the xml file, it is showing the following error:

                   

                  The XML page cannot be displayed

                  Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

                   

                  --------------------------------------------------------------------------------

                  The system cannot locate the object specified. Error processing resource 'http://localhost:8080/xml/dtds/cross-domain-polic...

                   

                  the xml file is in the ROOT folder.

                   

                  when i run the application still its showing the same security error.

                  • 6. Re: RSS Feeds in Flex
                    Barna Biro Level 3

                    My bad, I accidentally deleted a piece of it:

                     

                    <?xml version="1.0"?>
                    <!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
                    <cross-domain-policy>
                     <site-control permitted-cross-domain-policies="all"/>
                     <allow-access-from domain="*" to-ports="*" />
                     <allow-http-request-headers-from domain="*" headers="*"/>
                    </cross-domain-policy>
                    

                     

                    The should work.

                    • 7. Re: RSS Feeds in Flex
                      lravinarayanan Level 1

                      Still i am getting the same error when i am running the application:

                       

                      faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP

                       

                      the crossdomain.xml file is now accessible from the ROOT folder.

                      • 8. Re: RSS Feeds in Flex
                        Barna Biro Level 3

                        Nah, then I don't have a better idea... You need to use a server-side scrip to read the desired data and pass it back to the application ( or google for more information regarding the security error, understand what can cause it, why it's triggered - maybe your server settings are blocking something I can't guess those ). I'm really sorry, that's all I can do for you at the moment.

                        • 9. Re: RSS Feeds in Flex
                          lravinarayanan Level 1

                          (mx.rpc::Fault)#0

                          content = (null)

                          errorID = 0

                          faultCode = "Channel.Security.Error"

                          faultDetail = "Destination: DefaultHTTP"

                          faultString = "Security error accessing url"

                          message = "faultCode:Channel.Security.Error faultString:'Security error accessing url' faultDetail:'Destination: DefaultHTTP'"

                          name = "Error"

                          rootCause = (flash.events:ecurityErrorEvent)#1

                          bubbles = false

                          cancelable = false

                          currentTarget = (flash.net::URLLoader)#2

                          bytesLoaded = 0

                          bytesTotal = 0

                          data = (null)

                          dataFormat = "text"

                          eventPhase = 2

                          target = (flash.net::UR

                          Loader)#2

                          text = "Error #2048"

                          type = "securityError"

                           

                          this is the complete fault message i receive when i run the application.

                          • 10. Re: RSS Feeds in Flex
                            lravinarayanan Level 1

                            Thanks for your help. will try it anyway...

                            • 11. Re: RSS Feeds in Flex
                              senprojjwal

                              I am also getting exact error do u have any solution  ? Thanks