如何配置调用负载均衡器后面的其他服务的WCF服务?

时间:2010-09-03 16:11:48

标签: asp.net web-config wcf iis-7.5 load-balancing

我之前没有部署过负载均衡器。我的客户使用相对简单的服务模型配置在服务器上构建和测试了WCF服务。它提供了一种服务来返回另一个应用程序的地图图像。要获取地图,它会调用其他服务。

该服务是在面向3.5框架的Visual Studio 2010中构建的。客户正在使用IIS 7.5和F5负载均衡器。移动到生产服务器时,Web.config已更改为添加负载平衡器行为并指定端点以显示服务的物理和逻辑地址:

        <services>
      <service behaviorConfiguration="Service.Service1Behavior" name="StaticMapImageService.Data.MapImageService">
        <endpoint 
                address="https://gis.customer.com/StaticMapImage/Service/StaticMapImageService.svc" 
                binding="basicHttpBinding" 
                bindingNamespace="http://customer.com"
                contract="StaticMapImageService.Data.IMapImageService"
                listenUri="http://hq-gis01.customer.net/StaticMapImage/Service/StaticMapImageService.svc"
                behaviorConfiguration="SSLLoadBalancerBehavior">
        </endpoint>
        <endpoint 
                address="mex" 
                binding="mexHttpBinding" 
                bindingNamespace="http://werner.com"
                contract="IMetadataExchange"/>
      </service>
    </services>

system.servicemodel / bindings部分中没有此服务的条目。其他服务在绑定和客户端部分中配置:

        <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IAddressVerificationService"
            closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00"
            sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false"
            hostNameComparisonMode="StrongWildcard" maxBufferSize="999999999"
            maxBufferPoolSize="524288" maxReceivedMessageSize="999999999"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="999999999" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="BasicHttpBinding_IGeocoderService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="999999999" maxBufferPoolSize="524288" maxReceivedMessageSize="999999999"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="999999999" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
        <binding name="PCMilerSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
            receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
            bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
            maxBufferSize="999999999" maxBufferPoolSize="524288" maxReceivedMessageSize="999999999"
            messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
            useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="999999999" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="WSHttpBinding_IGeocoderService" closeTimeout="00:01:00"
            openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
            bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
            maxBufferPoolSize="524288" maxReceivedMessageSize="999999999"
            messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
            allowCookies="false">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
              maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
              enabled="false" />
          <security mode="Message">
            <transport clientCredentialType="Windows" proxyCredentialType="None"
                realm="" />
            <message clientCredentialType="Windows" negotiateServiceCredential="true"
                algorithmSuite="Default" establishSecurityContext="true" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="https://gis.customer.com/AddressVerification/Service/AddressVerificationService.svc"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IAddressVerificationService"
          contract="AddressVerificationService.IAddressVerificationService"
          name="BasicHttpBinding_IAddressVerificationService" />
      <endpoint address="https://gis.customer.com/Geocoder/Service/GeocoderService.svc/ws"
          binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IGeocoderService"
          contract="GeocoderService.IGeocoderService" name="WSHttpBinding_IGeocoderService">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
      <endpoint address="https://gis.customer.com/Geocoder/Service/GeocoderService.svc/soap"
          binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocoderService"
          contract="GeocoderService.IGeocoderService" name="BasicHttpBinding_IGeocoderService" />
      <endpoint address="http://hq-miler02.customer.net/MultiMiler/ALKWS/PCMiler.asmx"
          binding="basicHttpBinding" bindingConfiguration="PCMilerSoap"
          contract="PCMiler.PCMilerSoap" name="PCMilerSoap" />
    </client>

将服务部署到负载均衡器后面的服务器时出现问题。当我尝试从WCFStorm或WebServiceStudio调用服务时,我收到消息“提供的URI方案'https'无效;预期'http'。

服务本身的端点看起来对我而言。但是在配置的开发和测试版本中,客户端部分使用http而不是http,而在生产服务器上,它使用负载均衡器的https地址。

这似乎应该是显而易见的,但我们错过了它。任何人都能给我们一个线索吗?

2 个答案:

答案 0 :(得分:0)

我们在Windows网络负载平衡之后设置了wcf服务而没有任何问题(有一个,但它与NLB无关)。

我认为这与地址有关。 Web服务器通常不知道它在负载均衡器后面。所有它看到的是来自一个来源的负载均衡器的请求。你的绑定让它监听https,但是除非负载均衡器通过https与Web服务器通信,这种情况很少见,所以请求是通过http进行的,因此是错误。

您需要将地址更改为http,或将负载均衡器设置为通过http与Web服务器通信。

答案 1 :(得分:0)

所以我迟到了派对,但是在调用F5背后的服务时遇到了同样的问题。将客户端绑定安全性更改为“传输”而不是“无”。