Real Simple Discovery Made Easy with the JaySmith.RealSimpleDiscovery Library

Recently I have been spending a lot of time writing blog features for several applications I am working on.  I always have to wire up some of the same handlers for exposing API endpoints for services such as MetaWeblogAPI, Blogger, LiveJournal, etc.  So, being the lazy coder that I am I started looking at ways to make them easier to share between projects. 

In this post I am going to cover a configuration based approach I have developed for handing the first step in exposing those services, Real Simple Discovery.

Real Simple Discovery as described from the RFC posted here is as follows:

Really Simple Discovery is a way to help client software find the services needed to read, edit, or "work with" weblogging software.  Although I talk about weblogging software, there's no reason this format can't apply to other forms of web client/system software that I wasn't considering, or may not even exist as of this writing.  This format is simple but flexible. One of the design goals was to ensure that it would be human writeable. This was my "test" for ensuring that the format was easy for everyone to implement.

What is the benefit of using a handler versus just putting it in an rsd.xml file at your web root?

If you are creating a simple site that is for a single URL and will never be used by others then using an rsd.xml file is an ideal solution.  On the other hand, if you are creating a project that you expect others to install on their own domain they will have to modify the rsd.xml file to provide the full URL to each handler.  This is something you would expect a developer to know how to do but not someone who has just download your code and installed it.  They expect to deploy and it just to run.

Dynamically generating this information allows for a zero config setup where the code that generates the XML can figure out the correct URL’s to provide without the need of manual configuration.  The developer sets up the protocols they want to implement in the web.config file and the real simple discovery handler generates the xml based on that config.  In this scenario the user of the site does not have to setup anything to get it to work

Example rsd.xml from my blog using Blogengine.NET

  <rsd version="1.0">
  <service>
    <engineName>BlogEngine.NET 1.6.1.0</engineName>
    <engineLink>http://dotnetblogengine.com</engineLink>
    <homePageLink>http://jaysmith.us/</homePageLink>
    <apis>
      <api name="MetaWeblog" preferred="true" apiLink="http://jaysmith.us/metaweblog.axd" blogID="http://jaysmith.us/"/>
      <api name="BlogML" preferred="false" apiLink="http://jaysmith.us/api/BlogImporter.asmx" blogID="http://jaysmith.us/"/>
    </apis>
  </service>
</rsd>

Installing JaySmith.RealSimpleDisovery via NuGet

This approach will work for both WebForms and MVC applications since it uses a handler to basically bypass the UI layer.

Example of the config

<realSimpleDiscovery>
    <apis>
      <add name="Atom" preferred="false" apiLink="atom.axd" />
      <add name="Blogger" preferred="false" apiLink="blogger.axd" />
      <add name="MetaWeblog" preferred="true" apiLink="metaweblog.axd" />
      <add name="Manila" preferred="false" apiLink="manila.axd" />
      <add name="MetaWiki" preferred="false" apiLink="metawiki.axd" />
      <add name="LiveJournal" preferred="false" apiLink="livejournal.axd" />
    </apis>
</realSimpleDiscovery>

Navigating to http://[MyHost]/rsd.axd will display the following:

<?xml version="1.0" encoding="utf-8" ?> 
<rsd version="1.0">
  <service>
    <engineName>JaySmith.RealSimpleDiscovery Engine v1.0</engineName> 
    <engineLink>https://github.com/JaySmith/RealSimpleDiscovery</engineLink> 
    <homePageLink>http://localhost:4104/</homePageLink> 
    <apis>
      <api name="MetaWeblog" preferred="True" apiLink="http://localhost:4104/metaweblog.axd" blogID="http://localhost:4104/" /> 
      <api name="Atom" preferred="False" apiLink="http://localhost:4104/atom.axd" blogID="http://localhost:4104/" /> 
      <api name="Blogger" preferred="False" apiLink="http://localhost:4104/blogger.axd" blogID="http://localhost:4104/" /> 
      <api name="Manila" preferred="False" apiLink="http://localhost:4104/manila.axd" blogID="http://localhost:4104/" /> 
      <api name="MetaWiki" preferred="False" apiLink="http://localhost:4104/metawiki.axd" blogID="http://localhost:4104/" /> 
      <api name="LiveJournal" preferred="False" apiLink="http://localhost:4104/livejournal.axd" blogID="http://localhost:4104/" /> 
    </apis>
  </service>
</rsd>

Another feature is that the implementation is flexible enough to handle new APIs as they become available.  To expose a new api all you have to do is add it to the web.config file and the end point of the new api will be generated just like all the rest.

Example of new API

  <realSimpleDiscovery>
    <apis>
      <add name="Atom" preferred="false" apiLink="atom.axd" />
      <add name="Blogger" preferred="false" apiLink="blogger.axd" />
      <add name="MetaWeblog" preferred="true" apiLink="metaweblog.axd" />
      <add name="Manila" preferred="false" apiLink="manila.axd" />
      <add name="MetaWiki" preferred="false" apiLink="metawiki.axd" />
      <add name="LiveJournal" preferred="false" apiLink="/api/livejournal.axd" />
      <add name="MyNewApi" preferred="false" apiLink="/mynewapi.axd" />
    </apis>
  </realSimpleDiscovery>

Output with new API after navigation to http://[myhost]/rsd.axd

<?xml version="1.0" encoding="utf-8" ?> 
<rsd version="1.0">
<service>
  <engineName>JaySmith.RealSimpleDiscovery Engine v1.0</engineName> 
  <engineLink>https://github.com/JaySmith/RealSimpleDiscovery</engineLink> 
  <homePageLink>http://localhost:4104/</homePageLink> 
 <apis>
  <api name="MetaWeblog" preferred="True" apiLink="http://localhost:4104/metaweblog.axd" blogID="http://localhost:4104/" /> 
  <api name="Atom" preferred="False" apiLink="http://localhost:4104/atom.axd" blogID="http://localhost:4104/" /> 
  <api name="Blogger" preferred="False" apiLink="http://localhost:4104/blogger.axd" blogID="http://localhost:4104/" /> 
  <api name="Manila" preferred="False" apiLink="http://localhost:4104/manila.axd" blogID="http://localhost:4104/" /> 
  <api name="MetaWiki" preferred="False" apiLink="http://localhost:4104/metawiki.axd" blogID="http://localhost:4104/" /> 
  <api name="LiveJournal" preferred="False" apiLink="http://localhost:4104/api/livejournal.axd" blogID="http://localhost:4104/" /> 
  <api name="MyNewApi" preferred="False" apiLink="http://localhost:4104/mynewapi.axd" blogID="http://localhost:4104/" /> 
  </apis>
 </service>
</rsd>

You can see that the new MyNewApi endpoint has been included.

Looking for feedback

I am really looking for feedback on this approach so if you are creating applications that need to use Real Simple Discovery please give this a test drive and let me know of any improvements you would like to see.

Resources on Real Simple Discovery:

RFC: Really Simple Discoverability 1.0

http://archipelago.phrasewise.com/display?page=oldsite/1330.html

http://cyber.law.harvard.edu/blogs/gems/tech/rsd.html

Calendar

<<  July 2019  >>
MonTueWedThuFriSatSun
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

Month List