提供的URI方案“https”无效;预计'http'。参数名称:via for HTTPS

时间:2015-08-25 14:03:10

标签: wcf https wcf-hosting

以下是该方案。

我们有F5负载均衡器,传入请求作为HTTP进入F5负载均衡器,然后它们作为HTTP重定向到WCF服务服务器。

我已经尝试了几乎所有可能的配置组合,但它不断给出两个不同的错误。例如,根据一些建议,我尝试将安全模式更改为“传输”,然后错误更改为如下:“无法为具有权限的SSL / TLS建立安全通道'xxx.xxx.xxx.xxx:XXXX' 。“

服务器配置:

<system.serviceModel>
    <services>
      <service behaviorConfiguration="NameofServiceBehaviour" name="NameOfServices">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndPointBinding" name="wsHttpEndPoint" contract="Name.IContractName" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="wsHttpEndPointBinding">
          <security mode="None"> 
        <!-- <transport clientCredentialType="Certificate" /> -->
      </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehaviourName">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <!-- <serviceCredentials>
            <serviceCertificate findValue="CN=CertificateName" storeLocation="LocalMachine" />
          </serviceCredentials> -->
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>

客户端配置:

<system.serviceModel>
        <bindings>
            <wsHttpBinding>
                <binding name="wsHttpEndPoint">
                    <security mode="None" />
                </binding>
            </wsHttpBinding>
        </bindings>
        <client>
            <endpoint address="https://URL.svc"
                binding="wsHttpBinding" bindingConfiguration="wsHttpEndPoint"
                contract="Name.IContractName" name="wsHttpEndPoint" />
        </client>
    </system.serviceModel>

此致 纳西尔

2 个答案:

答案 0 :(得分:4)

在Load Balancer下我遇到了这个问题,修复程序在客户端就像这样:

<system.serviceModel>        
    <bindings>
      <customBinding>
        <binding name="MyBindingConfig">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap11" writeEncoding="utf-8">
          </textMessageEncoding>
          <httpsTransport  authenticationScheme="Anonymous" bypassProxyOnLocal="false" proxyAuthenticationScheme="Anonymous"/>
        </binding>
      </customBinding>
    </bindings> 
    <client>
        <endpoint address="https://YOUR-END-POINTURL-WITH-HTTPS"
            binding="customBinding" bindingConfiguration="MyBindingConfig"
            contract="ServiceReference.YOURCONTRACT" name="TEST" />
    </client>
</system.serviceModel>

另外,您可以看到,当您在VisualStudio上添加Web服务引用并且您使用HTTPS放置URL时,它将自动添加客户端端点子(客户端app.config)上的URL而不使用S(HTTP,因为loadbalancer)那么你可以继续使用HTTPS更新它,就像我在上面的例子中所做的那样。 希望它有所帮助。

答案 1 :(得分:-1)

我找到了this link的答案。关键是在自定义绑定中设置以下参数:

<security allowInsecureTransport="true" enableUnsecuredResponse="true">