This documentation is archived and is not being maintained.

MessageQuery Class

Defines the core behavior of classes used to search for specific correlating data in a message.

System::Object
  System.ServiceModel.Dispatcher::MessageQuery
    System.ServiceModel::XPathMessageQuery

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

public ref class MessageQuery abstract

The MessageQuery type exposes the following members.

  NameDescription
Protected methodMessageQueryInitializes a new instance of the MessageQuery class.
Top

  NameDescription
Public methodCreateMessageQueryCollectionCreates a collection of queries that returns a specific type of data associated with it.
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodEvaluate<TResult>(Message)When overridden in a derived class, runs a query against the message and returns a result. The body cannot be queried.
Public methodEvaluate<TResult>(MessageBuffer)When overridden in a derived class, runs a query against the message and returns a result.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

The MessageQuery class is similar to the MessageFilter class. However, instead of returning matches, the Evaluate() method returns the results of evaluating a query against a message. The result of the query is a value in the message. Use the value as a key to correlate the message to other messages. To add a new property for the data, use the Add(String, Func<String>) method of the CorrelationDataMessageProperty class.

NoteNote

For a concrete implementation of the MessageQuery, see the XPathMessageQuery class.

Using the XPathMessageQuery and MessageQueryCollection classes

You can optimize the query process by creating a set of query objects and inserting them into an instance of the MessageQueryCollection class.

NoteNote

For a concrete implementation of the MessageQueryCollection, see the XPathMessageQueryCollection class.

A common usage is to populate the collection with queries that have the same XPath predicate, but that differ only in the final leaf value. For example, the following XPath queries are identical except for the final clause. The first queries for all elements that have the quantity attribute set to 1, and the second queries for elements with the product attribute set to 'Contoso'):

"/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@quantity = 1]"
"/s12:Envelope/s12:Body/PurchaseOrder/Items/Item[@product = 'Contoso']"

The MessageQueryCollection class allows you to create tables of queries that differ only slightly, enabling more efficient processing.

Alternatively, you can use the MessageQueryTable<TItem> class to store and evaluate message queries.

The following example creates a message and XPath message queries. The queries are evaluated by the XPathMessageQuery objects contained in an XPathMessageQueryCollection object. The results of each query are tested using the ResultType property of the XPathResult class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: