Recommended Approach to Creating a Facade Over a Web Service API
History: There is a web service I use that is based half on the latest MISMO dtd (for the property in question) and the other half are reports that are to be run against that property. All this is bundled up into one big piece of xml and POSTED to the endpoint, the response is well, you guessed it.... xml, and lots of it.
The reporting aspect of it is the problem. Say there are 100 different reports that can be run, you can ask for a single report or any combination of reports. Right now all these flags are attributes of one node, you turn them on or off by setting the report attribute to Y(es) or N(o) (e.g. <someNode _fooReport="Y" _barReport="Y" .... />
Question: I'm interested in hearing your input on how to design a cleaner Web API over top of this, one that will simplify the the choosing o开发者_开发知识库f the reports for starters. I'm using c# 4.0.
Regards, Stephen
To design a clean API you need to drop the notion of running multiple reports by specific names.
You should instead focus on tagging and grouping your reports by a keyword. If your end user needs to have reports about everything to do with some keyword then allow that user to pass in the keyword.
What you would end up with is writing a search API on your reports. This can be as simple as a list of keywords to something as large as google depending on the amount of choice you want to offer your clients.
From an URL api design view I would consider having something like
url/reports/[id OR name]
and
url/reports/?search=[query]
This will result in a cleaner web API
精彩评论