WCF绑定到HTTPS

ste*_*yer 16 wcf .net-3.5

我知道有很多关于这个的帖子,我已经浏览了所有这些我的搜索并实现了所提到的所有内容.我有一个WCF Web服务,可以在我的本地系统上使用HTTP,它可以在HTTP上的服务器上运行.但客户端要求通过HTTPS工作.这个站点和其他站点上的帖子的镜像表明,这并不像应该的那样直截了当,因为在此之前,ASMX Web服务"只是工作"并且不需要复杂的配置.

我的当前配置出现以下错误:

找不到与绑定WSHttpBinding的端点的方案https匹配的基址.注册的基地址方案是[http].

这是我这段时间的代码,经过几天的努力来配置这个工作无济于事:

<system.serviceModel>

    <!--     -->
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="true" >
        <baseAddressPrefixFilters>
            <add prefix="https://mysite.com"/>
            <add prefix="http://mysite.com"/>
        </baseAddressPrefixFilters>
    </serviceHostingEnvironment>

    <!-- Set up Custom Behaviors -->    
    <behaviors>

        <endpointBehaviors>
        </endpointBehaviors>

        <serviceBehaviors>
            <behavior name="WebPostService.WebPostServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" httpsGetUrl="WebPostServices.svc/mex"  /> 
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>

    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>

        <wsHttpBinding>
            <binding    name="SOAPBinding" 
            >

                <security mode="Transport">
                </security>
            </binding>
        </wsHttpBinding>

    </bindings>

    <services>

        <service    
                    behaviorConfiguration="WebPostService.WebPostServiceBehavior"
                    name="WebPostService.WebPostService"
        >

    <host>
      <baseAddresses>
        <add baseAddress="https://mysite.com/Services/WebPostService.svc"/>
      </baseAddresses>
    </host>
            <endpoint   address="" 
                        binding="wsHttpBinding" 
                        bindingConfiguration="SOAPBinding"
                        contract="WebPostService.IWebPostService"
            >
                <identity>
                    <dns value="mysite.com" />
                </identity>
            </endpoint>

            <endpoint   
                        address="mex" 
                        binding="mexHttpsBinding" 
                        contract="IMetadataExchange" 
            >
            </endpoint>

        </service>

    </services>

</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

我做错了什么,如何让它通过HTTPS工作?我很沮丧,这不是应该的那么简单.我已经在MSDN的WCF文档中埋葬了这个项目的几个月,并且很好地掌握了服务,端点和绑定 - 足以让我感到沮丧甚至比我根本不知道的更多.

更新:仍然在努力,当我尝试将完整的URL放入mex地址时,我遇到了一个奇怪的错误.我改为:

address="https://prcwebs.com/Services/WebPostService.svc/mex" 
Run Code Online (Sandbox Code Playgroud)

并得到错误:

此服务的安全设置需要Windows身份验证,但不支持承载此服务的IIS应用程序.

我不是尝试使用Windows身份验证,安全设置没有更改,仍然设置为

<security mode ="Transport"/>

找不到与绑定WebHttpBinding的端点的方案https匹配的基址.注册的基地址方案是[http] - 没有帮助,没有提到任何帮助 无法找到与端点绑定WSHttpBinding的方案http匹配的基地址 - 我正在使用传输安全性,这不适用.尝试改变到不同的安全模式,仍然无法让网站工作.

Luu*_*uuk 5

添加multipleSiteBindingsEnabled="true"serviceHostingEnvironment更新安全性以禁用客户端凭据:

<security mode="Transport">
    <transport clientCredentialType="None"></transport>
</security>
Run Code Online (Sandbox Code Playgroud)

编辑 我在 Windows 2003 下的最终工作版本具有以下配置。

<system.serviceModel>
    <serviceHostingEnvironment  aspNetCompatibilityEnabled="false" />

    <!-- Set up Custom Behaviors -->    
    <behaviors>
        <endpointBehaviors>
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="WebPostService.WebPostServiceBehavior">
                <serviceMetadata httpsGetEnabled="true" httpsGetUrl="WebPostServices.svc/mex"  /> 
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <!-- Set up the binding configuration  -->
    <bindings>
        <wsHttpBinding>
            <binding name="SOAPBinding">
                <security mode="Transport">
                  <transport clientCredentialType="None"/>
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>

    <services>
        <service behaviorConfiguration="WebPostService.WebPostServiceBehavior"
                 name="WcfService2.Service1">

            <host>
                <baseAddresses>
                    <add baseAddress="https://localhost/Service/Service1.svc"/>
                </baseAddresses>
            </host>
            <endpoint address="" 
                      binding="wsHttpBinding" 
                      bindingConfiguration="SOAPBinding"
                      contract="WcfService2.IService1">
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>

            <endpoint address="mex" 
                      binding="mexHttpsBinding" 
                      contract="IMetadataExchange">
            </endpoint>
        </service>
    </services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)

您可以使用 https 访问该网站,所以我猜安装的证书部分是正确的。如果您有任何想要与我的设置进行比较的内容,请告诉我。