开发者

Redirect the wcf service request to a internal address

开发者 https://www.devze.com 2023-02-21 03:43 出处:网络
Now i have a public Wcf REST service A, and several internal wcf REST services B, each of internal service开发者_如何学Cs are identified by name. Is it possible to create a router/proxy in service A,

Now i have a public Wcf REST service A, and several internal wcf REST services B, each of internal service开发者_如何学Cs are identified by name. Is it possible to create a router/proxy in service A, and then, when the users request the interface of service A, it can redirect the request to the internal services based on name?

I tried using:

WebOperationContext.Current.OutgoingResponse.Location = targetInternalPath;
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect; // or MovedPermanently

All works fine except the headers that we get on the client side, Here is the details from Fiddler:

  • Transport

    Location: http://locahost:9856/internalAddress/getimage

  • Content-type: null (It should be "image/png")

  • Content-Length: 0

In other words, the client knows the exact internal address, the content-type and content-length is incorrect. All are not what i want. I have been struggling with this issue for days, anybody has any idea?

Best Regards.

Johnny


I'm confused. What you are seeing in fiddler is exactly what you are asking it to do. Your service A is returning a redirect response. The client is supposed to respond to that redirect by following the URI in the Location header.

If you truly want to hide the internal services then you need to make the service A work like a proxy. It needs to make the request to the internal services itself and then return the response it gets back.

Are you trying to hide the internal services for security reasons or is it just the clients don't know about those internal servers in advance?


The WCF RoutingService functionality can't be used because it only supports soap-based bindings. You could use the IIS 7 URL Rewrite Module as suggested here by Matthias in the MSDN forum answer. You could configure it to redirect the calls to the internal REST based services (an overview of its use at this link). I'm not sure it will help re-write the response header contents but it's worth a look.

0

精彩评论

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

关注公众号