I have a good example of this using Dynamic RSS feeds at my site.
http://g-unix.com/?p=54


[EMAIL PROTECTED] wrote:
> Not sure if somebody already responded - I just deleted my newest
> (flexcoders)
> mail without really looking at it... and I must add the disclaimer
> that I'm
> still pretty new to Flex so I could be off base here.  That said,
>
> I had the same issue trying to use one HTTPService component to access any
> number of sites by dynamically changing the url attribute.  What I
> found (and I
> think you too by now) is that it's not the dynamic nature of the url
> causing the
> problem, but rather the cross-domain issue - hitting a different
> domain than the
> one serving your swf.  You mentioned using a php proxy file for your
> weather.com
> project.  Do the same thing here, just pass the dynamic url in the
> querystring
> and extract it in the php file before going there.  Assuming you put
> your php
> file in the same folder as your swf, your example below would look like:
>
>       <mx:HTTPService
>             id="myService"
>             url=""> >             resultFormat="text"/> ...
>
> and you entire php file would be:
>
>       <?php
>             $dataURL = $_GET["url"];
>             readfile($dataURL);
>       ?>
>
> If the url you're passing already has a querystring, I found a simple
> way to
> handle that is to replace the '&' character with something unlikely (I use
> '~AND~') in Flex and re-replace the '&' in php, so the entire thing
> becomes one
> value, instead of trying to re-assemble the querystring in php.
>
> In this case your example would look like:
>
>       <mx:HTTPService
>             id="myService"
>            
> url=""> >             resultFormat="text"/> ...
>
> and you entire php file would be:
>
>       <?php
>             $replacethis = "~AND~";  //& was replaced by ~AND~ in Flex
> before sending the
> httprequest
>             $withthis = "&";
>             $dataURL = $_GET["url"];
>             $dataURL = str_replace($replacethis, $withthis, $dataURL);
>             readfile($dataURL);
>       ?>
>
> Why does this work locally when obviously C:\ is not the same domain as
> www.yahoo.com?  Because of Flash 8 security model which gives a locally
> executing swf access to EITHER the local file system OR the www, but
> not both
> (unless it's in trusted mode).  In Flash, you choose which you want in the
> publish settings.  I'm pretty sure Flash defaults to local access, and
> obviously Flex defaults to www access.  Search Macromedia site for
> "Flash 8
> security model" for all the info on that.
>
> Sorry for the long-winded response (and for telling you stuff you
> already knew),
> but I tried to be as detailed as possible to also benefit all the
> newbie lurkers
> like myself.  This just happens to be an issue I wrestled with for a
> LONG time
> both in Flash and in Flex and I'm pretty condfident I can actually
> help here -
> and start to give back.
>
> Rick
>
>
> -----Original Message-----
> From: oca_gw [mailto:[EMAIL PROTECTED]
> Sent: Sunday, April 30, 2006 10:32 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Help! ( Dynamic URLs for HTTPServices )
>
>
> Hi Again all.
>
> To further demonstrate this problem, I have developed the following
> sample application:
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
> layout="absolute" width="763" height="371">
>
>       <mx:HTTPService
>             id="myService"
>             url=""> >             resultFormat="text"/>
>       <mx:TextArea x="10" y="220" width="155" height="141"
> text="{myDataGrid.selectedItem.SiteTitle} -
> {myDataGrid.selectedItem.Address}"/>
>       <mx:TextArea x="173" y="11" width="580" height="350"
> text="{myService.result}"/>
>       <mx:DataGrid x="10" y="11" width="155" height="141" id="myDataGrid"
> click="myService.send();">
>             <mx:columns>
>                   <mx:DataGridColumn headerText="Site"
> dataField="SiteTitle"/>
>             </mx:columns>
>             <mx:dataProvider>
>                   <mx:Array>
>                         <mx:Object SiteTitle="Google"
> Address="http://www.google.com"/>
>                         <mx:Object SiteTitle="Yahoo"
> Address="http://www.yahoo.com"/>
>                         <mx:Object SiteTitle="Graham Weldon"
> Address="http://graham.weldon.ath.cx"/>
>                   </mx:Array>
>             </mx:dataProvider>
>       </mx:DataGrid>
>
> </mx:Application>
>
>
>
>
>
> This works fine when i click "Run" in the Flex 2,0 beta 2 builder, to
> launch it as a SWF/HTML through the local browser, but as soon as I
> put it on the webserver to be deployed and publically accessible, the
> Security errors popup when the HTTPService should send().
>
> Any thoughts?
>
> Cheers, Regards,
> Graham Weldon
> Web Development Manager
> Object Connections
>
>
> --- In flexcoders@yahoogroups.com, "oca_gw" <[EMAIL PROTECTED]> wrote:
> >
> > Hi All.
> >
> > I'm working with Flex 2.0 beta 2
> >
> > This response interested me, as I have been experiencing some issues
> > with HTTP Services, and the usage of dynamic destinations.
> >
> > One example that claims to be able to do this is GuniX technology's
> > administrator's RSS2.0 Reader version 0.2. (
> > http://www.g-unix.com/bin/rss/index.swf )
> > Running this sample, entering in any RSS feed causes the following
> > error to pop up:
> >
> > Error: faultCode:Channel.Security.Error faultString:'Security error
> > accessing url' faultDetail:'Destination: DefaultHTTP'
> >       at
> >
> mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
> <http://www.adobe.com/2006/flex/mx/internal::faultHandler%28%29>
> >       at flash.events::EventDispatcher/dispatchEvent()
> >       at mx.messaging::MessageAgent/fault()
> >       at mx.messaging::Producer/fault()
> >       at ::DirectHTTPMessageResponder/securityErrorHandler()
> >       at flash.events::EventDispatcher/dispatchEvent()
> >       at flash.net::URLLoader/flash.net:URLLoader::redirectEvent()
> >
> >
> > This is the same error I got while programming my weather.com sample:
> > http://graham.weldon.ath.cx/?page=projects&id=weather
> <http://graham.weldon.ath.cx/?page=projects&id=weather>
> >
> > I solved the weather sample by creating a PHP file that fetched all
> > XML data from the weather.com service, rather than having flex access
> > the URLs directly.
> >
> > Intially, I was attempting to databind the URL similar to:
> >
> > mx:HTTPService
> >    id="myService"
> >    url="" href="http://www.weather.com/blah/blah/{myLocationId}?key={myKey}">http://www.weather.com/blah/blah/{myLocationId}?key={myKey}
> <http://www.weather.com/blah/blah/%7BmyLocationId%7D?key=%7BmyKey%7D>"
> >    result="processResultXML(event);"
> >    resultFormat="e4x"
> >
> > This didn't work, and raised the same error as seen on GuniX's sample.
> > I felt that this was due to the dynamic nature of the URL ( since it
> > incorporates the location ID in the URL ) causing the error.
> >
> > GuniX's sample RSS reader will always have dynamic URLs, since it
> > databinds the url="" field to: textBox.text.
> >
> > The reason I have posted this in response to Darren's message, was
> > that I am unsure as to whether or not a cross-domain.xml file is the
> > solution, especially in the case of reading RSS feeds from remote
> > servers that the developer cannot deploy an XML file on. (also, not
> > sure if this is still applicable for Flex 2.0 beta 2)
> >
> > Is there a way to allow dynamic URLs in HTTPServices, without causing
> > this Security error?
> >
> >
> > Regards,
> > Graham Weldon
> > Web Development Manager
> > Object Connections
> >
> >
> > --- In flexcoders@yahoogroups.com, "Darren Houle" <lokka_@> wrote:
> > >
> > > Pretty sure you have to place a crossdomain file on the http server
> > you're
> > > trying to hit if you're going to run the swf off your desktop.
> > Normally the
> > > swf has rights to hit the server it's served from, but when you run
> > a swf
> > > file sitting on your desktop it's not "served" from any server, so
> > any web
> > > server you specify would be "foreign" and would need to have a
> > crossdomain
> > > file that allowed that swf to access it.
> > >
> > > Darren
> > >
> > >
> > >
> > > >From: "compengguy" <sachingaur.83@>
> > > >Reply-To: flexcoders@yahoogroups.com
> > > >To: flexcoders@yahoogroups.com
> > > >Subject: [flexcoders] Help!
> > > >Date: Thu, 27 Apr 2006 13:28:15 -0000
> > > >
> > > >Hi all,
> > > >I am making a page for my teamsite where i am sending the sql
> query in
> > > >the URL. which returns an xml file. When i compile and run this code
> > > >in Flex Builder 2.0 , It runs fine but when i take that swf file and
> > > >run it seperately It gives the following errors.
> > > >
> > > >       *****************************************************
> > > >Error: faultCode:Channel.Security.Error faultString:'Security error
> > > >accessing url' faultDetail:'Destination: DefaultHTTP'
> > > >      at
> > >
> >
> >mx.rpc::AbstractInvoker/http://www.adobe.com/2006/flex/mx/internal::faultHandler()
> <http://www.adobe.com/2006/flex/mx/internal::faultHandler%28%29>
> > > >      at flash.events::EventDispatcher/dispatchEvent()
> > > >      at mx.messaging::MessageAgent/fault()
> > > >      at mx.messaging::Producer/fault()
> > > >      at ::DirectHTTPMessageResponder/securityErrorHandler()
> > > >      at flash.events::EventDispatcher/dispatchEvent()
> > > >      at flash.net::URLLoader/flash.net:URLLoader::redirectEvent()
> > > >       ********************************************************
> > > >what i need to do,to not to have this warning because after the
> > > >warning it not fetches the data.
> > > >
> > > >The code snippet is
> > > ><mx:HTTPService id="xml" url="" URL" useProxy="false"/>
> > > >
> > > >so can anybody suggest what i need to do ?
> > > >
> > > >Thanks
> > > >Sachin Gaur
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >--
> > > >Flexcoders Mailing List
> > > >FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > > >Search Archives:
> > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > > >Yahoo! Groups Links
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> >
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
>
>
>
> SPONSORED LINKS
> Web site design development
> <http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ>
>       Computer software development
> <http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw>
>       Software design and development
> <http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>
>
> Macromedia flex
> <http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=OO6nPIrz7_EpZI36cYzBjw>
>       Software development best practice
> <http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&w1=Web+site+design+development&w2=Computer+software+development&w3=Software+design+and+development&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "flexcoders
>       <http://groups.yahoo.com/group/flexcoders>" on the web.
>       
>     *  To unsubscribe from this group, send an email to:
>        [EMAIL PROTECTED]
>       <mailto:[EMAIL PROTECTED]>
>       
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to