views:

52

answers:

1

I am trying to write a WCF service as a proxy for my Silverlight control to do cross-domain requests to an internet REST web service. I just want to make the requests to my service, and it would format and forward the request to the 3rd party web service (replace the hostname and part of the URL), then simply return the response to the caller.

Is my approach correct? The 3rd party server does not have the crossdomain.xml file to allow my call otherwise.

My question is, given my WCF service approach, I would like to rewrite the response body in my service with the response body I retrieved from the 3rd party service, and if possible, rewrite the response header to also be the one I got from that service. This way it minimizes the translation that my web service has to do on the response. Is it possible for me to do this rewrite? if so, how? if not, what are the best practices to implement this?

My interface is right now very primitive, something like this, simply because i don't need anything more than this. The response from the 3rd party service is a JSON response.

[ServiceContract]
interface IMyProxy
{
     [OperationContract]
     [WebGet(UriTemplate = "relay/{requestOptions}")]
     string ForwardRequest(string requestOptions);
}

p.s. I do not need it to work with HTTPS, so no need to worry about the man-in-the-middle issue.

A: 

I figured it out, I believe (WebOperationContext). I am still having an issue that if I duplicate the "Transfer-encoding" of the 3rd part service in my reply, I get an obscure exception down from the guts of the framework (something is "NotFound")... but that's a different story.