HTTPS 上的 WCF 生成 "The provided URI scheme ' https' 无效;预期为 'http'。”

标签 wcf ssl https iis-7.5

我一直在谷歌搜索我可能找到的所有地方(包括 Stackoverflow 上的此处)以找出一个错误我试图将 WCF 服务部署到 Windows 7 x64 上的 IIS 7.5,该服务仅通过具有基本 HTTP 身份验证的 SSL 运行。我在 IIS 中有一个站点,它使用自签名证书绑定(bind)到 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>

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

The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress

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

我已经多次调整服务器和客户端配置文件,但我已经忘记了,但上面的 web.config 文件是我迄今为止最好的猜测——它甚至不能在浏览器中运行,更不用说了WCF 客户端。

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

最佳答案

尝试将其添加到绑定(bind)中

<security mode="Transport"> 
    <transport clientCredentialType="None" proxyCredentialType="None" realm=""/> 
    <message clientCredentialType="Certificate" algorithmSuite="Default" />
</security> 

关于HTTPS 上的 WCF 生成 "The provided URI scheme ' https' 无效;预期为 'http'。”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11512969/

相关文章:

iphone - https 连接是否自动使用 ssl 加密数据

php - 通过 cURL 使用自签名证书通过 https 执行 soap 请求

c# - WCF 绑定(bind)中的 <readerQuotas> 是什么?

c# - 我希望能够使用 lambda 表达式来指定要通过 wcf 服务返回的值范围

c# - wcf get 方法 - 如何绑定(bind)到 View 模型?

ssl - 简单理解https协议(protocol)

api - 如何绕过 SSL 证书验证?

c# - Singleton vs PrEcision vs PerCall 状态管理

apache - 在 Apache 中选择 (TLS 1.3) 曲线

java - 如何在JAVA中从HTTPS url保存文件?