Flex与服务器通信问题,关于几个配置文件

  Flex 调用远程或所在web应用的 BlazeDS服务时,必须建立和远端的通道channel,才能正常通信。
     通常的方式是 Flex 在编译时就指定远程的端点 Endpoint,service-config.xml 中的Endpoint 配置是 例如:

 

 

代码
<channels>
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/Gateway.aspx"
            class
="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>

 

 

 

 

  编译时指定的方式是在加编译参数,例如: -services "services-config.xml" -context-root "/HelloBlazeds"

 

  services-config.xml 需要放在当前目录下,或者指定BlazeDS所在的配置文件路径。

 

如果要动态改变endpoint,那么加上如下代码:

  建立一个web-config.xml文件:

 

<config>
<endpoint>http://172.23.19.252/Gateway.aspx</endpoint>
</config>

 

  引入web-config.xml,文件放在主文件的同级目录:

 

<mx:Model id="xmlConfig" source="web-config.xml"/>

  
  为RemoteObject组件的endpoint赋值

 

var ro:remoteObject = new remoteObject();
ro.endpoint
= xmlConfig.endPoint;

 

  以后改IP地址可以直接在web-config.xml中改。

 

参考资料:

blazeds体系结构一和二

 

http://www.javaeye.com/wiki/flex/1480-blazeds-document-b---------blazeds-architecture-1

http://www.javaeye.com/wiki/flex/1481-blazeds-document-b---------blazeds-architecture-b

posted @ 2010-03-16 11:20    阅读(860)  评论(0)    收藏  举报