We are trying to develop a set of C# 2.0 web services that are data driven,
loosely coupled, easy to maintain, and somewhat high preferment (I'm sure
that's either an oxymoron or everyone else's dream too?!?) Anyway, we need to
be able to take an "arbitrary" number of key (or name) /value pairs that do
have a finite, but changeable, set of possible values to them. What is the
best (practice) approach to accomplishing this without compromising (too
badly) any 1 of the 4 qualities that we are looking for?
For example, let’s say we have a webmethod called "RegisterVehicle" that
takes a "Vehicle" as the input. The Vehicle can be of type "Car", "Truck", or
"Motorcycle". If it's a "Car", then we would need to know "How many doors",
"Make", "Model", "How many cylinders the engine has", and the "Type of fuel".
For a "Truck" we would have the same, but maybe add "4 Wheel Drive or not"
and "Bed length". For "Motorcycle" we wouldn't need "Number of doors". And so
on and so forth.
So as you can see, some of the inputs are somewhat set (Car, Truck, or
Motorcycle), but the others could change at any time and are mostly dependant
on the type of Vehicle that you are submitting.
If we create enums and expose those through the WSDL, we would need to
recompile and redeploy our services, plus existing client may need to do the
same. However the validation is "free", but we would probably also have to
maintain enums in C# code as well as "enums" in the database.
If we take an "array" of key/value pairs with some min/max bounding
constraint, it make the validation of those key/value pairs a bit more error
prone (i.e. just doing string comparisons, room for type-o's, etc.), but is
much more flexible in what can be passed in by any given client application.
Anyone dealing with this type of thing now?