我在为较大的文件设置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();
另外,我想使用流消息将任何类型的文件传输到500mb。 有人可以请我提供支持它的配置(或解决方案)吗?
感谢名单!
答案 0 :(得分: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>
更新确定,现在我看到您的配置正常 - 但 是您的客户端端点连接到??您没有定义任何address=
!
<client>
<endpoint name="FS.Services.FileTransferService"
address=""
binding="basicHttpBinding"
bindingConfiguration="streamedHttpBinding"
contract="FS.Services.IFileTransferService" />
</client>