【问题标题】:getting error message related to basicHttpBinding even though I'm using wsHttpBinding即使我正在使用 wsHttpBinding,也会收到与 basicHttpBinding 相关的错误消息
【发布时间】:2011-03-08 16:54:39
【问题描述】:

我试图在 wsHttpBinding 端点公开 WCF 服务,它给了我以下错误消息:

Contract 需要 Session,但是 Binding 'BasicHttpBinding' 不支持 或未正确配置为 支持一下。

界面如下:

[ServiceContract(Namespace="http://server.com/orderservices/",SessionMode=SessionMode.Required)]
public interface IOrderService
{
    [OperationContract(IsInitiating=true,IsTerminating=false)]
    string GetOrderNumber();

    [OperationContract(IsInitiating = false, IsTerminating = true)]
    void CreateOrder(string orderXML);
}

这是我的 web.config 文件(服务托管在 IIS 7 中):

<system.serviceModel>
   <bindings>
      <wsHttpBinding>
         <binding name="longTimeoutBinding" 
             receiveTimeout="00:10:00" sendTimeout="00:10:00">
         </binding>
      </wsHttpBinding>
   </bindings>
   <services>
      <service name="eMidWare.OrderService">
         <host>
            <baseAddresses>
                <add baseAddress = "http://localhost/" />
            </baseAddresses>
         </host>
         <!-- Service Endpoints -->
         <endpoint 
            address="" 
            binding="wsHttpBinding" bindingConfiguration="longTimeoutBinding"
            contract="eMidWare.IPricingDataService">
         </endpoint>
         <endpoint 
             address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
   </services>
   <behaviors>
      <serviceBehaviors>
         <behavior>
            <serviceDebug includeExceptionDetailInFaults="True" />
         </behavior>
      </serviceBehaviors>
   </behaviors>
</system.serviceModel>

【问题讨论】:

  • @marc_s,我什至无法使用指向 .svc 文件的浏览器在本地访问该服务。
  • 检查我的答案 - 我认为您的配置和服务合同文件不匹配....
  • 您的示例显示 IOrderService 合同,您的配置使用 IPricingDataService 合同。 IOrderService 在哪里使用?
  • @Ladislav,谢谢。我刚刚纠正了这个错误,但我仍然收到相同的错误消息。

标签: c# .net wcf


【解决方案1】:

嗯....检查您的服务合同 - 这是IOrderService

[ServiceContract(Namespace="http://server.com/orderservices/",SessionMode=SessionMode.Required)]
public interface IOrderService
{
}

但在您的配置中,您正在为eMidWare.IPricingDataService 设置端点

<endpoint 
    address="" 
    binding="wsHttpBinding" bindingConfiguration="longTimeoutBinding"
    contract="eMidWare.IPricingDataService">

因此,我相信 .NET / WCF 4 将启动一个默认端点,默认情况下,basicHttpBinding 用于 http:// 方案......

【讨论】:

  • 谢谢,马克。我相信你是对的,WCF 4 启动了默认端点。
【解决方案2】:

如果你发布了你的服务接口,我可以肯定地说,但我相信你的服务接口上有这样的东西:

 [ServiceContract(SessionMode = SessionMode.Required)]

这需要会话,BasicHttpBinding 不支持它。如果需要会话,则需要使用 wsHttpBinding。

【讨论】:

  • 问题是我在配置文件中使用的是wsHttpBinding,而不是basicHttpBinding。您可以在我上面发布的 web.config 中看到它。
  • .svc 文件在 c:\inetpub 目录中
猜你喜欢
  • 2021-07-09
  • 2018-07-11
  • 1970-01-01
  • 2016-02-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-10
  • 2020-10-13
相关资源
最近更新 更多