10

When I update a Service Reference I end up with :

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

my web.config ends up like this:

endpoints:

  <endpoint address="http://localhost/main/MainService.asmx"
    binding="basicHttpBinding" bindingConfiguration="MainServiceSoap"
    contract="MyService.MainServiceSoap" name="MainServiceSoap" />
  <endpoint address="http://localhost/main/MainService.asmx"
    binding="customBinding" bindingConfiguration="MainServiceSoap12"
    contract="MyService.MainServiceSoap" name="MainServiceSoap12" />

bindings:

  <basicHttpBinding>
    <binding name="MainServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
      receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
      bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="655360" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="81920" maxArrayLength="163840"
        maxBytesPerRead="40960" maxNameTableCharCount="163840" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
  <customBinding>
    <binding name="MainServiceSoap12">
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
        messageVersion="Soap12" writeEncoding="utf-8">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
        maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
        bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
        keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
        realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
        useDefaultWebProxy="true" />
    </binding>
  </customBinding>

I manually delete customBinding and Soap12 endpoint and everything works fine. But if I update the service again (right click Update Service Reference) the added custom binding is added again causing error and the need to manually remove from config file.

Does someone knows how to fix this ? I don't want/need a custom soap12 binding.

This is the service config file:

<?xml version="1.0"?>
<configuration>
  <system.web>
    <globalization culture="es-PY" uiCulture="es-PY"/>
    <customErrors mode="Off"/>
    <webServices>
<!-- Tried adding and/or removing protocols and conformanceWarnings -->
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
<!-- -->
      <conformanceWarnings>
        <remove name="BasicProfile1_1"/>
      </conformanceWarnings>
    </webServices>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
  <system.serviceModel>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="standard" maxReceivedMessageSize="6553600" maxBufferSize="6553600" transferMode="Streamed" helpEnabled="true" automaticFormatSelectionEnabled="true">
          <readerQuotas maxStringContentLength="65536000" maxArrayLength="163840" />
        </standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints>
    <behaviors>
      <serviceBehaviors>
        <behavior>

          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above 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="true"/>

        </behavior>
      </serviceBehaviors>
    </behaviors>
<!-- Tried setting multipleSiteBindingEnalbed true and false -->
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
<!--  -->

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  <connectionStrings>
    <clear/>
    <add name="GamblingEntities" connectionString="..." providerName="System.Data.EntityClient" />
    <add name="GamblingSiteEntities" connectionString="..." providerName="System.Data.EntityClient" />
  </connectionStrings>
  <system.data>
    <DbProviderFactories>
      <clear/>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, &#xA;Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>
</configuration>
Bart Calixto
  • 19,210
  • 11
  • 78
  • 114

3 Answers3

3

The new ASMX runtime in .NET 2.0 supports SOAP 1.2. At this moment SOAP 1.1 is most widely being used in the industry. In the .NET Framework both SOAP 1.1 and SOAP 1.2 are supported. This means that the Web Services created in .NET Framework 2.0 will be configured to support both SOAP 1.1 and SOAP 1.2 messages. This indirectly means that the WSDLs thus created for the Web Service will have two types of bindings, i.e., SOAP 1.1 and SOAP 1.2.

Taken from here

This is why two bindings are being generated.

<remove name="HttpSoap12"/>

I guess this i how you disable this now i can understand why you see this as a workaround. Something may have caused this when you moved your web service to the new framework and this is why some of your older web services on 1.1 possibly don't respond in the same way. Try targeting 2.0 framework maybe to see what happens.

Community
  • 1
  • 1
Keith Beard
  • 1,601
  • 4
  • 18
  • 36
  • im the creator of the service! – Bart Calixto Jan 16 '12 at 16:33
  • Yes, I know removing it fixes the problem, but when I update the service this is added again, and how to prevent that from being added to web.config is the original question. – Bart Calixto Jan 16 '12 at 20:57
  • Remove it from the original service not the client. When you add a reference in the client it will no longer be there. – Keith Beard Jan 16 '12 at 21:02
  • BTW if you are updating the service that means you are the client, the client updates a service reference. You also might have some version deployed in the background containing the OLD code with both endpoints. I don't know why else, code isn't going to just be created unless you previously defined it. – Keith Beard Jan 16 '12 at 21:10
  • added the config file of the service, there's no such code on the service. – Bart Calixto Jan 16 '12 at 21:15
  • @Bart i do not know how you defined two endpoints and a custom binding. But somewhere in the service is binding information otherwise when you added a reference it would not have shown up. Somebody wrote do you not know where that is ? – Keith Beard Jan 16 '12 at 21:19
  • adding in protocol 'fixes' the problem but i see it more like a workaround than a real solution. why is this configuration getting generated? – Bart Calixto Jan 16 '12 at 21:22
  • searched on all solutions involved, MainServiceSoap12 found on .disco, .wsdl files, so i removed the service, clean the config file, added again and update, guess what : MainServiceSoap12 is there again! – Bart Calixto Jan 16 '12 at 21:33
  • you disable soap 1 ? ran your service removed all references in your client add it again at the mew development port and it regenerated it? – Keith Beard Jan 16 '12 at 21:37
  • i am curious i saw targetFramework="4.0" why is the service in asmx not wcf ? – Keith Beard Jan 16 '12 at 21:38
  • If i type then it won't generate the extra binding. I see it as a workaround, but i have other services that works just fine without the need of this tag We create the asmx and then changed to framework 4.0 because we found easier to work with asmx than with WCF. Also server is IIS 6.0 – Bart Calixto Jan 16 '12 at 21:40
3

There is no solid workaround. I voted up your question. I am a victim of same problem, Although now I switched to generating dll using svcutil but this issue has been reported to Microsoft here update-or-configure-an-existing-service-reference-in-sl-application-you-get-duplicate-binding-and-endpoint-information

They said, it's fixed in VS2010 but I confirm it's not, I have VS2010 SP1 installed too but this is not fixed in SP1 also. So there this no fix given and bug is closed as 'External'. strange.

On the bug report page, you can also find a workaround but I find that messy.

Another workaround is creating service client object with binding name hard-coded to avoid double endpoint

MyService.MainServiceSoap mainServiceSoap = new MyService.MainServiceSoap("MainServiceSoap");

or at last we can open another bug report at Microsoft and vote up to fix it.

SSA
  • 5,433
  • 4
  • 36
  • 50
-3

I just call svcutil.exe manually to rebuild my proxy class. Much simpler.

Rocklan
  • 7,888
  • 3
  • 34
  • 49