如何配置调用负载均衡器后面的其他服务的 WCF 服务?
我以前没有在负载均衡器后面部署过。我的客户使用相对简单的服务模型配置在服务器上构建和测试了 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 地址。
这看起来应该是显而易见的,但我们缺少它。
I haven't deployed behind a load balancer before. My customer has a WCF service built and tested on servers using a service model configuration that is relatively straightforward. It provides a service to return an image of a map for another application. To get the map, it calls other services.
The service was built in Visual Studio 2010 targeting the 3.5 framework. The customer is using IIS 7.5 and an F5 load balancer. When moving to the production server, the Web.config was changed to add the load balancer behavior and specify the endpoint to show the physical and logical address of the service:
<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>
There is no entry for this service in the system.servicemodel/bindings section. The other services are configured in the bindings and client sections:
<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>
There was a problem when the service was deployed to a server behind the load balancer. When I try to call the service from WCFStorm or WebServiceStudio I get the message "The provided URI scheme 'https' is invalid; expected 'http'.
The endpoints for the service itself look right to me. However in the development and testing versions of the config, the client section uses http instead of http, while on the production servers it uses the load balancer's https address.
This seems like it should be obvious, but we're missing it. Can anybody give us a clue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们在 Windows 网络负载平衡后面设置了 wcf 服务,没有任何问题(确实有一个,但与 NLB 无关)。
我认为这与地址有关。 Web 服务器通常不知道它位于负载均衡器后面。它看到的只是来自一个来源(负载均衡器)的请求。您的绑定让它侦听 https,但除非负载均衡器通过 https 与 Web 服务器通信(这种情况很少见),否则请求将通过 http 发送,因此会出现错误。
您需要将地址更改为 http,或者将负载均衡器设置为通过 http 与 Web 服务器通信。
We have wcf services set up behind Windows Network Load Balancing without any issue (well there was one, but it wasn't to do with NLB).
I think it's to do with the address. The web server is usually unaware that it's behind a load balancer. all it sees are requests coming from one source, the load balancer. Your binding has it listening for https, but unless the load balancer talks to the web server over https, which is rare, the requests are coming over http, hence the error.
You need to either change the address to http, or set the load balancer to talk to the web server via http.
所以我迟到了,但我在调用 F5 后面的服务时遇到了同样的问题。将客户端绑定安全性更改为“传输”而不是“无”。
So I'm late to the party, but i ran into the same issue with calling a service behind F5. Change your client binding security to Transport instead of None.