[英]Integrating DotNetOpenAuth and WCF WebAPI
I am trying to create a RESTful web service based on WCF Web API . 我试图基于WCF Web API创建一个RESTful Web服务。 I also need to control access using OAuth and for this I am using the DotNetOpenAuth open source library.
我还需要使用OAuth来控制访问,为此,我正在使用DotNetOpenAuth开源库。
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 (eg HTTP requests, HTTP headers, etc...).
我正在努力将WCF Web API的HTTP实体表示形式转换为DNOA可以理解的内容(例如HTTP请求,HTTP标头等)。
Any tip would be greatly appreciated. 任何提示将不胜感激。
Could you be a little more specific? 您能具体一点吗?
In WebAPI a request is represented by the HttpRequestMessage
class. 在WebAPI中,请求由
HttpRequestMessage
类表示。 A response is represented by the HttpResponseMessage
class. 响应由
HttpResponseMessage
类表示。
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)
. 我以前对DNOA并不了解,但是从我看到的结果来看,您可以使用公共
HttpRequestInfo(string httpMethod, Uri requestUrl, string rawUrl, WebHeaderCollection headers, Stream inputStream)
从HttpRequestMessage
轻松创建HttpRequestInfo
。
The HTTP method and request uri are directly HttpRequestMessage
properties. HTTP方法和请求uri直接是
HttpRequestMessage
属性。 The input stream is obtained via the Content
property. 输入流是通过
Content
属性获得的。 I don't see a direct way of creating a WebHeaderCollection
from the WebAPI's HttpRequestHeaders
. 我没有看到从WebAPI的
HttpRequestHeaders
创建WebHeaderCollection
的直接方法。 However, you can iterate the HttpRequestHeaders
entries and insert then on the WebHeaderCollection
one by one. 但是,您可以迭代
HttpRequestHeaders
条目,然后在WebHeaderCollection
一个接一个地插入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.