** UPDATE - This was a fun experiment, but if you want to do this sort of thing then check out Swashbuckle . It's an awesome project that gives you Swagger and loads of options!
I recently wrote a post about adding support for generating WADL to an ASP.NET Web API project.
I’ve found myself wanting to demo it a few times, so I’ve packaged it up as a NuGet package to make it easier. This means that it’s also easier for you to add it to your projects :-)
To get started create a new ASP.NET Web API project and add the leeksnet.AspNet.WebApi.Wadl package. This depends on the Microsoft.AspNet.WebApi.HelpPage (>=5.1.0) package that provides the API documentation. This package is added by Visual Studio (from the ASP.NET and Web Tools 2012.2 Update onwards).
After installing the package, build and run the solution and navigate to /Help/Wadl to see the generated output.
You can control which APIs are documented (and therefore included in the WADL output) using the ApiExplorerSettings attribute as shown below. This attribute can be applied at the controller level or the individual action level. E.g.
public class AccountController : ApiController
One small point to note is that when the package is installed it converts the Areas.HelpPage.Controllers.HelpController to be a partial class. This helps to separate out the Wadl action added by the package from the rest of the code.
As always, use it at your own risk (but hopefully it will be useful!)
This is really cool, thank you.
I have one question though - just wondering in case do you have any reference, or thoughts on generating client side code (i am just interested in .net/c#) from WADL and XSD. basically i have to consume a third party web service which basically exposes its WADL and XSD, i can manually create the packets, and write the client side code. Just looking for some techniques which will generate client side code similar to generating code from WSDL.
[Just continuation to above comments as looks like i can't edit once i sent the comment :)]
And looks like the only option i can think of as of now is going through https://wadl.java.net (wad2java), and see how it is generating code from WADL and XSD, and simulate same for .net (C#).
Just wondering if any one already solved it, and have nugget for the same :)
Appreciate your time, or thoughts on this.
I have a minor patch for this package, is it hosted anywhere to accept pull requests?
@makeblake - thanks for the interest! The code etc on my blog is intended as samples. Unfortunately, taking pull requests etc would slightly change the nature of the code and lead to some complications :-(
Still, what was the issue that you found?
Tried installing via NuGet in VS 2013 today and got this error:
Install failed. Rolling back...
Updating 'Microsoft.AspNet.WebApi.WebHost 5.2.2' to 'Microsoft.AspNet.WebApi.WebHost 5.1.0' failed. Unable to find a version of 'Microsoft.AspNet.WebApi' that is compatible with 'Microsoft.AspNet.WebApi.WebHost 5.1.0'.
@Sujit - I'll try to find some time to take a look. in the meantime you can always grab the source from the original post (blogs.msdn.com/.../teaching-asp-net-web-api-to-wadl.aspx)
This also happened to me. Why it's updating 5.2.2 to a lower version of 5.1.0 makes no sense... Also, it doesn't happen all the time. We've been able to recreate it in various different situations.
Stuart, it also seems like the original source is no longer available. It seems like there is a hard dependency on 5.1.0 across a range of things.
The source for the view is here: gist.github.com/.../324162793413f0e8d19e
I've just pushed an updated version of the package to the nuget feed. This pulls in 5.2.2 - can you let me know whether that works for you?