使用 HTTPS 配置 WCF 时收到 404

Receiving 404 when configuring WCF with HTTPS

我部署了一个包含 MVC 部分和 WCF 部分的 .NET 4.5 站点。 WCF 托管在 IIS 中,它是 MVC 应用程序的 subapp/subsite。

我遇到的问题是当 MVC 调用 WCF 时我无法使 HTTPS 工作。 HTTP 工作,但只要我添加 HTTPS 配置,它就会停止工作。

这是我的配置: MVC:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IApplicationContract" >
                <security mode="Transport">  
                    <transport clientCredentialType="None"/>  
                </security>             
             </binding>
        </basicHttpBinding>        
    </bindings>
    <client>
        <endpoint address="https://mysiteaddress.com/wcf/MyService.svc/Application" 
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApplicationContract" 
            contract="MyServiceReference.IApplicationContract" name="BasicHttpBinding_IApplicationContract" />
    </client>
</system.serviceModel>

WCF:

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpStreaming" maxReceivedMessageSize="67108864" transferMode="Streamed">         
            <security mode="Transport">  
                <transport clientCredentialType="None"/>  
            </security>             
        </binding>
      </basicHttpBinding>     
    </bindings>
    <services>
        <endpoint address="Application" binding="basicHttpBinding" contract="MyService.Contract.IApplicationContract" />
      </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="MyServicebehavior">
                <serviceDebug includeExceptionDetailInFaults="True" />
                <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
</system.serviceModel>

我收到一条错误消息:

"EndpointNotFoundException: There was no endpoint listening at https://mysiteaddress.com/wcf/MyService.svc/Application that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.]"

如果在 MVC 配置中,我将端点地址更改为“http://localhost/wcf/MyService.svc/Application”并删除该元素,然后在 WCF 中删除,换句话说,删除所有 HTTPS 设置,一切正常!。

对于 HTTPs 设置,我之前遇到了一个安全错误配置错误,在我添加代码以启用 TLS 1.2 后错误消失了,因为它在 .NET 4.5 上默认情况下未启用。

有人知道我在这里缺少什么吗? IIS 具有绑定且 MVC 站点在 HTTPs 中运行良好,就在它尝试调用 WCF 时发生错误。

显然,对于 WCF 配置,在 HTTP 中,如果您确实在 basicHttpBinding 元素中指定了一个以上的绑定并在服务部分省略了 services/service/endpoint/@bindingConfiguration 属性,它将正常工作。但是,在 HTTPS 中,这会给您一个 404。因此请记住始终将 bindingConfiguration 属性添加到端点。