开发者

WCF - maxReceivedMessageSize

I have a problem setting maxReceivedMessageSize for larger files.

I'm getting:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

Here is my server side configuration:

<?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>

Here is my client side 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>

This is how i connect the client:

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();

Also I would like to transfer any type of files up to 500mb using stream messages. Can someone please provide me with configuration (or solution) that would support that?

Thanx!


Your client side config doesn't have any <client> tag that would reference the server, and to which you could apply the binding configuration with your increased message size......

On your server side, you need to define the service and its endpoints:

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

On your client side, you need to define your client endpoint connecting to one of the service endpoints

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

Update: ok, now I see your config fine - but where is your client endpoint connecting to?? You don't have any address= defined!

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜