2009-06-22 38 views
1

我正在使用VSTS 2008 + C#+ .Net 3.0。我正在使用自託管的WCF。執行以下語句(host.Open())時,會出現以下找不到的綁定錯誤。我發佈了我的整個app.config文件,任何想法是什麼錯誤?WCF wsHttpBinding'algorithmSuite'無法解析錯誤

ServiceHost host = new ServiceHost(typeof(MyWCFService)); 
host.Open(); 

錯誤消息,

屬性 'algorithmSuite' 的值不能被解析。錯誤是:值'Aes128'不是'System.ServiceModel.Security.SecurityAlgorithmSuite'類型的有效實例。

EDIT1:我已經改變了算法西裝期權價值爲默認值,但執行Open()時遇到了一個新的錯誤,錯誤消息是,任何想法什麼是錯的,

綁定驗證失敗,因爲WsHttpBinding的呢不支持傳輸安全性(HTTPS)上的可靠會話。渠道工廠或服務主機無法打開。使用消息安全性通過HTTP實現安全可靠的消息傳遞

完整的app.config,

<?xml version="1.0"?> 
<configuration> 
    <system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="MyBinding" 
      closeTimeout="00:00:10" 
      openTimeout="00:00:20" 
      receiveTimeout="00:00:30" 
      sendTimeout="00:00:40" 
      bypassProxyOnLocal="false" 
      transactionFlow="false" 
      hostNameComparisonMode="WeakWildcard" 
      maxReceivedMessageSize="100000000" 
      messageEncoding="Mtom" 
      proxyAddress="http://foo/bar" 
      textEncoding="utf-16" 
      useDefaultWebProxy="false"> 
      <reliableSession 
       enabled="false" /> 
      <security mode="Transport"> 
      <transport clientCredentialType="Digest" 
       proxyCredentialType="None" 
       realm="someRealm" /> 
      <message clientCredentialType="Windows" 
      negotiateServiceCredential="false" 
      algorithmSuite="Default"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="MyWCFService" 
       behaviorConfiguration="mexServiceBehavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://localhost:9090/MyService"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IMyService"/> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="mexServiceBehavior"> 
      <serviceMetadata httpsGetEnabled="True"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration> 

由於事先 喬治

+1

喬治,我可以提個建議這裏,而不是嘗試調試每次迭代中,你可以張貼問題詳細說明您正在努力實現,並要求適當的配置是什麼?一點也不清楚你想要認證/授權/安全。 – blowdart 2009-06-22 09:48:37

+0

我只想用wsHttpBinding開發一個服務,那麼簡單!我正在使用Windows集成安全性,因爲我在Windows域中。 – George2 2009-06-22 09:57:07

+1

如果你在Windows域 - 爲什麼不使用netTcp?更快,更可靠,更好,更少的開銷? :-) – 2009-06-22 10:00:10

回答

3

你需要更新您的服務行爲也一樣,如果你改變從http MEX端點HTTPS - 你需要使httpsGetEnabled設置(不是httpGetEnabled):

<behaviors> 
     <serviceBehaviors> 
     <behavior name="mexServiceBehavior"> 
      <serviceMetadata httpsGetEnabled="True"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 

更新
喬治,看看這個MSDN link - 沒有「Aes128」算法 - 你必須選擇一個現有的算法。

更新2:

你可以試試這個配置 - 減少到了極致! :-)

<system.serviceModel> 
    <bindings> 
     <wsHttpBinding> 
     <binding name="MyBinding" 
      maxReceivedMessageSize="100000000" 
      messageEncoding="Mtom" 
      proxyAddress="http://foo/bar" 
      textEncoding="utf-16" 
      useDefaultWebProxy="false"> 
      <reliableSession enabled="false" /> 
      <security mode="None" /> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 
    <services> 
     <service name="MyWCFService" 
       behaviorConfiguration="mexServiceBehavior"> 
     <host> 
      <baseAddresses> 
      <add baseAddress="https://localhost:9090/MyService"/> 
      </baseAddresses> 
     </host> 
     <endpoint address="" binding="wsHttpBinding" bindingConfiguration="MyBinding" contract="IMyService"/> 
     <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="mexServiceBehavior"> 
      <serviceMetadata httpsGetEnabled="True"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

你就可以開始你的服務,你可以從Visual Studio中添加服務引用?

更新3
喬治,我建議你看一下這些安全相關的鏈接,並得到一些感受你真正需要的和想要的 - 以及如何去實現它。

馬克