F5 负载均衡器后面的 WCF 服务(wsHttpBinding 绑定)

问题描述 投票:0回答:4

当前设置: - 我有一个带有 wsHttpBding 的 WCF 服务,请参阅下面的服务配置 - 我实现了一个ServiceHostFactory来解决模式位置和soap地址不正确的问题,将它们从机器名修改为正确的服务器主机名 - 我的测试客户端(WCFStorm)我可以生成代理,查看所有方法并成功调用它们。 - 我的开发环境(客户端-> HTTPS -> 服务)运行良好。

问题: - 产品环境(客户端 -> HTTPS -> F5 -> HTTP -> 服务) - 我的服务位于 F5 负载均衡器后面,该均衡器卸载 SSL - 我的测试客户端(WCFStorm)我可以生成代理并查看所有方法,但是当我调用任何方法时,我收到远程服务器未找到 404 错误

  • 我的服务配置:

    
    
    <services>
      <service behaviorConfiguration="Service1Behavior"
        name="MyService">
        <endpoint name="secure" address="" binding="wsHttpBinding" bindingConfiguration="custBinding" contract="IService"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="custBinding">
          <security mode="Transport">
            <transport clientCredentialType="None" />
            <message clientCredentialType="None" negotiateServiceCredential="false"
              establishSecurityContext="false" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Service1Behavior">
          <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" httpGetUrl="http://myserver/MyService.svc"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="6553600" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    
    

  • 请注意,我在 wsdl 上的所有架构位置和肥皂地址在产品中都是正确的,但我根本无法调用任何方法。

请帮忙。

wcf https f5
4个回答
4
投票

我们也有类似的情况,以下是我们的解决方法。

在服务中 - 我们更改了绑定以使用


<services>
  <service behaviorConfiguration="Service1Behavior"
    name="MyService">
    <endpoint name="secure" address="" binding="wsHttpBinding" bindingConfiguration="custBinding" contract="IService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <wsHttpBinding>
    <binding name="custBinding">
      <security mode="Transport">
        <transport clientCredentialType="None" />
        <message clientCredentialType="None" negotiateServiceCredential="false"
          establishSecurityContext="false" />
      </security>
    </binding>
  </wsHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="Service1Behavior">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="true" httpGetUrl="http://myserver/MyService.svc"/>
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <dataContractSerializer maxItemsInObjectGraph="6553600" />
    </behavior>
  </serviceBehaviors>
</behaviors>
并添加了每个请求都必须传递的密钥。

在客户端 - 我们将配置中的 http 更改为 https,并在

basicHttpBinding
配置中将安全模式更改为
basicHttpBindings
,并使用
Transport

希望这有帮助。

更新:我很快就发现了这篇文章,我更新了配置并且它起作用了。所以现在我们使用 wsHttpBinding 而不是 basicHttpBinding。 https://web.archive.org/web/20151215000000*/http://blogs.msdn.com/b/morgan/archive/2010/04/15/setting-up-wcf-with-a-load-平衡器使用 ssl-in-the-middle.aspx


2
投票

您的服务配置的问题在于安全模式是

clientCredentialType="None"
,而实际上它应该是
Transport
。由于对您的服务的任何调用都将在 F5 负载均衡器后面进行 HTTP,因此您不能在那里使用
None
安全模式(客户端 -> HTTPS -> F5 -> HTTP -> 服务)。但是,当从客户端调用服务时,客户端配置需要为
Transport
安全模式,并且端点地址需要有
Transport
地址。

HTTPS

0
投票

这对您来说可能有点晚了,但我们是这样做的。生成代理后,我只需将配置中的 http: 更改为 https。现在,如果我有时必须使用 ssl 来调用它,有时则不需要,我将复制配置部分,并为副本指定一个不同的名称,然后当您构建客户端时,您可以传入配置名称,它会选择正确的一个。


0
投票

我们无法通过第 7 层负载平衡实现此功能 - 服务返回了各种错误消息。相反,它设置在第 4 层负载平衡上,没有任何问题。

© www.soinside.com 2019 - 2024. All rights reserved.