现在的位置: 首页 > 综合 > 正文

HttpService 使用useProxy参数

2013年02月13日 ⁄ 综合 ⁄ 共 1338字 ⁄ 字号 评论关闭

 

If you want your application to access services available on another domain without deploying a crossdomain.xml file on that domain (for example, because you may not own the target domain), you can set the useProxy attribute of the HTTPService to "true" like in this example. In this case, the request is sent to the BlazeDS proxy which makes the request to the target domain on the client application's behalf. This configuration also provides more control over the access to the service. For example, you may configure the proxy to require authentication before accessing a service, log access to the service, etc.

When using the proxy, you can specify a logical name in the HTTPService destination attribute instead of specifying a hardcoded value in the url attribute. You then map this logical name to an actual URL in WEB-INF/flex/proxy-config.xml. Open WEB-INF/flex/proxy-config.xml to see how the catalog destination is configured.

 

优点:

1. 可以跨域

2. 可以在这里做一些认证登陆等操作

3. 避免在mx:HttpService中使用url硬编码

 

代码示例

main.mxml

 

flex/proxy-config.xml

 

 

 

抱歉!评论已关闭.