为什么C#服务引用向导会生成重复的配置代码?

时间:2013-03-05 14:06:49

标签: c# visual-studio-2010 web-services soap

如果我在使用visual 2010服务引用向导引用Web服务之后查看app.config的输出,这就是我在app.config的basicHttpBinding节点中得到的内容:

        <basicHttpBinding>
            <binding name="FirmNameServiceSOAPServiceSoapBinding" 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="Transport">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
            <binding name="FirmNameServiceSOAPServiceSoapBinding1" 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>

节点binding name="FirmNameServiceSOAPServiceSoapBinding"binding name="FirmNameServiceSOAPServiceSoapBinding1"只是完全重复。

你知道原因吗?这对某事有帮助吗?

2 个答案:

答案 0 :(得分:0)

我简单地评论了第二个<Binding>节点。然后,它仍然可以正确构建和执行。

我认为这是一个MS Visual 2010错误,它正在污染应用程序配置文件。当试图了解正在发生的事情时,这无济于事。

答案 1 :(得分:0)

我的预感是您的服务正在暴露多个BasicHttpBindings。我会检查你的服务配置。

你可以看到她在类似路径上找到的WcfTestClient会发生什么:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe