WCF最小客户端app.config设置

时间:2021-10-03 14:10:54

What are the minimal client settings i need to do for a streamlined WCF config in the app.config?

在app.config中为简化的WCF配置需要做的最小客户端设置是什么?

The default one is this:

默认的是:

    <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>

What can I exclude, and how much of that do i need?

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


Edit: Should i just start ripping out parts till it breaks? I was hoping to find some good optimized wsHttpBindings that people have good luck with.

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

3 个解决方案

#1


Jerograv is right, given that these are all defaults you can omit all of them. To test this I've created a simple service and created the minimal config required which is pretty much the address, the binding and the contract-

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>

#2


Just remember the ABC's of WCF. Address, Binding, Contract. That's all you need!

只记得WCF的ABC。地址,装订,合同。这就是你所需要的!

Your client only has to have an endpoint to talk to a WCF Service. Each endpoint only needs to describe each of the ABC's and you're done. The other stuff can be tacked on later.

您的客户端只需要有一个端点与WCF服务通信。每个端点只需要描述每个ABC,你就完成了。其他的东西可以在以后加以解决。

That's one reason I'm not a big fan of adding Service References in Visual Studio.

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

#3


I think you'll find that all of that is optional. All of those things in that particular binding are the defaults anyway.

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

In fact I think specifying the binding at all in the endpoint would be optional in this case.

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

#1


Jerograv is right, given that these are all defaults you can omit all of them. To test this I've created a simple service and created the minimal config required which is pretty much the address, the binding and the contract-

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>

#2


Just remember the ABC's of WCF. Address, Binding, Contract. That's all you need!

只记得WCF的ABC。地址,装订,合同。这就是你所需要的!

Your client only has to have an endpoint to talk to a WCF Service. Each endpoint only needs to describe each of the ABC's and you're done. The other stuff can be tacked on later.

您的客户端只需要有一个端点与WCF服务通信。每个端点只需要描述每个ABC,你就完成了。其他的东西可以在以后加以解决。

That's one reason I'm not a big fan of adding Service References in Visual Studio.

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

#3


I think you'll find that all of that is optional. All of those things in that particular binding are the defaults anyway.

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

In fact I think specifying the binding at all in the endpoint would be optional in this case.

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