我有这个方案:
IIS
- 主机: OperatorService.svc (连接到ClientService)
- Global.asax(启动时):通过 ServiceHost托管ClientService
WPF 客户端
- 连接到客户端服务
如果我去OperatorService服务被激活,Web 应用程序启动,并且ClientService成功托管在http://localhost:8020/ClientService
. 到目前为止,一切都很好。
我现在可以在浏览器中访问上述 URL 中的ClientService ,我可以通过Add Service Reference添加它。它就在那里——运行。
但是当我尝试通过生成的客户端连接(看起来不错)时,它突然不起作用。投掷:
There was no endpoint listening at http://localhost:8020/ClientService that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
此外,OperatorService连接到这个ClientService本身(它是一个 WsDualHttpBinding 来提供通知)。它正确地订阅了这个服务(调用一个方法)并且它可以工作(与我的 WPF 客户端相同的 URL)。
为什么我无法从我的 WPF 客户端连接?
WPF 客户端配置(仅相关部分):
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="Server.IClientService"
name="DefaultBindingClientService">
<identity>
<servicePrincipalName value="host/OHS-UPC" />
</identity>
</endpoint>
</client>
<bindings>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>
</bindings>
IIS 托管 web.config(用于ClientService)
<service name="TelPro.OHS.Server.Services.ClientService" behaviorConfiguration="UnsecuredBehavior">
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="DefaultBindingClientService" contract="TelPro.OHS.Server.Services.IClientService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8020/ClientService"/>
</baseAddresses>
</host>
</service>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService"/>
</wsDualHttpBinding>
<behavior name="UnsecuredBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
IIS 托管 web.config(用于 OperatorService -> ClientService)
<client>
<endpoint address="http://localhost:8020/ClientService" binding="wsDualHttpBinding"
bindingConfiguration="DefaultBindingClientService" contract="ClientNotificationServer.IClientService"
name="DefaultBindingClientService" />
</client>
<wsDualHttpBinding>
<binding name="DefaultBindingClientService" />
</wsDualHttpBinding>