4

I am trying to create a RESTful web service based on WCF Web API. I also need to control access using OAuth and for this I am using the DotNetOpenAuth open source library.

Has anyone ever been successful integrating the two? I am struggling converting from the HTTP entities representations of the WCF Web API into something that's understandable by DNOA (e.g. HTTP requests, HTTP headers, etc...).

Any tip would be greatly appreciated.

Stefano Ricciardi
  • 2,923
  • 3
  • 33
  • 40
  • I'd suggest cross-posting your question at the [WCF WebAPI discussion page](http://wcf.codeplex.com/discussions/topics/4885/web-api). Some pretty smart and in-the-know people are floating around there. Being such a young (and alpha) library, may get extra visibility there to this great question. – ckittel Aug 04 '11 at 22:09
  • Done: http://wcf.codeplex.com/discussions/267859 – Stefano Ricciardi Aug 05 '11 at 07:22
  • I suggest you bug this guy https://twitter.com/#!/GQAdonis2008 He was working on an OAuth implementation for WCF Web API. – Darrel Miller Aug 10 '11 at 19:41

1 Answers1

2

Could you be a little more specific?

In WebAPI a request is represented by the HttpRequestMessage class. A response is represented by the HttpResponseMessage class.

I've no previous knowledge of DNOA, but from what I saw, you can easily create a HttpRequestInfo from an HttpRequestMessage using the public HttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream).

The HTTP method and request uri are directly HttpRequestMessage properties. The input stream is obtained via the Content property. I don't see a direct way of creating a WebHeaderCollection from the WebAPI's HttpRequestHeaders. However, you can iterate the HttpRequestHeaders entries and insert then on the WebHeaderCollection one by one.

ckittel
  • 6,478
  • 3
  • 41
  • 71
Pedro Felix
  • 1,056
  • 1
  • 8
  • 12
  • Yes, that's exactly what I ended up doing after some more research. Good that you confirmed it. Marking your answer as correct for future readers. – Stefano Ricciardi Aug 12 '11 at 10:58
  • how did you create de Stream object from the Content property of the HttpRequestMessage? @PedroFelix – Daniel Jan 02 '12 at 20:34