Collections from an object-oriented paradigm combined with Web Services enable designers to get into trouble by accidentally exposing the underlying complexity of the service implementation platform and language. By leveraging the service implementation language too heavily, the types of clients that can easily access the Web Service will become limited. The following implementation tips show ways to ensure easy adoption of your collections by unexpected client platforms and types:
Do not expose open -ended query mechanisms tied to the underlying object implementation: Query mechanisms tie collections to the underlying representation of the data, objects use Object Query Language (OQL), and relational databases use SQL. This technique violates the ability to encapsulate the service implementation architecture and design.
Return arrays of data from operations that return more than one object rather than Java-specific collection types: There is no guarantee that a Web Service client has a mechanism to represent complex Java- specific types. For example, using a Vector on a service implementation may not translate easily to a type available for a COBOL programmer. Arrays are a more common programming construct and easily translate between most platform architectures.
Collections will exist on the client or on the server: A collection based on the pattern presented here does not span the client and the server. Always remember that the collection used by a client is a copy of the data on the server. Changes to the data on the client move back into the collection on the server through an explicit call to the collection interface.
Certain Web Service scenarios can avoid some of these rules by limiting the types of clients that can access your Web Service. For example, by ensuring that your clients are either .NET or Java clients, you can open up your interface to OQL and simple collection types that translate between platforms. Unfortunately, by putting a limitation such as this on your clients, you also limit the uses of the Web Service. For example, consider that a larger company may someday buy your company; object-oriented clients may restrict integration with their systems.