我创建了一个 WCF 服务,它接收字符串(Text/Json)作为请求,但问题是它只能接收长度为 65536(String.Length)的字符串。我通过谷歌搜索在下面尝试过(绑定 maxReceivedMessageSize="2147483647"),但没有任何变化,它只能接收 65536 的 String.Length 大小,仅此而已。我是 dotNet 和 WCF 词的新手,有人可以帮我向该服务发送大数据(我想向我的 WCF 服务发送大约 10MB 的数据)。
My Server Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="[my-service-name]">
<endpoint address="http://localhost:8005/MyService"
binding="webHttpBinding"
contract="[my-service-contract-name]"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>
My Service:
[OperationContract]
[WebInvoke(Method = "POST", UriTemplate = "MyService")]
void MyService(String input)
{
Console.WriteLine("Request data = " + input.Length);
}
Client Config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="name-here" maxReceivedMessageSize="2147483647">
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="behavior-here">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>