views:

71

answers:

2

I'm currently working on a project which exposes some functions through webservices. Trouble is, some calls should return an array of "Attribute", which is a container class for a database cell.

These attributes are, obviously, of different types (int, string, date, timestamp and so on). Nothing really hard, just basic types. By now, the webservice calls simply return an array of Attribute objects which holds the values in strings.

Now I haven't coded the webservices, I just want to know if there are some known patterns for design such situations (in order to make advices to the guy which is actually the developer of those webservices).

A: 

I think you need "contract first" web services. Write them in such a way that you accept an XML Request and return an XML Response. It's not much different from your scheme that returns an array of Strings, but it'll be far more portable across different clients. The definition of string and array is different in Java and .NET, so any approach that uses objects for requests or responses locks in a particular client. Stick with XML; start with schemas as your contract with clients.

duffymo
+1  A: 

I think this series of articles on InfoQ will help you (or the actual developer) understand what you need to do. It talks about the mappings between XML data types and Java data types.

If not, then I don't quite understand your question. Sorry!

stephendl