Enumeration
Many scenarios require data exchange using more than just a single request/response message pair. Types of applications that require these longer data exchanges include database queries, data streaming, the traversal of information such as namespaces, and enumerating lists. Enumeration, in particular, is achieved though establishing a session between the data source and the requestor. This session is established using the Enumerate operation, which provides an enumeration context that is then used in subsequent operations. Successive messages within the session transport the collection of elements being retrieved. No assumptions are made on the approach used by the service to organize the items that will be produced. What is expected is that under normal processing circumstances, the enumeration will produce all the underlying data before the end of the session.WS-Enumeration specifies protocols to establish an enumeration session and to retrieve sequences of data. The enumeration protocols allow the data source to provide a session abstraction, called an enumeration context, to the consuming service. This enumeration context represents a logical cursor through a sequence of data items. The requestor then uses this enumeration context over a span of one or more SOAP messages to request the data. The enumerated data is represented as XML Infosets. The specification also allows a data source to provide a custom mechanism for starting a new enumeration. Because an enumeration session might require several message exchanges, the session state must be retained.In its simplest form, WS-Enumeration defines a single operation, Pull, which allows a data source, in the context of a specific enumeration, to produce a sequence of XML elements in the body of a SOAP message. Each subsequent Pull operation returns the next N elements in the sequence. Once the last element in a sequence has been returned or the enumeration context has expired, the enumeration context is considered invalid and the result of subsequent operations referencing that context is undefined.Three more request/response operations are defined in WS-Enumeration: Renew, GetStatus, and Release. The Renew operation is used to extend the validity of an enumeration context. The GetStatus operation enables the caller to request information about a given enumeration context. The Release operation represents the failure-free shutdown and relinquishment of session resources. Finally, there is an advisory message sent by data sources when an enumeration is terminated unexpectedly: EnumerationEnd.State information regarding the progress of the iteration can be maintained between requests by either the data source or the consuming service. WS-Enumeration allows the data source to decide, on a request-by-request basis, which party will be responsible for maintaining state for the next request. This flexibility enables several kinds of optimizations. One optimization example is allowing a server to avoid saving any cursor state between invocations. Because message latencies can be large for a service supporting several simultaneous enumerations, not preserving state might yield substantial savings in the total amount of information that must be maintained. Service implementations on resource-constrained devices, such as cell phones, might not be able to maintain any state information at all.In addition to enumerating the data entities present in a Web service, it is convenient to be able to perform several basic operations on them. These operations are introduced in the WS-Transfer specification.