HTTPS 上的 WCF 生成“提供的 URI 方案‘https’无效;需要‘http’。”

2024-03-12

我一直在谷歌上搜索我能找到的所有地方(包括 Stackoverflow 上的这里),以找出我尝试将 WCF 服务部署到 Windows 7 x64 上的 IIS 7.5 时遇到的错误,该服务仅通过具有基本 HTTP 身份验证的 SSL 运行。我在 IIS 中有一个站点,它绑定到带有自签名证书的 HTTPS 端口 50443。 (我无法使用标准端口 443,因为我们计划将其部署到已运行 Tomcat 的服务器上的 IIS,该服务器正在侦听 80 和 443。)

这是 web.config:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <basicHttpBinding>
        <binding name="SSLBinding">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="HelloWorldWcf.HelloWorldWcfService">
        <endpoint name="HelloWorldWcf.HelloWorldWcfService" 
                  address="https://mylaptop:50443/HelloWorld/Service1.svc" 
                  binding="basicHttpBinding" 
                  bindingConfiguration="SSLBinding" 
                  contract="HelloWorldWcf.IHelloWorldWcfService"/>
        <endpoint address="https://mylaptop:50443/HelloWorld/Service1.svc/mex" 
                  binding="mexHttpsBinding" 
                  contract="IMetadataExchange"/>
      </service>
    </services>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

如果我浏览到服务端点地址并手动输入基本身份验证凭据,我的浏览器中会显示以下异常错误消息:

提供的 URI 方案“https”无效;预期为“http”。
参数名称:context.ListenUriBaseAddress

这与我尝试针对类似服务运行 WCF 客户端时遇到的错误相同,只不过它以“参数名称:via”结尾(因为调用堆栈中显示的方法的参数名称为“System.ServiceModel. Channels.TransportChannelFactory`1.ValidateScheme(URI via)”,实际上是“via”)。

我已经多次调整服务器和客户端配置文件,但我已经迷失了方向,但上面的 web.config 文件是我迄今为止最好的猜测 - 它甚至无法在浏览器中工作,更不用说在 WCF 客户端中工作了。

我需要做什么才能在非标准 SSL 端口上通过 HTTPS 进行基本 HTTP 身份验证来访问 IIS 7.5 中托管的 WCF 服务?帮助! (& 谢谢!)


尝试将其添加到绑定中

<security mode="Transport"> 
    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
    <message clientCredentialType="Certificate" algorithmSuite="Default" />
</security> 
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

HTTPS 上的 WCF 生成“提供的 URI 方案‘https’无效;需要‘http’。” 的相关文章

随机推荐