Reputation: 4721
I have this dilemma.
I'm developing a web services. It has to return a list of supported languages. Languages are stored in an enum.
Is it better to return (from web method) an enum array or covert it to string and return a string array.
Maybe I'd prefer string array so the client doesn't have to mess with custom object types, and no serialization/deserialization is required. But on the other hand, if I need that enum on the client I'll have to reimplement it and convert the string array back to enum array.
What do you suggest?
Upvotes: 0
Views: 967
Reputation: 4721
I agree. I believe services should be encapsulated and independent as much as possible. Anyway I'm not a big fan of any kind of auto-generation. Also I prefer REST and pure HTTP over WS and SOAP. Although I will leave both options available.
So I think I'll just stay with simple string array return. At least if nobody gives me a strong argument not to :)
Upvotes: 1
Reputation: 7580
Usually the thumb rule should be Keep It As Simple As Possible . Because i have seen really funny things happen with WSDLs while generating their clients.
Upvotes: 1
Reputation: 5188
As usual: it depends :)
You have already answered your own question I'd say.. Does the client need the custom object in order to do any operations with it? Implement it with a custom object.
Is the String representation sufficient? Go for that..
I don't know of any guidelines regarding that topic..
Upvotes: 1