我将 WCF 与两个端点 basicHttpBinding 和 pollingDuplexHttpBinding 一起使用。在 Silverlight 4 中使用 WCF。如果我只有基本的.. 和轮询.. 效果很好。但是,如果我在一项服务和一项 silverlight 项目中同时使用,我会在客户端收到消息:
“服务参考配置中无法识别的元素‘pollingDuplexHttpBinding’。请注意,Silverlight 中只有一部分 Windows Communication Foundation 配置功能可用。”
WFC 正确引用了 silverlight 项目,但无法正常工作。这是 WCF 的 web.config:
<services>
<service behaviorConfiguration="Service1Behavior" name="Service1">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="LargeBuffer"
contract="IService1"
listenUri="http://localhost:7007/Service1.svc">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint
address=""
binding="pollingDuplexHttpBinding"
bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="ILongService1"
listenUri="http://localhost:7007/Service1.svc/LongService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
这是客户端的配置:
<endpoint address="http://localhost:7007/ServiceWebTDM.svc/LongService"
binding="pollingDuplexHttpBinding" bindingConfiguration="multipleMessagesPerPollPollingDuplexHttpBinding"
contract="GXWebTDM.Web.ILongServiceWebTDM" name="LongServiceWebTDMDev" />
<endpoint address="http://localhost:7007/ServiceWebTDM.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IServiceWebTDM1" contract="GXWebTDMService.IServiceWebTDM"
name="ServiceWebTDMDev" />