标签:
解压后文件目录如下:
Lib下保存jar包:
Flex中保存配置文件:
Web.xml为配置文件:
<servlet>
<servlet-name>MessageBrokerServlet</servlet-name>
<display-name>MessageBrokerServlet</display-name>
<servlet-class>flex.messaging.MessageBrokerServlet</servlet-class>
<init-param>
<param-name>services.configuration.file</param-name>
<param-value>/WEB-INF/flex/services-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
?
<servlet-mapping>
<servlet-name>MessageBrokerServlet</servlet-name>
<url-pattern>/messagebroker/*</url-pattern>
</servlet-mapping>
?
目录如下:
Src为java类;
WebContent为输出文件夹;
WEB-INF/flex中保存上面解压的配置文件;
WEB-INF/lib中保存上面解压的jar包;
FlexBin为在FlashBuilder中配置的服务路径;
配置flex/remoting-service.xml
?
<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service"
class="flex.messaging.services.RemotingService">
?
<adapters>
<adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/>
</adapters>
?
<default-channels>
<channel ref="my-amf"/>
</default-channels>
?
????<destination id="blazeDSServer">
????????<properties>
????????????<source>com.zhu.blazeDSServer.HelloWorld</source>
????????</properties>
????</destination>
</service>
?
<default-channels>
<channel ref="my-amf"/>
</default-channels>
Channel 对应于remoting-config.xml中的
?
<channels>
?
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
?
<channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
<endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
<properties>
<add-no-cache-headers>false</add-no-cache-headers>
</properties>
</channel-definition>
?
<channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
<properties>
<polling-enabled>true</polling-enabled>
<polling-interval-seconds>4</polling-interval-seconds>
</properties>
</channel-definition>
</channels>
?
<destination id="blazeDSServer">
????????<properties>
????????????<source>com.zhu.blazeDSServer.HelloWorld</source>
????????</properties>
????</destination>
对应于相应的包中的类,id则为Flex客户端的remoteobject中相对应。
?
Flexbuilder新建客户端;
服务器配置如下:
服务器技术为Java;
远程对象访问服务为BlazeDS;
服务器位置:
????根文件夹为服务器动态网站的WebContent
必须包含WEB-INF/flex中的这个配置文件
根URL为服务启动的根URL
上下文目录必须为上面remoting-config.xml中所配置的路径
<channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
<endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
上下文根目录
上下文根目录通常与根 URL 路径的最后一段相匹配。
?
?
输出文件夹为Flex输出的文件夹,可以在WebContent目录下新建一个Flex的输出文件夹FlexBin,然后运行Flex客户端,则打开如下URL:
http://localhost:8080/MyFirstServlet/FlexBin/index.html
标签:
原文地址:http://www.cnblogs.com/The-SEA/p/4530580.html