`
zgzlwm
  • 浏览: 20244 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

java 与flex通信 BlazeDs 报安全沙箱2048 错误

    博客分类:
  • Flex
 
阅读更多
[RPC Fault faultString="Send failed" faultCode="Client.Error.MessageSend" faultDetail="Channel.Security.Error error Error #2048 url: 'http://127.0.0.1:8080/Flex_Service/messagebroker/amf'"]

试了很多遍  竟然是这样

<s:AMFChannel id="myAmf" uri="http://127.0.0.1:8080/Flex_Service/messagebroker/amf"/>

跟配置链接的flex server 不同 http://localhost:8080...
不一样 就 报错 改了 就ok



1、建立 Dynamic Web Project  --记得指定web-server
2、将 从adobe下载的 blazeds 覆盖项目web-root项
3、建立一个类SimpleService 且方法say
4、web.xml中添加
<servlet>
        <servlet-name>RDSDispatchServlet</servlet-name>
<display-name>RDSDispatchServlet</display-name>
        <servlet-class>flex.rds.server.servlet.FrontEndServlet</servlet-class>
<init-param>
<param-name>useAppserverSecurity</param-name>
<param-value>true</param-value>
</init-param>       
        <load-on-startup>10</load-on-startup>
    </servlet>
    <servlet-mapping id="RDS_DISPATCH_MAPPING">
        <servlet-name>RDSDispatchServlet</servlet-name>
        <url-pattern>/CFIDE/main/ide.cfm</url-pattern>
    </servlet-mapping>
5、remoting-config.xml 中添加
    <destination id="simpleService">
<properties>
<source>com.test01.SimpleService</source>
</properties>
    </destination>

6、动态部署到web-server

7、建立flex项目

8、Flex服务器选择 上面的web-server
   根url为: 上面java项目 应用路径
   上下文目录为:上面的java项目

9、
  flex_client.mxml

   <?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   minWidth="955" minHeight="600">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<s:RemoteObject id="remoteObject" destination="simpleService" fault="faultHandler(event)"
result="resultHandler(event)" source="com.test01.SimpleService">
<s:channelSet>
<s:ChannelSet>
<s:channels>
<s:AMFChannel id="myAmf" uri="http://127.0.0.1:8080/Flex_Service/messagebroker/amf"/>
</s:channels>
</s:ChannelSet>
</s:channelSet>
</s:RemoteObject>

</fx:Declarations>

<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

private function resultHandler(event:ResultEvent):void{
Alert.show(event.result+"","提示");
}

private function faultHandler(event:FaultEvent):void{
Alert.show(event.fault.toString(), "提示");
}

]]>
</fx:Script>

<s:Button label="发送" click="remoteObject.say()"/>

</s:Application>

10、类SimpleService

<?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="simpleService">
<properties>
<source>com.test01.SimpleService</source>
</properties>
</destination>
</service>








分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics