简体   繁体   English

WCF 4 Soap和Json Endpoint通过DotNetOpenAuth保护

[英]WCF 4 Soap and Json Endpoint Secured with DotNetOpenAuth

I have a WCF 4 service project that I created using the WCF REST Service Template 40. 我有一个使用WCF REST服务模板40创建的WCF 4服务项目。

My goal is to expose a single WCF service out as both a SOAP endpoint and a RESTful endpoint that returns JSON formatted data. 我的目标是将单个WCF服务公开为SOAP端点和返回JSON格式数据的RESTful端点。 Both endpoints must be protected via my DotNetOpenAuth OAuthAuthorizationManager that is copied from the sample project. 必须通过从示例项目复制的DotNetOpenAuth OAuthAuthorizationManager保护两个端点。

Thusfar, I have a SOAP WCF services that can successfully authorize a consumer from my OAuth service provider. 因此,我有一个SOAP WCF服务,可以从我的OAuth服务提供商成功授权消费者。 To do this I used the same config that was in the DotNetOpenAuth Service Provider example. 为此,我使用了DotNetOpenAuth服务提供程序示例中的相同配置。

Now, I am trying to setup a WCF RESTful JSON response endpoint for the same service and also secure that endpoint. 现在,我正在尝试为同一服务设置WCF RESTful JSON响应端点,并保护该端点。 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 然后我看到这篇关于制作RESTful WCF服务+ DotNetOpenAuth的博客文章: 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. 我不确定是否设置工厂加服务配置的ServiceAuthorization部分会导致问题。

I am also unsure if there is anything I need to do in the RegisterRoutes method in the Global.asax: 我也不确定我是否需要在Global.asax中的RegisterRoutes方法中做任何事情:

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. 如果您需要更多信息,请与我们联系。

Not sure, but I've heard that to enable SOAP you need to use basicHttpBinding and set 不确定,但我听说要启用SOAP,你需要使用basicHttpBinding和set

aspNetCompatibilityEnabled="true" aspNetCompatibilityEnabled = “真”

I could be wrong, but why not try? 我错了,但为什么不试试?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM