惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Docker
爱范儿
爱范儿
T
The Exploit Database - CXSecurity.com
量子位
T
Tailwind CSS Blog
T
Threatpost
The GitHub Blog
The GitHub Blog
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
K
Kaspersky official blog
P
Proofpoint News Feed
博客园 - 司徒正美
L
LangChain Blog
T
Threat Research - Cisco Blogs
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
Spread Privacy
Spread Privacy
H
Hacker News: Front Page
T
Troy Hunt's Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google DeepMind News
Google DeepMind News
W
WeLiveSecurity
A
Arctic Wolf
Apple Machine Learning Research
Apple Machine Learning Research
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
P
Proofpoint News Feed
T
Tor Project blog
T
The Blog of Author Tim Ferriss
I
Intezer
P
Privacy & Cybersecurity Law Blog
美团技术团队
N
Netflix TechBlog - Medium
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Vulnerabilities – Threatpost
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
Google Developers Blog
Attack and Defense Labs
Attack and Defense Labs
T
Tenable Blog
月光博客
月光博客
Stack Overflow Blog
Stack Overflow Blog
J
Java Code Geeks
腾讯CDC
Microsoft Security Blog
Microsoft Security Blog
A
About on SuperTechFans
Last Week in AI
Last Week in AI

博客园 - Martin XJ

windows2000 蓝色背景 楚留香mv2 楚留香mv cyberarticle Castle.Facilities.WebserviceIntegration SharpRush中的跨函数事务实现 - Martin XJ - 博客园 SharpRush中的AOP实现 自己的ORMapping starcraft2 Spring.net的一个小例子 EnterpriseLibrary 数据访问组件windows98不能使用 使用EnterpriseLibrary碰到的问题 好久都没写blog了 MS推荐的命名指南 Sybase DataWindow.net 1.5(Beta) For .Net 发布 IEWebcontrol webctrl_client目录配置 CodeSmith使用心得 mywallop、orkut、gmail的邀请 无法打开Web项目
Castle Windsor Wcf Facility的配置及调用IChannel的Close - Martin XJ
Martin XJ · 2009-01-11 · via 博客园 - Martin XJ

服务端windsor.xml:
<configuration>

  <facilities>

    <facility id="wcf"

                              type="Castle.Facilities.WcfIntegration.WcfFacility,

                                    Castle.Facilities.WcfIntegration" />

  </facilities>

  <components>

    <!--Services start-->

        <component

                 id="order service"

                 service="WCF.Contract.ServiceContract.IOrder, WCF.Contract"

                 type="WCF.Service.OrderService, WCF.Service" >

    </component>

    <!--Services end-->

  </components>

</configuration>服务端Global.asax

protected void Application_Start(object sender, EventArgs e)

        {

            Container = new WindsorContainer()

        .AddFacility<WcfFacility>()
        .Install(Configuration.FromXmlFile("Windsor.xml"));

        }

服务端 Svr文件:

<% @ServiceHost Service="order service"

       Factory="Castle.Facilities.WcfIntegration.DefaultServiceHostFactory, Castle.Facilities.WcfIntegration" %>

<configuration>

  <facilities>

    <facility id="wcf"

                              type="Castle.Facilities.WcfIntegration.WcfFacility,

                                    Castle.Facilities.WcfIntegration" />

  </facilities>

       <components>

              <!--Services start-->

       <component

      id="order service"

       type="WCF.Contract.ServiceContract.IOrder, WCF.Contract"

       wcfEndpointConfiguration="order service"  lifestyle="transient">

    </component>

              <!--Services end-->

       </components>

</configuration>


这里为了每次都要启动一个实例,采用了transient的对象生命周期,
但是默认的WcfManagedChannelInterceptor不会自动调用IChannel.Close(),所以我改了下WcfManagedChannelInterceptor 的代码,添加了
Close方法:
#region IInterceptor Members
public void Intercept(IInvocation invocation)
  {
   EnsureOpenChannel(invocation);
   invocation.Proceed();
            Close(invocation);
  }

  #endregion

        void Close(IInvocation invocation)
        {
            if (lifestyle == LifestyleType.Transient)
            {
                IChannel channel = invocation.InvocationTarget as IChannel;
                if (channel != null)
                {
                    WcfUtils.ReleaseCommunicationObject(channel);
                }
            }
        }

这样的话每次调完一个wcf的实例,就把他关了