Developing an API for a downloadable ASP.NET product?
We've got a product built using ASP.NET web forms (3.5), and are investigating adding an API to allow other applications to access data and business logic within the application.
What is the best way to implement this? I'm inclined to go down the route of using Http Handlers to read posted XML and return XML, but I'm sure there must be a better way. Is it advisable to use something lik开发者_如何学运维e WCF instead?
As the product will be downloaded and installed by users on their own servers (instead of hosted), it seems like there's a lot of pressure to get it right the first time as making changes will be hard once users start downloading and using the product. Any suggestions on how to manage this?
I assume if it's made with web forms, the user will have a web server / IIS. Therefore, I suggest a web service addition to your product.
That way, you leave it open for customization and don't tie it too tightly to the web forms project. Customers could even configure them on different websites/servers if they liked. Most modern applications can easily invoke web services, so they're popular for APIs (google, amazon, facebook, etc).
How to manage it? I think version it. Let customers download new versions / bug fixes. I'd see how open source applications handle frequent updates and branching, and do the same. If anyone knows how to do that, it's popular downloaded applications.
Surely WCF is a viable way, but I would suggest, as Nikki did, using Web Services.
About "managing", well, you are pretty right: once you published the interfaces, it's hard to change them. I mean...
Assuming you want to use Web Services, once you publish WSDL interfaces and you find that you designed them bad, you may force people that were already using your product to download the new specifications and re-implement their code. But, if you find a programming error in your Web Service handler, you can fix it ASAP without changing the design contracts of your public wweb services.
The product you want to make available along with the public APIs must be versioned like Nikki said.
The difference between a software product and public APIs is that APIs are public interfaces with which anyone can develop his own software that interacts with your application. A software product is out-of-the-box and runs your code.
Facebook, PayPal, etc., for example, publish lots of APIs and you can find lots of libraries that wrap those APIs into your favourite language.
I hope my generalist answer helped.
精彩评论