【问题标题】:Why does the WCF service with the following configuration not work?为什么如下配置的 WCF 服务不起作用?
【发布时间】:2014-03-29 15:36:22
【问题描述】:

我有一个带有以下配置文件的 WCF 服务。即使我指定了clientCredentialType = None,WCF 服务(来自 VS2013)也会抛出异常,说明未指定证书。

为什么会这样?仅当 clientCredentialType 设置为证书时才需要证书。

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding>
          <security mode="Message">
            <message clientCredentialType="Windows"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="WCFBindingwshttpBinding.Service1">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="" contract="WCFBindingwshttpBinding.IService1">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/WCFBindingwshttpBinding/Service1/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="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="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

【问题讨论】:

  • 什么时候得到异常,ServiceHost.Open()?您能否提供有关异常的更多详细信息。
  • 我同意 Petar 的观点。是客户端进程还是服务器异常?它是自托管服务器,还是托管在 IIS 之类的东西上?
  • 这是您的绑定规范。见this link
  • 尝试只使用basicHttpBinding。此外,如果这是您的意图,您的端点实际上并没有使用上面定义的 bindingConfiguration。请参阅此处了解如何执行我认为您正在尝试的简单示例:stackoverflow.com/questions/7043814/…
  • 设置为无。

标签: c# .net web-services wcf


【解决方案1】:

我认为您收到错误是因为您没有指定服务器证书。

我记得,WCF 在使用消息加密 (&lt;security mode="Message"&gt;) 时需要传输级别的安全性,以便安全地交换“共享密钥”并建立安全上下文。因此,既然您使用的是WSHttpBinding,那么服务器证书就是用来建立安全通道的。

以下链接提供了很好的相关信息:
WCF message security without certificate and windows auth

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-03-25
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 2018-07-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多