我在将绑定属性拉入客户端服务配置时遇到问题。我在服务器上运行 WCF 服务(作为 Windows 服务)。我首先尝试命名绑定,并使用 bindingConfiguration 属性将其应用于我的服务,但这不起作用。我看到其他人通过删除 name 属性将绑定设为默认值,这就是我现在所处的位置。WCF 项目的应用程序配置如下所示:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="6553600" maxBufferSize="6553600" />
</basicHttpBinding>
</bindings>
<client />
<services>
<service ... />
<service name="PdfWriterService.Service4">
<host>
<baseAddresses>
<add baseAddress="http://rsmreports:8733/PdfWriterService/v4" />
</baseAddresses>
</host>
<!-- Service Endpoints -->
<!-- Unless fully qualified, address is relative to base address supplied above -->
<endpoint address="" binding="basicHttpBinding" contract="PdfWriterService.IService4">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<!--<identity>
<dns value="localhost" />
</identity>-->
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="True" />
<!-- To receive exception details in faults for debugging purposes,
set the value below to true. Set to false before deployment
to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我的客户端站点(服务部分)上的 web.config 如下所示:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_PdfWriterServiceV4" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://rsmreports:8733/PdfWriterService/v4"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_PdfWriterServiceV4"
contract="PdfWriter.PdfWriterServiceV4" name="BasicHttpBinding_PdfWriterServiceV4" />
</client>
</system.serviceModel>
我是否缺少让客户端拥有这些属性(maxReceivedMessageSize 和 maxBufferSize)的东西?
谢谢!