wcf - 基本 HTTP 绑定(bind)未正确配置

标签 wcf wcf-4

我已经使用 wsHTTPBinding 配置了 WCF 服务,但即便如此我还是得到了错误

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


这是服务契约(Contract)定义
<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>

非常感谢有关此问题的任何建议。

最佳答案

如果您使用的是 wcf 4.0,请打开 web.config/app.config 并在 <system.serviceModel> 中添加以下标签标签。

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

关于wcf - 基本 HTTP 绑定(bind)未正确配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4930403/

相关文章:

.net - 如何为 WCF 中的 [WebGet] 方法发出裸 XML?

c# - 从请求上下文中添加和检索数据

c# - WCF - 设置大文件下载超时

c# - WCF 4 关闭客户端代理

.net - EndpointNotFoundException 的可能原因是什么?

c# - WCF 公共(public)参数 ClientMessageInspector、DispatchMessageInspector 或替代方案?

.net - 从 IClientMessageInspector 获取请求 URI

c# - 如何在 web.config 中引用 DLL?

wcf - 在 Azure PaaS 上配置 MTU 大小