2012-10-01 142 views
1

我的一個WCF服務有一個操作協定,它將一個大文件作爲參數。所以,當客戶端嘗試這個送過來,我有一個例外,當我看着服務器跟蹤,這是我所看到的:WCF - 沒有端點監聽

消息:傳入消息(65536) 具有最大郵件大小配額已超過。要增加配額,請在適當的綁定元素上使用MaxReceivedMessageSize屬性。

我是用我的WCF服務的默認簡化的配置,所以增加了新的服務定義如下:

<system.serviceModel> 
<services> 
    <service name="MyNamespace.MyService"> 
    <endpoint address="MyService.svc" 
     binding="basicHttpBinding" bindingConfiguration="basicHttp" 
     contract="MyNamespace.IMyService" /> 
    </service> 
</services> 
<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttp" allowCookies="true" 
      maxReceivedMessageSize="10485760" 
      maxBufferSize="10485760" 
      maxBufferPoolSize="10485760"> 
     <readerQuotas maxDepth="32" 
      maxArrayLength="10485760" 
      maxStringContentLength="10485760"/> 
    </binding> 
    </basicHttpBinding> 
</bindings> 
<behaviors> 
    ... 
</behaviors> 
<protocolMapping> 
    ... 
</protocolMapping>  

我消耗我的服務的方式是,我有一個函數在我的幫手類中返回一個頻道,並使用該頻道調用操作:

public static T CreateChannel<T>() where T : IBaseService 
{ 
    System.ServiceModel.BasicHttpBinding binding= new System.ServiceModel.BasicHttpBinding(); 

    binding.TransferMode = TransferMode.Streamed; 
    binding.Security = new BasicHttpSecurity() { Mode = BasicHttpSecurityMode.None }; 
    binding.MaxReceivedMessageSize = 10485760; 
    binding.MaxBufferSize = 10485760; 

    System.ServiceModel.ChannelFactory<T> cf2 = new ChannelFactory<T>(binding, 
      new System.ServiceModel.EndpointAddress(MyEndpointAddress)); //I checked this part, the address is correct. 
    T Channel= cf2.CreateChannel(); 
    return Channel; 
} 

and the N,

var businessObject = WcfHelper.CreateChannel<IMyService>(); 
var operationResult = await businessObject.MyOperationAsync(...); 

即使,我的其他服務都正常運行,我在配置中定義的一個明確返回異常「沒有終點的聆聽......」我開發在VS2012,使用IISExpress。可能是什麼問題,有什麼建議?

回答

0

我認爲轉移模式存在不匹配。在客戶端,您正在使用流式傳輸,而在服務器端,它不在配置中。另外,你已經指定了10MB,不是很高。

請訪問this瞭解更多關於流媒體的信息。

編輯:

如果您在IIS下託管,也請您查看(默認爲4MB):

<system.web>  
    <httpRuntime maxRequestLength="4096 " /> 
</system.web> 
+0

感謝您的文章,但傳輸模式設置沒什麼區別,我只是嘗試不同的東西+我作爲參數傳遞的文件大於65536字節,小於10MB。 –

+0

@ F.Erken見編輯 – Cybermaxs

+0

已經檢查過,沒有運氣。 –