获取与basicHttpBinding相关的错误消息,即使我正在使用wsHttpBinding

时间:2011-03-08 16:54:40

标签: c# .net wcf

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

  

合同需要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>

2 个答案:

答案 0 :(得分:2)

嗯......检查你的服务合同 - 这是一个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:// ....

答案 1 :(得分:0)

如果您已经发布了服务界面,我可以肯定地说,但我相信您的服务界面上有类似的内容:

 [ServiceContract(SessionMode = SessionMode.Required)]

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