Problem loading external XML files from different domain

3610
4
08-25-2011 04:46 AM
PedroGarcia
New Contributor III
Hi all,

I'm developing a widget that access to a XML file in an external server to load dynamic information. The application works fine in Adobe Flash Builder in my local machine, but when I upload the application to the web server it doesn't works, and I'm not able to access to the external xml file (in different domain that my server and my machine), and debugging in Mozilla I've seen that the application fault doing a GET of crossdomail.xml file from the external server where is the xml file I'm trying to download. Any idea how to solve that? (as the external server from I'm trying to download the xml file, it's not our server, I can't put there this crossdomain file.)

You can see below a little extract of code used to connect to download a external xml file:

private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejeroCodigos.asmx/ConsultaMunicipio...");

loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);
             ....

Thanks a lot in advance.
Tags (2)
0 Kudos
4 Replies
ZahidChaudhry
Occasional Contributor III
Hi all,

I'm developing a widget that access to a XML file in an external server to load dynamic information. The application works fine in Adobe Flash Builder in my local machine, but when I upload the application to the web server it doesn't works, and I'm not able to access to the external xml file (in different domain that my server and my machine), and debugging in Mozilla I've seen that the application fault doing a GET of crossdomail.xml file from the external server where is the xml file I'm trying to download. Any idea how to solve that? (as the external server from I'm trying to download the xml file, it's not our server, I can't put there this crossdomain file.)

You can see below a little extract of code used to connect to download a external xml file:

private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejeroCodigos.asmx/ConsultaMunicipio...");

loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);
             ....

Thanks a lot in advance.

instead of using URLLoader, you should try something like this

<fx:Declarations>
  <s:HTTPService id="srv" result="srv_resultHandler(event)" resultFormat="xml" 
        url="http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejeroCodigos.asmx/ConsultaMunicipioCodigos">
   <s:request xmlns="">
    <CodigoProvincia>30</CodigoProvincia>
    <CodigoMunicipio></CodigoMunicipio>
    <CodigoMunicipioIne></CodigoMunicipioIne>
   </s:request>
  </s:HTTPService>
 </fx:Declarations>
0 Kudos
LuisJimenez
New Contributor
The only solution is to create a 'proxy' in your server (for example a servlet that gets the url) and do the request there.

En español:
La única solución es crear alguna especie de 'proxy' en tu servidor (por ejemplo un servlet al que le pasas la url) y hacer la petición ahí.

Hi all,

I'm developing a widget that access to a XML file in an external server to load dynamic information. The application works fine in Adobe Flash Builder in my local machine, but when I upload the application to the web server it doesn't works, and I'm not able to access to the external xml file (in different domain that my server and my machine), and debugging in Mozilla I've seen that the application fault doing a GET of crossdomail.xml file from the external server where is the xml file I'm trying to download. Any idea how to solve that? (as the external server from I'm trying to download the xml file, it's not our server, I can't put there this crossdomain file.)

You can see below a little extract of code used to connect to download a external xml file:

private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("http://ovc.catastro.meh.es/ovcservweb/OVCSWLocalizacionRC/OVCCallejeroCodigos.asmx/ConsultaMunicipioCodigos?CodigoProvincia=30&CodigoMunicipio=&CodigoMunicipioIne=");

loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(request);
             ....

Thanks a lot in advance.
0 Kudos
PedroGarcia
New Contributor III
The only solution is to create a 'proxy' in your server (for example a servlet that gets the url) and do the request there.

En español:
La única solución es crear alguna especie de 'proxy' en tu servidor (por ejemplo un servlet al que le pasas la url) y hacer la petición ahí.


Could you send me a link with a example? I haven't any experience creating proxy. Besides, is it needed to change my code? How would be the code in Flex to access XML file, using the proxy you refers?

En español:
¿Podrías enviarme algún enlace con algún ejemplo? No tengo experiencia en crear dicho proxy. ¿Cómo seria el código en Flex para poder descargar el fichero XML que me interesa usando el proxy que comentas? (mi servidor es un w2008 server y utilizo IIS7)
0 Kudos
LuisJimenez
New Contributor
Just create a asp with a one parameter with the url and do the request in the server. You should do something like:

In Flex -> Send a request to an asp in you server with the url as parameter:
   http://SERVER/Proxy.asp?URL=YOUR_URL

In the Proxy.asp -> Do the request here to YOUR_URL and send the result to the flex (for example, get the xml from YOU_URL in a string and send this string to the client)

This method is 'transparent' for the flex. Simply do the call to the 'Proxy' instead of do the call to YOUR_URL.

Could you send me a link with a example? I haven't any experience creating proxy. Besides, is it needed to change my code? How would be the code in Flex to access XML file, using the proxy you refers?

En español:
¿Podrías enviarme algún enlace con algún ejemplo? No tengo experiencia en crear dicho proxy. ¿Cómo seria el código en Flex para poder descargar el fichero XML que me interesa usando el proxy que comentas? (mi servidor es un w2008 server y utilizo IIS7)
0 Kudos