WCF over SSL 问题

发布于 2024-12-08 01:18:05 字数 2288 浏览 0 评论 0原文

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

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

以下是服务配置:

<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>

服务和客户端都位于同一域中。

I have a WCF web service in IIS 6 and trying to get it to work over SSL. When I call the service I get the following error:

The message could not be processed. This is most likely because the action 'http://tempuri.org/IARPolicyComposer/GetTemplatesList' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.

Here is the service config:

<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>

Client's config:

  <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>

Both service and client are on the same domain.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白衬杉格子梦 2024-12-15 01:18:05

<serviceMetadata httpGetEnabled="true" /> 

不应该注意

<serviceMetadata httpsGetEnabled="true" />

httpsGetEnabled 中的 s...

如果您问我这部分可以删除,因为端点不使用它...

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

如何将 mex 绑定更改为

binding="mexHttpsBinding"

You have

<serviceMetadata httpGetEnabled="true" /> 

Shouldn't it be

<serviceMetadata httpsGetEnabled="true" />

Mind the s in httpsGetEnabled...

And if you ask me this part can be removed since it is not used by an endpoint...

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

How about changing the mex binding to

binding="mexHttpsBinding"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文