2011-12-30 178 views
10

当我更新服务参考时,我最终得到:更新服务引用坚持要将Soap12添加到配置。

合同'MyService.MainServiceSoap'的端点配置节无法加载,因为找到了该合同的多个端点配置。请按名称指出首选的端点配置部分。

我的web.config结束这样的:

端点:

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

绑定:

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

我手动删除customBinding和SOAP12终点,一切工作正常。但是,如果我再次更新服务(右键单击“更新服务参考”),添加的自定义绑定会再次被添加,从而导致错误并需要手动从配置文件中删除。

有人知道如何解决这个问题吗?我不想/需要一个自定义的soap12绑定。

这是服务配置文件:

<?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> 
+0

您是否具有作为服务参考添加的访问服务? – 2012-01-15 06:47:28

+0

是的,我有两个点的开发者。 – 2012-01-16 18:12:46

+0

你是否在IIS托管,如果是的话,你在你的站点绑定中设置了什么,并允许应用程序中的协议? – 2012-01-19 13:35:36

回答

2

.NET 2.0中新的ASMX运行时支持SOAP 1.2。目前,SOAP 1.1被业界广泛使用。在.NET Framework中,支持SOAP 1.1和SOAP 1.2。这意味着在.NET Framework 2.0中创建的Web服务将被配置为支持SOAP 1.1和SOAP 1.2消息。这间接意味着为Web服务创建的WSDL将具有两种类型的绑定,即SOAP 1.1和SOAP 1.2。

Taken from here

这就是为什么正在生成两个绑定。

<remove name="HttpSoap12"/> 

我想这是我如何禁用这个现在我可以理解为什么你看到这是一个解决方法。 当您将Web服务移动到新框架时可能会导致这种情况,这就是为什么1.1上的一些较早的Web服务可能不会以相同的方式响应。 尝试定位2.0框架也许看到会发生什么。

+0

即时服务的创造者! – 2012-01-16 16:33:53

+0

是的,我知道删除它可以修复问题,但是当我更新服务时会再次添加该服务,并且如何防止将其添加到web.config中是原始问题。 – 2012-01-16 20:57:26

+0

将其从原始服务中移除,而非客户端。当你在客户端添加引用时,它将不再存在。 – 2012-01-16 21:02:59

-3

我只是svcutil.exe的手动调用重建我的代理类。简单得多。

3

没有可靠的解决方法。我投了你的问题。我是同样问题的受害者,虽然现在我切换到使用svcutil生成DLL但这个问题已经报告给微软在这里update-or-configure-an-existing-service-reference-in-sl-application-you-get-duplicate-binding-and-endpoint-information

他们说,它在VS2010中修复,但我确认它不是,我也安装了VS2010 SP1但是这在SP1中也不是固定的。所以这里没有给出修复,bug被关闭为'External'。奇怪。

在错误报告页面上,您还可以找到一种解决方法,但是我发现这很麻烦。

另一个解决方法是用结合名称硬编码,以避免重复端点

MyService.MainServiceSoap mainServiceSoap =新为MyService创建服务客户对象。MainServiceSoap( “MainServiceSoap”);

或者最后我们可以在微软打开另一个错误报告并投票解决它。

+0

它确实似乎是这种情况。我也使用VS2010SP1检查了您的发现 – Plippie 2012-01-20 16:12:51

+0

与Visual Studio 2012相同 – 2013-09-28 08:18:08

相关问题