【发布时间】:2012-12-22 22:47:17
【问题描述】:
我有一个 WCF 服务和一个 Silverlight 5 客户端。 我定义了以下接口:
[ServiceContract(Namespace = "Silverlight", CallbackContract = typeof(IDuplexClient))]
public interface IDuplexService
{
[OperationContract]
void Subscribe(string userId);
[OperationContract]
void Unsubscribe(string userId);
}
[ServiceContract]
public interface IDuplexClient
{
[OperationContract(IsOneWay = true)]
void PushNotification(string msg);
}
这是我的 Web.config 文件:
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
当我尝试运行我得到的服务时:
由于编译过程中出现异常,无法激活服务“/ServerService.svc”。异常消息是:Contract requires Duplex,但 Binding 'BasicHttpBinding' 不支持或未正确配置以支持它。
我知道我需要向 Web.config 添加一些属性,但是无论我在哪里(以及我尝试过的任何东西),我都无法让它工作。
我是 WCF 的新手,希望您能就该主题提供帮助。我所有的谷歌搜索都让我无处可去,在这里问同样问题的人得到的答案对我不起作用。
所以我决定放弃搜索,只是问问。
更新:我使用此链接创建界面 - http://msdn.microsoft.com/en-us/library/cc645027%28v=vs.95%29.aspx
【问题讨论】:
标签: c# wcf silverlight wcf-binding duplex