集成 DotNetOpenAuth 和 WCF WebAPI
我正在尝试创建基于 WCF Web API 的 RESTful Web 服务。我还需要使用 OAuth 控制访问,为此我使用 DotNetOpenAuth 开源库。
有没有人成功地将两者结合起来?我正在努力将 WCF Web API 的 HTTP 实体表示转换为 DNOA 可以理解的内容(例如 HTTP 请求、HTTP 标头等)。
任何提示将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你能说得更具体一点吗?
在 WebAPI 中,请求由
HttpRequestMessage
类。响应由HttpResponseMessage
类。我以前对 DNOA 没有任何了解,但据我所知,您可以使用 public
HttpRequestInfo(string httpMethod, Uri requestUrl、字符串 rawUrl、WebHeaderCollection 标头、Stream inputStream)
。HTTP 方法和请求 uri 直接是
HttpRequestMessage
属性。输入流是通过
Content
属性获取的。我没有看到从 WebAPI 的HttpRequestHeaders
创建WebHeaderCollection
的直接方法。但是,您可以迭代HttpRequestHeaders
条目,然后将其一一插入到WebHeaderCollection
中。Could you be a little more specific?
In WebAPI a request is represented by the
HttpRequestMessage
class. A response is represented by theHttpResponseMessage
class.I've no previous knowledge of DNOA, but from what I saw, you can easily create a
HttpRequestInfo
from anHttpRequestMessage
using the publicHttpRequestInfo(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 aWebHeaderCollection
from the WebAPI'sHttpRequestHeaders
. However, you can iterate theHttpRequestHeaders
entries and insert then on theWebHeaderCollection
one by one.