使用 DotNetOpenAuth 保护 WCF 4 Soap 和 Json 端点
我有一个使用 WCF REST 服务模板 40 创建的 WCF 4 服务项目。
我的目标是将单个 WCF 服务公开为 SOAP 端点和返回 JSON 格式数据的 RESTful 端点。两个端点都必须通过从示例项目复制的 DotNetOpenAuth OAuthAuthorizationManager 进行保护。
到目前为止,我有一个 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>
然后我看到这篇关于让 RESTful WCF 服务 + DotNetOpenAuth 协同工作的博客文章: http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together< /a>
我不确定设置工厂加上服务配置的 ServiceAuthorization 部分是否会导致问题。
我也不确定 Global.asax 中的 RegisterRoutes 方法是否需要做任何事情:
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi)));
}
这里的任何建议将不胜感激。感谢您的任何帮助。
如果您需要更多信息,请告诉我。
I have a WCF 4 service project that I created using the WCF REST Service Template 40.
My goal is to expose a single WCF service out as both a SOAP endpoint and a RESTful endpoint that returns JSON formatted data. Both endpoints must be protected via my DotNetOpenAuth OAuthAuthorizationManager that is copied from the sample project.
Thusfar, I have a SOAP WCF services that can successfully authorize a consumer from my OAuth service provider. To do this I used the same config that was in the DotNetOpenAuth Service Provider example.
Now, I am trying to setup a WCF RESTful JSON response endpoint for the same service and also secure that endpoint. I am unsure how to accomplish this. My initial idea was to make it look like this:
<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>
And then I saw this blog post about making RESTful WCF services + DotNetOpenAuth work together:
http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together
I am not sure if setting up a Factory plus the ServiceAuthorization section of the service config would cause problems.
I am also unsure if there is anything I need to do in the RegisterRoutes method in the Global.asax:
private void RegisterRoutes()
{
RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi)));
}
Any advice here would be appreciated. Thanks for any assistance.
Please let me know if you need more information.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定,但我听说要启用 SOAP,您需要使用
basicHttpBinding
并设置我可能是错的,但为什么不尝试呢?
Not sure, but I've heard that to enable SOAP you need to use
basicHttpBinding
and setI could be wrong, but why not try?