【问题标题】:Configure Binding on WCF Service injected with Autofac在注入 Autofac 的 WCF 服务上配置绑定
【发布时间】:2012-05-02 17:15:31
【问题描述】:

我正在使用 Autofac 提供一些 WCF 服务,并且按照教程它工作正常!但是现在,我需要发送一个大于 65Kb 的请求,所以我必须更改服务器上的绑定以允许该请求,但我不知道该怎么做!

如何拦截服务的注入以分配动态创建或在 .config 中定义的绑定?在客户端,我做得正确并且工作正常!

提前致谢,

马克。

【问题讨论】:

    标签: wcf binding configuration integration autofac


    【解决方案1】:

    我终于找到了解决方案,关注this post

    我已经使用他的配置和我的服务名称重写了配置文件,它可以工作。我之前尝试过,但是没有用;真诚地,我不知道我的错误在哪里。

    配置:

    <bindings>
      <basicHttpBinding>
        <binding name="clearHttpBinding">
          <security mode="None" />
        </binding>
        <binding name="secureHttpBinding">
          <security mode="TransportWithMessageCredential">
            <message clientCredentialType="UserName" />
          </security>
        </binding>
        <binding name="largeMessageHttpBinding" maxBufferSize="10000000"
            maxReceivedMessageSize="10000000" messageEncoding="Text" transferMode="Buffered">
          <readerQuotas maxArrayLength="10000000" />
          <security mode="None" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="defaultBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="defaultBehavior" name="my.Services.MyService">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="largeMessageHttpBinding" contract="my.ServiceModel.ServiceContracts.IMyService"/>
      </service>
    </services>
    

    希望对你有帮助。

    【讨论】:

    • 您真的能够为您的服务获取元数据吗?您的配置中缺少 Mex 绑定。我无法使元数据正常工作,我只在 Autofac 示例中的代码中看到了行为规范,但试图从 web.config 中获取它
    • 是的,我正确获取了元数据。我认为使用属性: 就足够了!
    • 您好,您如何托管您的服务,我正在使用 IISExpress,但收到错误消息,提示“为 WCF 配置的服务 'xxxx' 未在 Autofac 容器中注册。”我在我的 App_code 文件夹中添加了一个带有 AppInitialize 的类,但是当我浏览时它没有点击此代码。有什么想法吗?
    • 我已经在 Global.asax 中实现了 Application_Start 事件来初始化 Autofac 容器。服务 (.svc) 使用 AutofacServiceHostFactory 实例化:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-16
    相关资源
    最近更新 更多