WCF 4 Soap and Json Endpoint Secured with DotNetOpenAuth

I have a WCF 4 service project that I created using the WCF REST service service template 40.

My goal is to expose one WCF service, both the SOAP endpoint and the RESTful endpoint, which returns JSON data. Both endpoints must be protected through my DotNetOpenAuth OAuthAuthorizationManager, which is copied from a sample project.

Thus, I have WCF SOAP services that can successfully resolve a consumer at my OAuth service provider. For this, I used the same configuration as in the example of the DotNetOpenAuth service provider.

Now I am trying to configure the WCS RESTful JSON response endpoint for the same service, and also protect this endpoint. I am not sure how to do this. My initial idea was to do it 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 how RESTful WCF + DotNetOpenAuth services work: http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together

I'm not sure if installing Factory plus the ServiceAuthorization section of the service configuration will cause problems.

I'm also not sure if there is anything I need to do in the RegisterRoutes method in Global.asax:

 private void RegisterRoutes() { RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi))); } 

Any advice here would be appreciated. Thanks for any help.

Please let me know if you need more information.

+7
source share
1 answer

Not sure, but I heard that to enable SOAP you need to use basicHttpBinding and set

aspNetCompatibilityEnabled = "true"

I could be wrong, but why not give it a try?

+1
source

All Articles