2011-02-08 71 views
6

我已经配置了WsHttpBinding的WCF服务但即使如此,我得到的错误基本HTTP绑定配置不正确

Contract requires Session, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it. 

这里的服务合同定义

<ServiceContract(SessionMode:=SessionMode.Required)> 
Public Interface IPrivateService 

这里是服务实施定义

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)> 
Public Class PrivateService 
    Implements IPrivateService 

下面是配置设置

<services> 
    <service behaviorConfiguration="behaviorAction" name="Viking.Service.PrivateService"> 
      <endpoint address="RequiredService" binding="wsHttpBinding" bindingConfiguration="bindingAction" contract="Viking.Service.IPrivateService"> 
       <identity> 
       <dns value="localhost"/> 
       </identity> 
      </endpoint> 
      <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
      </service> 
</services> 
<bindings> 
      <wsHttpBinding> 
      <binding name="bindingAction" transactionFlow="false" sendTimeout="00:30:00" receiveTimeout="00:30:00"> 
       <reliableSession enabled="true"/> 
      </binding> 
      </wsHttpBinding> 
</bindings> 

真正体会到在这个问题上的任何建议。

回答

24

如果您使用wcf 4.0,则打开web.config/app.config并在<system.serviceModel>标记内添加以下标记。

<protocolMapping> 
    <add scheme="http" binding="wsHttpBinding"/> 
</protocolMapping> 
+0

工作。万分感谢 ! – Vikram 2011-02-08 08:28:23