WCF over SSL 问题

标签 wcf ssl https

我在 IIS 6 中有一个 WCF Web 服务,并试图让它通过 SSL 工作。当我调用该服务时,出现以下错误:

无法处理消息。这很可能是因为操作“http://tempuri.org/IARPolicyComposer/GetTemplatesList”不正确,或者因为消息包含无效或过期的安全上下文 token ,或者因为绑定(bind)之间存在不匹配。如果服务由于不活动而中止 channel ,则安全上下文 token 将无效。为防止服务过早中止空闲 session ,增加服务端点绑定(bind)的接收超时。

这是服务配置:

<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
  <wsHttpBinding>
    <binding name="WSHttpBinding_IARPolicyComposer">
      <security mode="Transport">
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="PolicyComposer.ARPolicyComposerBehavior" name="PolicyComposer.ARPolicyComposer">
            <endpoint address="" binding="wsHttpBinding" contract="PolicyComposer.IARPolicyComposer">
            </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services> 
<behaviors>
<serviceBehaviors>
<behavior name="PolicyComposer.ARPolicyComposerBehavior">
    <serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
 <serviceMetadata httpGetEnabled="true" />
 <serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>

客户端配置:

  <wsHttpBinding>
    <binding name="WSHttpBinding_IARPolicyComposer" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Transport">
      </security>
    </binding>
  </wsHttpBinding>

服务和客户端都在同一个域中。

最佳答案

你有

<serviceMetadata httpGetEnabled="true" /> 

不应该吗

<serviceMetadata httpsGetEnabled="true" />

注意 httpsGetEnabled 中的 s...

如果你问我这部分可以删除,因为它没有被端点使用......

<behavior name="">  
  <serviceMetadata httpGetEnabled="true" />  
  <serviceDebug includeExceptionDetailInFaults="false" /> 
</behavior>

如何将 mex 绑定(bind)更改为

binding="mexHttpsBinding"

关于WCF over SSL 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7649467/

相关文章:

wcf - WCF MSMQ 4.0 中的中毒消息处理

c# - 使用 DI 和 InstanceContextMode.Percall 的自定义 ServiceHost

java - Http Get 请求 - 实际发送什么数据?

c# - Windows 服务托管 TCP WCF 服务

c# - WCF 以 JSON 格式返回 double 并在昏迷后限制数字

java - 使用 Java 连接到带有 key 、证书和 cacert 文件而不是 .p12 文件的 RabbitMQ (TLS)

jquery - 在没有 SSL 的情况下将 Wufoo 链接到外部样式表

web-services - 带有 ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED 错误消息的 THttpRio https (Wininet)

android - OKHTTP 安全吗?

amazon-web-services - AWS S3 图像仅通过 HTTP 提供服务,但 Chrome 升级到 HTTPS