2012-05-02 144 views
2

我使用Autofac爲一些WCF服務提供服務,並遵循教程,它工作正常!但現在,我需要發送> 65Kb的請求,所以我必須更改服務器上的綁定以允許此請求,並且我無法找到如何執行該操作!在使用Autofac注入的WCF服務上配置綁定

如何攔截服務的注入以分配一個綁定創建的或在.config中定義的綁定?在客戶端我已經正確完成並且工作正常!

在此先感謝,

Marc。

回答

5

最後我找到了解決方案,下面是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> 

希望它能幫助。

+0

你確實能夠獲取服務的元數據嗎? Mex綁定在您的配置中丟失。我無法獲取元數據的工作方式,我只能在Autofac示例的代碼中看到行爲規範,但試圖從web.config中獲取它。 –

+1

是的,我正在獲取元數據。我認爲使用屬性:就足夠了! – Marc

+0

嗨,你是如何託管你的服務,我使用的IISExpress,但得到錯誤,說:「服務'xxxx'配置爲WCF未註冊與Autofac容器。」我在App_code文件夾中添加了一個AppInitialize的類,但是當我瀏覽時它沒有打這個代碼。有任何想法嗎? – Donny