zoukankan      html  css  js  c++  java
  • Remoting experienes

    在做Remoting的時候,寫的代碼在第一次運行的時候還是正常,但再次執行的時候,發現有類似"http already registed ...."的錯誤,顯然是因為在客戶端不能重復注冊同一個channel, 后來加一個ChannelServices.RegisteredChannels.Length判斷是否有channel注冊就可以正常工作了

    不work的代碼:
        public sealed class RemotingDataService : DataService
        {
            public RemotingDataService()
            {
                   RemotingConfiguration.Configure("ClientRemoting.config", false); // false means we needn't do security check currently
            }
    ... ...

    Work的代碼:
        public sealed class RemotingDataService : DataService
        {
            public RemotingDataService()
            {
                if (ChannelServices.RegisteredChannels.Length == 0)
                    RemotingConfiguration.Configure("ClientRemoting.config", false); // false means we needn't do security check currently
            }

    補充:
    當在同一台機器是可以用上述方法順利調用remoting的,但是當把remoting service以IIS host的方式發布到另外一台機器的時候,經常出現 **** (403) Forbidden的錯誤。經過長時間的查找,原來是在網絡上調用IIS Host的remoting需要身份, Remoting本身并不具務權限的機制,因為它被host在IIS中,所以必須經過IIS那道關卡,解決方法是
    1. 在IIS管理器將remoting站點的匿名訪問不選,只選integrate with Windows, And choice correct Dot net framework version. And let this Web site has script only permission, because it is web application site.
    2. 在IIS主機中創建一個Windows帳號,可以只為一般用戶權限就可
    3. 修改客戶端調用remoting service代碼,加入此帳號即可
    .... ....
                    IRemotingDataService service = (IRemotingDataService)Activator.GetObject(typeof(DDNP.Layers.DSL.IRemotingDataService), myEntries[0].ObjectUrl);
                    IDictionary Props = ChannelServices.GetChannelSinkProperties(service);
                    Props["credentials"] = new NetworkCredential(ConfigurationManager.AppSettings["remotingusername"], ConfigurationManager.AppSettings["remotinguserpwd"]);

    .... ....


    Today, I tried to setup multiple remoting services that was host in a physical machine. At client, can config multiple Welknow service to connect these 2 service :
    <configuration>
     <system.runtime.remoting>
      <application>
       <client displayName="DDNP Remoting">
        <wellknown
           type="DDNP.Layers.DSL.RemotingDataServiceProxy, DDNP.Layers.DSL"
           url="http://localhost:8085/DBDataService2.rem"/>  <!-- If remoting object reside in IIS, you should use: http://localhost:port/DBDataService2.rem-->
        <wellknown
           type="DDNP.Layers.DSL.RemotingDataServiceProxy1, DDNP.Layers.DSL"
           url="http://localhost:8086/DBDataService2.rem"/>
        <!-- If remoting object reside in IIS, you should use: http://localhost:port/DBDataService2.rem-->
       </client>
       <channels>
        <channel
           ref="http"
           port="0"/>
        
        <channel
           ref="tcp"
           port="0"/>
       </channels>
      </application>
     </system.runtime.remoting>
    </configuration>
  • 相关阅读:
    IOS归档操作
    IOS文件操作
    NSNumber,NSValue,NSData
    dbcp数据库连接池属性介绍
    Spring整合hibernate4:事务管理
    Spring整合hibernate4
    Spring AOP
    Chapter 27 Controlling Animations
    Chapter 23 Core Data
    Chapter 21 WebServices and UIWebView
  • 原文地址:https://www.cnblogs.com/sdikerdong/p/841030.html
Copyright © 2011-2022 走看看