合约需要 Duplex,但绑定“BasicHttpBinding”;不支持它或未正确配置以支持它

发布于 2024-12-27 04:14:42 字数 826 浏览 2 评论 0原文

我的项目是silverlight并使用Ria服务。 我想创建一个 WCF 服务, 这是我的代码

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  public class MessageDuplex : IServiceSide
  {
    public void Attach(string s)
    {      
    }
  }

  [ServiceContract]
  interface IClientSide
  {
    [OperationContract(IsOneWay = true)]
    void SendMessage(string s);
  }

  [ServiceContract(CallbackContract = typeof(IClientSide))]
  interface IServiceSide
  {
    [OperationContract(IsOneWay = true)]
    void Attach(string s);
  }

当我在没有 CallbackContract 的情况下定义 IServiceSide 时,这会正确添加到 silverlight 项目中,但是当我使用 CallbackContract 时,添加 Service Referense 时会引发此错误: “合同需要 Duplex,但绑定‘BasicHttpBinding’不支持它,或者未正确配置以支持它。”

my project is silverlight and use Ria service.
I want to create a WCF Service,
this is my code

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
  [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
  public class MessageDuplex : IServiceSide
  {
    public void Attach(string s)
    {      
    }
  }

  [ServiceContract]
  interface IClientSide
  {
    [OperationContract(IsOneWay = true)]
    void SendMessage(string s);
  }

  [ServiceContract(CallbackContract = typeof(IClientSide))]
  interface IServiceSide
  {
    [OperationContract(IsOneWay = true)]
    void Attach(string s);
  }

When i defined IServiceSide without CallbackContract this is add to silverlight project correctly, but when i use CallbackContract this error raise when add Service Referense :
"Contract requires Duplex, but Binding 'BasicHttpBinding' doesn't support it or isn't configured properly to support it."

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

生来就爱笑 2025-01-03 04:14:42

BasicHttpBinding 不支持双工服务。您必须使用 PollingDuplexHttpBinding

BasicHttpBinding doesn't support duplex services. You must use PollingDuplexHttpBinding.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文