简体   繁体   English

WCF + IIS 重定向失败,有可能吗?

[英]WCF + IIS Redirect failing, is it possible?

I'm trying to migrate a live, active WCF service (SOAP, standard HTTP binding config) to a new server [on IIS 7] without necessitating a client redeployment.我正在尝试将实时的、活动的 WCF 服务(SOAP,标准 HTTP 绑定配置)迁移到新服务器 [在 IIS 7 上],而无需使用。 The WCF service in question is the 'central service' which holds config information and passes control off onto further services.有问题的 WCF 服务是“中央服务”,它保存配置信息并将控制权传递给其他服务。

The new server/service is in place, both use SSL/HTTPS and have valid certificates.新的服务器/服务就位,都使用 SSL/HTTPS 并具有有效的证书。

I set up a new virtual directory on the old/source IIS [IIS 6] as a test, set to 'A redirection to a URL', new service URL entered.我在旧/源 IIS [IIS 6] 上设置了一个新的虚拟目录作为测试,设置为“重定向到 URL”,输入新服务 URL。 Using a web browser, URL forwards are done correctly and I can browse to the service, no HTTPS warnings or other messages - the important parts of the path and URL preserved and all seems to work OK. Using a web browser, URL forwards are done correctly and I can browse to the service, no HTTPS warnings or other messages - the important parts of the path and URL preserved and all seems to work OK.

However the WCF call fails.但是 WCF 调用失败。 I'm pretty sure it's attempting to interpret the redirect response as a WCF SOAP response and evidently failing, here's the exception logged:我很确定它试图将重定向响应解释为 WCF SOAP 响应并且显然失败了,这是记录的异常:

Error: The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were:
'<HTML><HEAD><link rel="alternate" type="text/xml" href="https://server-name-here/service-path-here.svc?disco"/>
<STYLE type="text/css">#content{ FONT-SIZE: 0.7em; PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP: 0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Service-Name-Here'.

Is there any way around this?有没有办法解决? I'm trying to reduce load from the server, and sustained/active connections since this service is fairly heavily loaded.我正在尝试减少来自服务器的负载以及持续/活跃的连接,因为该服务的负载相当大。 I was hoping the forward would result in the client caching the new URL, and only making the request to the initial URL infrequently, when the redirect expires or similar.我希望转发会导致客户端缓存新的 URL,并且仅在重定向到期或类似情况时不频繁地向初始 URL 发出请求。

I have read various issues and blogs, saying for example that the redirect will ask the client to do a GET rather than a POST, but I'm not seeing that, just the message above so far.我已经阅读了各种问题和博客,例如说重定向将要求客户端执行 GET 而不是 POST,但我没有看到,到目前为止只是上面的消息。

You've pretty much answered your own question, the WCF HTTP handling code in the client cannot act upon an HTTP 301 or some similar response to redirect the service call to another URL like a browser can. You've pretty much answered your own question, the WCF HTTP handling code in the client cannot act upon an HTTP 301 or some similar response to redirect the service call to another URL like a browser can. I can't document this but the WCF client code only handles the type of response (HTTP+soap, in your case) that it is configured for.我无法记录这一点,但 WCF 客户端代码仅处理为其配置的响应类型(在您的情况下为 HTTP+soap)。

Something worth looking at if you have the option of upgrading the old server to Windows Server 2008 is the IIS Application Request Routing extension .如果您可以选择将旧服务器升级到 Windows Server 2008,那么值得一看的是IIS 应用程序请求路由扩展 It's easy to install and configure and the URL rewrite rules are pretty flexible.它易于安装和配置,并且 URL 重写规则非常灵活。 I've used it for proxying (eg, exposing an internally-hosted service via an internet-facing web server) and it works well.我已经将它用于代理(例如,通过面向 Internet 的 web 服务器公开内部托管服务)并且效果很好。 It won't eliminate the work being done on the old server but it will limit it to a small amount.它不会消除在旧服务器上完成的工作,但会将其限制在少量。

If an OS upgrade isn't feasible, the router service suggestion linked above is your next best bet.如果操作系统升级不可行,那么上面链接的路由器服务建议是您的下一个最佳选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM