开发者

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. The WCF service in question is the 'central service' which holds config information and passes control off onto further services.

The new server/service is in place, both use SSL/HTTPS and have valid certificates.

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. 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. 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:

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.

I have read various issues and blogs, saying for example that the redirect will ask the client to do a GE开发者_运维技巧T rather than a POST, but I'm not seeing that, just the message above so far.


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.


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. It's easy to install and configure and the URL rewrite rules are pretty flexible. I've used it for proxying (e.g., exposing an internally-hosted service via an internet-facing web server) and it works well. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜