我有我使用WCF REST服務模板40WCF 4肥皂和JSON端點DotNetOpenAuth
我的目標是揭露一個WCF服務進行同時作爲SOAP端點並創建了一個WCF 4個服務項目擔保一個返回JSON格式數據的RESTful端點。兩個端點都必須通過從示例項目複製的DotNetOpenAuth OAuthAuthorizationManager進行保護。
Thusfar,我有一個SOAP WCF服務,可以從我的OAuth服務提供者成功授權給一位消費者。爲此,我使用了DotNetOpenAuth服務提供者示例中的相同配置。
現在,我正在嘗試爲同一服務設置WCF RESTful JSON響應端點,並且還保護該端點。我不確定如何做到這一點。我最初的想法是,使它看起來像這樣:
<behaviors>
<serviceBehaviors>
<behavior name="DataApiBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="OAuthServiceProvider.Core.OAuthAuthorizationManager, OAuthServiceProvider" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="DataApiBehavior" name="OAuthServices.DataApi">
<endpoint address="soap" binding="wsHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/>
<endpoint address="json" binding="webHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/>
</service>
</services>
然後,我看到這個博客帖子大約使REST風格的WCF服務+ DotNetOpenAuth共同努力: http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together
我不知道,如果設置一個廠加上服務配置的ServiceAuthorization部分會導致問題。
我也不能確定,如果有什麼事情,我需要在Global.asax中的RegisterRoutes方法做:
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi)));
}
這裏任何意見,將不勝感激。感謝您的幫助。
如果您需要更多信息,請讓我知道。
正確!對於Json端點的工作,您需要使用asp.netCompatibilityEnabled =「Tru」的BasicHttpBinding – 2011-05-25 07:44:29