我在将绑定属性拉入我的客户端服务配置时遇到问题。我正在服务器上运行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)?
谢谢!
答案 0 :(得分:0)
看来为了使用这些属性,我需要在服务的app.config以及客户端站点的web.config上更改值。这就是我能够让改变工作的方式。
如果我认为这是不正确的,请告诉我如何通过更新服务参考将这些更改过滤到客户端,我会将您的答案标记为正确。