BlazeDS & Flex & LiveCycle DS & Tutorials 12 May 2008 07:51 am
BlazeDS Tutorial – Proxy Service
This article is applicable to LiveCycle DS, LiveCycle DS Express, and BlazeDS.
Flash Player Cross Domain Policy
Flash player has cross domain security restriction that prevents Flex applications from retrieving data from remote servers. At runtime, when a network request is made from your Flex application, may it be HTTP or SOAP, the Flash player examines the cross domain policy file on the remote server before the data could be retrieved.
The policy file is an XML file named crossdomain.xml, residing at the root of the remote server. The syntax is,
[code lang="xml"]
[/code]
The Yahoo Search API server, for example, allows direct access from third party clients (http://search.yahooapis.com/crossdomain.xml). Notice how the allow-access-from node is set to the wildcard *. Certain sites have more restrictive polices, or no cross domain policy at all. In that case, you need to set up your own proxy server with either LiveCycle DS or BlazeDS.
Default Proxy Service
The data service proxy configration file, proxy-config.xml, resides under the WEB-INF/flex directory. In your configuration file, there should be one default destination node,
[code lang="xml"]
The default proxy destination will forward HTTP payload with an URL specified by your Flex client. Before you could use the proxy service, you must specify the permitted proxy destinations using the dynamic-url property,
[code lang="xml"]
[/code]
To access the proxy service from your Flex application, ensure your application is properly wired to the data service, and set the useProxy attribute to true,
[code lang="xml"]
[/code]
Named Proxy Service
The named proxy service is just like a default proxy service, but with the addition of a URL property,
[code lang="xml"]
[/code]
To access a named proxy service from MXML,
[code lang="xml"]
As you can see, the named proxy simply delegates the URL details from MXML code into the server config file. This is recommended in a production environment. It helps you manage URL changes without recompiling the Flex application.
It’s still possible to use dynamic URLs in a named proxy service. In this case, the URL property serves as the default address for the destination,
[code lang="xml"]
[/code]
Authenticate with External Proxies
If you server resides in a corporate network that must go through a proxy for out-bound traffic, add external-proxy setting to your service properties,
[code lang="xml"]
[/code]
Need to bring your Flex project up to speed? Zee Yang is a freelance Flex developer with deep understanding of architecture and user experience. You can reach him at zee.yang@gmail.com.

on 13 May 2008 at 3:16 pm 1.Ted C said …
When calling an HTTPService with useProxy=true through BlazeDS I am getting java.net.ConnectException: Connection refused while attempting to access the following url: http://examples.adobe.com/flex3/exchangingdata/text/plainHttpService.php
Any ideas why this wouldn’t be working?
thanks,
(sorry if this sent twice)
on 16 May 2008 at 5:52 pm 2.Flex Integration | Solution Hacker said …
[...] LiveCycleDS, this mechanism is provided without you manually create your own proxy service. Check this out for detail. Another advantage of using proxy is that you now put proxy name in [...]
on 20 May 2008 at 5:49 am 3.FlexLive.net » BlazeDS Tutorials said …
[...] BlazeDS Proxy Service – Having trouble with Flash cross domain policy? Use the BlazeDS Proxy Service to tunnel Flex RPC calls through your own server [...]
on 30 May 2008 at 5:06 am 4.leonardo said …
Hello,
Have you already made a login with blazeds and jaas?
Can you help me or give me some tutorial? I´m trying to do a HTTPService to “https://localhost:8080/testeFlex/j_security_check” passing the params j_username and j_password.
Am i in the correct way?
Thanks
on 10 Sep 2008 at 8:15 pm 5.Yo said …
Hey man, ever get this when making a call to a proxy service.
Channel.Connect.Failed error NetConnection.Call.BadVersion
on 07 Nov 2008 at 3:33 am 6.Abdul Areef said …
Hi,
i am new to Flex, i would like to connect the Flex and Struts without JSP, is it possible, i need help,
thanks in advance
areef
on 22 Oct 2009 at 6:02 am 7.Carsten Schlipf said …
Unfortunately your article seems to be broken. Looks like there should be several XML tags in the document, but they are not displayed.
on 11 Dec 2009 at 1:05 am 8.fonetval said …
Hi,
{Carsten} : fortunately, you can access this tags by editing the “source of the page” in your browser : they’re still there.
Hope it helps.
on 28 Jul 2010 at 6:11 am 9.fgh said …
nee bonada