views:

77

answers:

1

I'm building a simple ASP.NET MVC 2.0 web application. I'd like to serve up a AtomPub endpoint so that I can publish/update content from Windows Live Writer. I originally went down the path of implementing the AtomPub protocol as an Controller with a set of custom ActionResults. That worked until I tried to get authentication working, when I realized that getting Basic or Digest auth (necessary for WLW) to work within my Forms-Auth based MVC app was going to be problematic.

So, now I've decided to move the AtomPub logic to a WCF service within the MVC app. I created a new WCF service called AtomPub.svc. I added the following to my web.config file:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>

And, my AtomPub.svc.cs code behind looks like this:

namespace Web
{
    using System.ServiceModel;
    using System.ServiceModel.Web;

    [ServiceContract]
    public partial class AtomPub
    {
        [WebGet(UriTemplate = "?test={test}")]
        [OperationContract]
        public string DoWork(string test)
        {
            return test;
        }
    }
}

I also added a route exclusion to exclude this endpoint from MVC's route handling.

Now, I'm a total noob to WCF, so I'm sure I'm doing a number of things wrong. As I'm writing this, the root of the endpoint seems to be working as I get an AtomPub Service page. The URL templating, however, is not working and I don't know what to do to get it working. I'd love to hear your suggestions.

By the way, I'm trying to keep this overall implementation as simple as possible. So, I'm not looking to introduce a dependency on the Entity Framework so I can use WCF Data Services. I'd also prefer not to move the WCF endpoint into a separate project, though I'm open to that if I can easily deploy it to a W2k3/IIS6 environment.

A: 

OK, I found this article: RESTful WCF Services with No svc file and No config and it's pretty much gotten me up and working.

Jim Lamb