2011-09-24 76 views
3

我有一個包含WCF服務項目和單元測試項目的VS 2010解決方案。單元測試項目具有對WCF服務的服務引用。WCF服務參考支持文件不更新

的Web.config WCF服務項目設置一個號碼綁定屬性與其他超默認值:

的web.config:(具體地注意MAXBUFFERSIZE = 「」)

<basicHttpBinding> 
    <binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> 
     <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Ntlm"/> 
     </security> 
    </binding> 
</basicHttpBinding> 

在檢查this issue時,我意識到單元測試項目的服務引用支持文件不包含我期望的值(即在WCF服務的web.config中配置的值):

configuration.svcinfo: (具體地注意MAXBUFFERSIZE = " ")

<binding hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" messageEncoding="Text" name="BasicHttpBinding_IBishopService" textEncoding="utf-8" transferMode="Buffered"> 
    <readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192" /> 
    <security mode="None"> 
     <message algorithmSuite="Default" clientCredentialType="UserName" /> 
     <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> 
    </security> 
    </binding> 

刪除和重新創建服務引用或更新服務引用重新創建文件,但我仍然會得到相同的價值觀。

爲什麼?

更新

這裏的客戶

<binding name="BasicHttpBinding_IMyService" closeTimeout="00:01:00" 
        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" 
        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" 
        maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000" 
        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" 
        useDefaultWebProxy="true"> 
        <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000" 
         maxBytesPerRead="200000000" maxNameTableCharCount="200000000" /> 
        <security mode="None"> 
         <transport clientCredentialType="None" proxyCredentialType="None" 
          realm="" /> 
         <message clientCredentialType="UserName" algorithmSuite="Default" /> 
        </security> 
       </binding> 

回答

0

同樣的問題在這裏,沒有解決方案後半天搞亂配置文件...更改自動生成的文件通常是皺眉,所以我的感覺說「有一個更好的方法,丹尼斯」。

更新:我通過刪除綁定配置中的name屬性來解決我的問題。 因此你目前的網站。配置是這樣看

<basicHttpBinding> 
    <binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> 
    <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Ntlm"/> 
    </security> 
    </binding> 
</basicHttpBinding> 

將成爲

<basicHttpBinding> 
    <binding maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000"> 
    <readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/> 
    <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Ntlm"/> 
    </security> 
    </binding> 
</basicHttpBinding> 

我想你只需要在這個客戶端。據我所知,通過刪除名稱屬性,本質上可以更改您的應用的默認basicHttpBinding配置。此解決方案的信貸here

另一個更新:如果你正確地命名你的服務配置(包括命名空間),它會選擇綁定配置。因此,而不是

<service name="ServiceName"> 

你需要

<service name="My.Namespace.ServiceName"> 
+0

當我從客戶端的app.config中的'<綁定...>'中刪除'name'屬性並更新服務引用時,我收到一個錯誤,抱怨找不到指定的綁定。當我從'

+0

如果它抱怨找不到指定的綁定,那就意味着它正在選取並有效地使用該配置。客戶端和服務器綁定配置現在是否一樣?你可以使用兩者的服務配置更新你的文章嗎? –

0

這是正確的行爲的app.config。綁定中包含的一些信息僅適用於配置的一側,客戶端和服務器都可以使用完全不同的值。此外,這些值可防禦拒絕服務附加,因此服務不希望公開顯示它們。

這些值僅影響傳入消息的處理,因此服務會配置它如何處理傳入請求,並且客戶端會配置它如何處理傳入響應。請求和響應可以具有不同的特徵和不同的配置。如果服務只收到幾個KB請求並返回1MB響應,則不需要配置接受1MB請求的服務。

Btw。這是與通用Web服務無關的WCF特定功能,因此在WSDL中沒有標準化的方式來描述它。

+0

如果這是正確的行爲,什麼是改變這些值正確的程序?正在應用的默認(?)值不適用於我的特定應用程序(這就是爲什麼我開始探索設置)。 –

+0

您將根據需要修改客戶端上的值。 –

+0

我已經修改了客戶端的app.config中的設置,但這些也沒有反映在生成的文件中,並且出現與設置太小有關的錯誤。 App.config添加到問題。 –