9

对于 app.config 中的简化 WCF 配置,我需要做的最小客户端设置是什么?

默认是这样的:

    <bindings>
        <wsHttpBinding>
            <binding name="WSHttpBinding_IService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                allowCookies="false">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00"
                    enabled="false" />
                <security mode="Message">
                    <transport clientCredentialType="Windows" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="Windows" negotiateServiceCredential="true"
                        algorithmSuite="Default" establishSecurityContext="true" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>

我可以排除什么,我需要多少?


编辑:我应该开始撕掉零件直到它破裂吗?我希望能找到一些人们很幸运的优化好的 wsHttpBindings。

4

3 回答 3

8

Jerograv 是对的,因为这些都是默认值,您可以忽略所有这些。为了测试这一点,我创建了一个简单的服务并创建了所需的最小配置,这几乎是地址、绑定和合同——

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.serviceModel>
        <client>
            <endpoint address="http://sabra2/TestService/Service1.svc" binding="wsHttpBinding"
                contract="IService1"/>
        </client>
    </system.serviceModel>
</configuration>
于 2009-01-16T14:36:21.200 回答
7

请记住 WCF 的 ABC。地址,绑定,合同。这就是你所需要的!

您的客户端只需要有一个端点即可与 WCF 服务通信。每个端点只需要描述每个 ABC 就完成了。其他的东西可以稍后补上。

这就是我不喜欢在 Visual Studio 中添加服务引用的原因之一。

于 2009-01-17T18:13:52.883 回答
4

我想你会发现所有这些都是可选的。无论如何,该特定绑定中的所有这些东西都是默认值。

事实上,在这种情况下,我认为在端点中指定绑定是可选的。

于 2009-01-16T00:35:41.197 回答