title: WCF 4 Soap and Json Endpoint Secured with DotNetOpenAuth
body: <p>I have a WCF 4 service project that I created using the WCF REST Service Template 40. </p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>&lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name="DataApiBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
        &lt;serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="OAuthServiceProvider.Core.OAuthAuthorizationManager, OAuthServiceProvider" /&gt;
      &lt;/behavior&gt;
      &lt;behavior name=""&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  
  &lt;services&gt;
    &lt;service behaviorConfiguration="DataApiBehavior" name="OAuthServices.DataApi"&gt;
      &lt;endpoint address="soap" binding="wsHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/&gt;
      &lt;endpoint address="json" binding="webHttpBinding" contract="OAuthServices.Interfaces.IDataApi"/&gt;
    &lt;/service&gt;
  &lt;/services&gt;
  </code></pre>
  
  <p>And then I saw this blog post about making RESTful WCF services + DotNetOpenAuth work together:
  <a href="http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together">http://www.theleagueofpaul.com/codesnippet-ooo-openid-odata-oauth-together</a></p>
  
  <p>I am not sure if setting up a Factory plus the ServiceAuthorization section of the service config would cause problems.</p>
  
  <p>I am also unsure if there is anything I need to do in the RegisterRoutes method in the Global.asax:</p>
  
  <pre><code>private void RegisterRoutes()
  {
      RouteTable.Routes.Add(new ServiceRoute("DataApi", new WebServiceHostFactory(), typeof(DataApi)));
  }
  </code></pre>
  
  <p>Any advice here would be appreciated. Thanks for any assistance.</p>
  
  <p>Please let me know if you need more information.</p>