WCF 客户端无法通过 ServiceHost 连接到 IIS 中托管的 WCF 服务?

WCF client cannot connect to WCF service hosted in IIS via ServiceHost?

我有这个方案:

IIS

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>

我可以通过切换到端口 80 来解决它。

http://localhost/ClientService

不知何故行得通。我试图在任何地方向端口 8020 添加规则(甚至停止防火墙),检查任何端口转发、Azure 端点等。我的理论是,当服务器试图连接回(回调)到客户端并且没有权限或某物。我的猜测是 IIS 托管服务没有足够的权限进行回连。如果有人仍然可以阐明原因,我很乐意将答案切换给他们。但到目前为止,无论端口如何,我都很高兴它能正常工作。