Svcutil generating bad config with multiple endpoints

Posted by vfilby on Stack Overflow See other posts from Stack Overflow or by vfilby
Published on 2010-04-19T18:58:07Z Indexed on 2010/04/19 19:03 UTC
Read the original article Hit count: 478

Filed under:
|
|
|

I have a WCF service that has exposed a soap and an xml endpoint. When I use svcutil to generate the proxy code on the client side the generated configuration contains two endpoints which causes the client to fail. If I edit the web.config file and remove the second endpoint (with the custom binding) all works as expected. Is there a way I can get svcutil to generate a config that just works so that I don't need to hand edit the file everytime?

Client-side error:

An endpoint configuration section for contract 'MyNamespace.ITestService' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.

Svcutil command:

svcutil http://api.local/Test.svc
    /reference:bin\MyNamespace.Interface.dll 
    /config:web.config 
    /mergeConfig 
    /out:"Service References\TestService.cs" 
    /n:*,MyNamespace

Generated client config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_ITestService" 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>
        <customBinding>
            <binding name="CustomBinding_ITestService">
                <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
                    messageVersion="Soap12" writeEncoding="utf-8">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                </textMessageEncoding>
            </binding>
        </customBinding>
    </bindings>
    <client>
        <endpoint address="http://api2.local/Test.svc/soap" binding="basicHttpBinding"
            bindingConfiguration="BasicHttpBinding_ITestService" contract="MyNamespace.ITestService"
            name="BasicHttpBinding_ITestService" />
        <endpoint binding="customBinding" bindingConfiguration="CustomBinding_ITestService"
            contract="MyNamespace.ITestService" name="CustomBinding_ITestService" />
    </client>
</system.serviceModel>

© Stack Overflow or respective owner

Related posts about wcf

Related posts about soap