WCF wsHttpBinding'algorithmSuite'无法解析错误

时间:2009-06-22 09:08:13

标签: c# visual-studio-2008 wcf binding wshttpbinding

我使用的是VSTS 2008 + C#+ .Net 3.0。我正在使用自托管的WCF。执行以下语句(host.Open())时,会出现以下绑定未找到错误。我发布了我的整个app.config文件,任何想法有什么问题?

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

错误讯息

无法解析属性“algorithmSuite”的值。错误是:值'Aes128'不是'System.ServiceModel.Security.SecurityAlgorithmSuite'类型的有效实例。

EDIT1:我已将算法套装选项值更改为Default,但在执行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>
提前谢谢, 乔治

2 个答案:

答案 0 :(得分:3)

如果您将MEX端点从http更改为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
乔治,我建议你看看那些与安全相关的链接,并了解你真正需要和想要的东西 - 以及如何实现它。

马克

答案 1 :(得分:2)

错误消息是正确的,您没有通过WSHttp获得可靠的消息,您需要使用custom binding and protocol