2010-12-21 53 views
2

對於較大的文件,我有一個問題設置maxReceivedMessageSizeWCF - maxReceivedMessageSize

我越來越:

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

這裏是我的服務器端配置:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <add key="HTTPBaseAddress" value="http://localhost:8080/WelcomeMessage/"/> 
    <add key="HTTPFileTransferAddress" value="http://localhost:8080/FileTransfer/"/> 
    </appSettings> 
    <system.web> 
    <compilation debug="false" /> 
    </system.web> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
    <system.serviceModel> 
    <services> 
     <service name="FS.Services.MessageService" behaviorConfiguration="MyServiceTypeBehaviors"> 
     <endpoint contract="FS.Interfaces.IMessageService" address="" binding="wsHttpBinding"/> 
    </service> 
     <service name="FS.Services.FileTransferService" behaviorConfiguration="MyServiceTypeBehaviors"> 
     <endpoint contract="FS.Interfaces.IFileTransferService" address="" binding="basicHttpBinding" bindingConfiguration="streamedHttpBinding"/> 
     </service> 
    </services> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="streamedHttpBinding" 
       messageEncoding="Text" 
       transferMode="Streamed" 
       maxReceivedMessageSize="400000000"/> 
     </basicHttpBinding> 
    </bindings> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="MyServiceTypeBehaviors"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

這裏是我的客戶端配置:

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.serviceModel> 
    <client> 
     <endpoint address="" binding="wsHttpBinding" contract="FS.Services.IMessageService" 
     name="FS.Services.MessageService" /> 
     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="streamedHttpBinding" 
     contract="FS.Services.IFileTransferService" name="FS.Services.FileTransferService" /> 
    </client> 
    <bindings> 
     <basicHttpBinding> 
     <binding name="streamedHttpBinding" maxReceivedMessageSize="400000000" 
      messageEncoding="Text" transferMode="Streamed"/> 
     </basicHttpBinding> 
    </bindings> 
    </system.serviceModel> 
</configuration> 

我這是怎麼連接的客戶端:

BasicHttpBinding binding2 = new BasicHttpBinding("streamedHttpBinding"); 
EndpointAddress endpoint2 = new EndpointAddress("http://localhost:8080/FileTransfer"); 
ChannelFactory<IFileTransferService> channelFactory2 = new ChannelFactory<IFileTransferService>(binding2, endpoint2); 
IFileTransferService proxy2 = channelFactory2.CreateChannel(); 
((IClientChannel)proxy2).Open(); 

而且我想使用st轉換任何類型的文件高達500MB令消息。 有人可以請我提供配置(或解決方案),將支持嗎?

Thanx!

+0

對不起...我已經嘗試插入代碼,但只有第一行出現... – no9 2010-12-21 10:03:38

+0

好的thanx,固定的。 – no9 2010-12-21 10:19:48

回答

3

您的客戶端配置沒有任何<client>標籤會引用服務器,並且你可以用你增加郵件大小應用綁定配置......

在您服務器一面,你需要定義服務及其端點:

<services> 
    <service name="YourNamespace.YourServiceClass"> 
     <endpoint name="endpoint1" 
       address="http://server:8888/YourService.svc" 
       binding="basicHttpBinding" 
       bindingConfiguration="lageMessageTransfer" 
       contract="IYourServiceContract" /> 
    </service> 
</services> 

在您客戶端,你需要定義你的客戶終端連接到服務端點的一個

<client> 
    <endpoint name="Default" 
      address="http://server:8888/YourService.svc" 
      binding="basicHttpBinding" 
      bindingConfiguration="lageMessageTransfer" 
      contract="IYourServiceContract" /> 
</client> 

更新: OK,現在我看到你的配置很好 - 但其中是你的客戶端點連接到??您沒有任何address=定義!

<client> 
    <endpoint name="FS.Services.FileTransferService" 
       address="" 
       binding="basicHttpBinding" 
       bindingConfiguration="streamedHttpBinding" 
       contract="FS.Services.IFileTransferService" /> 
</client> 
+0

我會在哪裏放置客戶端標籤?我相信我將不得不封裝服務部分呢? – no9 2010-12-21 10:06:21

+0

對不起,我錯過了放置圖像! – no9 2010-12-21 10:14:58

+0

看起來像這不是問題...任何其他的想法? – no9 2010-12-21 10:20:11

相關問題