0

我想在我的服务中启用 (SessionMode=SessionMode.Required),所以当我启用它时,然后使用 WCF Client Test 测试服务,它会引发以下错误:

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

URI: http://localhost:7645/PublisherService.svc    

HTML 文档不包含 Web 服务发现信息。

<system.serviceModel>

    <bindings>
        <basicHttpBinding>
            <binding name="myBasicBinding"  maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" closeTimeout="00:01:00" openTimeout="00:01:00" sendTimeout="00:01:00" receiveTimeout="00:01:00">
                <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
            </binding>

        </basicHttpBinding>

   <!--enable WSHTTPBinding session-->
  <wsHttpBinding>
    <binding name="bindingAction" transactionFlow="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"  sendTimeout="00:01:00"   receiveTimeout="00:01:00" closeTimeout="00:01:00" openTimeout="00:01:00">
      <readerQuotas maxDepth="128" maxStringContentLength="8388608" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="2147483647"/>
      <reliableSession enabled="true"/>
      <security mode="Transport">
        <message establishSecurityContext="false" clientCredentialType="IssuedToken"/>
      </security>  
    </binding>
  </wsHttpBinding>

</bindings>

 <protocolMapping>
  <add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
<services>
  <service name="AllChatService.PublisherService"  behaviorConfiguration="metadataSupport">    
    <host>
      <baseAddresses>
        <add baseAddress ="http://localhost:7645/"/>
      </baseAddresses>
    </host>
    <endpoint contract="AllChatService.PublisherService" binding="wsHttpBinding" address=""/>
    <!--Enable Meta Data Publishing-->
    <endpoint address="mex"  binding="mexHttpBinding"  contract="IMetadataExchange"/>
  </service>
</services>

 <behaviors>
    <serviceBehaviors>
    <behavior name="metadataSupport">
      <serviceDebug includeExceptionDetailInFaults="False" />

   <!--Enable WSDL Data Binding-->
      <serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
    </behavior>
  </serviceBehaviors>


    </behaviors>

<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>




[ServiceBehaviorAttribute(InstanceContextMode = InstanceContextMode.PerCall)]
public class PublisherService : IPublisher
{
}

[ServiceContract(SessionMode = SessionMode.Required)]
public interface IPublisher
{
}

那么任何人都可以帮助我解决这个问题。

4

1 回答 1

0

删除线

<security mode="Transport">

从您的 web.config 文件中。因为传输似乎需要 HTTPS 来加密凭据。

于 2013-06-19T16:11:39.087 回答