2
我添加了一个WCF服务引用Silverlight应用程序和这里是从web.config中,我有看起来像Silverlight和双工WCF服务
<bindings>
<wsDualHttpBinding>
<binding name="wsDualHttpBinding">
<security mode="None" />
</binding>
</wsDualHttpBinding>
<pollingDuplexHttpBinding>
<binding name="multipleMessagesPerPollPollingDuplexHttpBinding"
duplexMode="MultipleMessagesPerPoll" />
</pollingDuplexHttpBinding>
</bindings>
约束力和我有这样的片段,以创建服务客户端实例
var serviceClient = new DuplexCallerIdServiceClient(
new PollingDuplexHttpBinding(PollingDuplexMode.MultipleMessagesPerPoll),
new EndpointAddress("http://localhost:51445/Service/MyService.svc"));
我担心的是为什么我必须在代码中提供绝对网址。我有一个使用相同服务的winforms应用程序,我只需要执行new DuplexCallerIdServiceClient()
即可创建一个看起来很理想的服务客户端实例。有什么办法可以解决它吗?我无法更改绑定设置。
谢谢
您可以调用不带参数的服务客户端构造函数的原因是该地址是在app.config中指定的。如果你不喜欢这个网址是绝对的,你可以使用一个相对的网址,比如'../MyService.svc' – vorrtex