2011-12-30 56 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

相關問題