zoukankan      html  css  js  c++  java
  • [导入]FMS如何连接FlashRemoting?(附示例源码下载)

        在FMS开发中,我们经常要在FMS端连接数据库,进行如身份验证等的数据查询操作。方法有多种,你可以使用WebServices或NetConnection对象,也可以使用NetServices类,差别是NetServices能够返回RecordSet对象的数据,本例子就是一个使用NetServices连接FlashRemoting程序的简单例子。例子的重点在于跑通"Flash->FMS->FlashRemoting"这个数据传递的过程,所以并没有使用到RecordSet对象。例子使用Flash 8 + FMS 2.0.4 + Asp.Net 2.0 制作。

        点此下载(74KB)>>

        一、使用说明
            1).在IIS中,创建虚拟目录RemotingApp,asp.net版本选择2.0,将例子中RemotingApp文件夹中的内容放进去;
            2).将crossdomain.xml文件放在IIS站点根中,要能通过http://domain/crossdomain.xml访问;
            3).将FMSRemotingTest文件夹copy到FMS的应用程序目录中,此目录默认在“C:\Program Files\Macromedia\Flash Media Server 2\applications\”

        二、关键代码分析
            1).TestDemo.aspx
    <%@ Page Language="c#" Debug="true" %>

    <%@ Register TagPrefix="Macromedia" Namespace="FlashGateway" Assembly="flashgateway" %>
    <Macromedia:Flash ID="Flash1" runat="Server" />

    <script language="C#" runat="server">
        
    void Page_Load(Object sender, EventArgs e)
        {
            Flash1.Result 
    = "FlashRemoting服务器时间:"+System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }
    </script>

            注意加粗的部分,FlashRemoting是个比较特殊的东西,你的页面"TestDemo.aspx"的名称"TestDemo"就是方法名称,方法的代码要写在Page_Load中,然后把返回结果绑定到一个FlashGateway对象(本例中"Flash1")上才能传递出去。关于FlashRemoting For .Net的详细用法,请查其它资料。

            2).FMS端Main.asc文件

    load ("netservices.asc");
    //
    application.onConnect = function (client, _name)
    {
        //...
            this.acceptConnection (client);
            
    //
            NetServices.setDefaultGatewayUrl ("
    http://localhost/RemotingApp/gateway.aspx");
            
    var conn = NetServices.createGatewayConnection ();
            
    var myService = conn.getService ("RemotingApp", this);
            myService.TestDemo();
            application.TestDemo_Result =
     function (result_obj)
            {
              //...
            }
        //...
    };

            同样注意加粗的部分,load ("netservices.asc");要放在最顶行。
            "RemotingApp"就是前边创建的虚拟目录了。
            conn.getService ("RemotingApp", this);这一句这里要非常注意,如果你的aspx页面放在更深一层的目录中,那么这一句中的"RemotingApp"就要带把路径转换为类似命名空间的写法,如“RemotingApp.Folder”。
            "TestDemo"就是前边TestDemo.aspx页面的名称,接受数据的函数使用"Remoting方法名"+"_Result"的格式。

            3).FMS_FlashRemoting.fla文件
            这个没啥说的,很简单,略了。

        三、注意事项
            如果遇到不能成功连接和返回数据,请注意:
            1).安全策略的问题,前边放置"crossdomain.xml"就是解决这个问题。
            2).web.config中system.web节的是否有:

    <httpModules>
          
    <add name="GatewayController" type="FlashGateway.Controller.GatewayController,flashgateway" />
    </httpModules>
            
        四、本例的测试运行效果

           如下图:



        五、另附两个开发过程中遇到的简单问题
        1.如何查看FMS的服务端trace出的信息?
            1).打开FMS的管理控制台;
            2).View Applications -> { FMSRemotingTest } -> LiveLog;如下图:
     



        2.如何重启FMS应用程序?
            修改了FMS服务端的程序,如Main.asc后,需要重启FMS的应用程序才能看到最新的结果,所以如果你改了代码而看不到最新效果,不要恼火,还需要这步操作。
            1).打开FMS的管理控制台;
            2).Manage Servers -> { FMSRemotingTest } ->  如下图:





    [新闻]互联网的未来
    博客园首页 社区 新闻频道 小组 博问 网摘 闪存
    文章来源:http://www.cnblogs.com/yao/archive/2008/01/16/1041131.html
  • 相关阅读:
    arcgis server adf java
    JBoss4.2.3下载地址
    关心
    [转载]通过Arcgis Server向MXD中添加图层
    arcgis server问题总结
    想和做
    无敌
    [转载]通过Arcgis Server将某一图层从MXD中…
    Error retrieving "feature.xml".
    360很强大
  • 原文地址:https://www.cnblogs.com/tonybinlj/p/1297961.html
Copyright © 2011-2022 走看看