2011-04-04 90 views
7

我有我使用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))); 
} 

这里任何意见,将不胜感激。感谢您的帮助。

如果您需要更多信息,请让我知道。

回答

1

不知道,但我听说,使您需要使用basicHttpBinding SOAP和设置

aspNetCompatibilityEnabled =“真”

我可能是错的,但为什么不尝试一下呢?

+0

正确!对于Json端点的工作,您需要使用asp.netCompatibilityEnabled =“Tru”的BasicHttpBinding – 2011-05-25 07:44:29