This topic has not yet been rated - Rate this topic

IDispatchOperationSelector.SelectOperation Method

Associates a local operation with the incoming method.

Namespace:  System.ServiceModel.Dispatcher
Assembly:  System.ServiceModel (in System.ServiceModel.dll)
string SelectOperation(
	ref Message message
)

Parameters

message
Type: System.ServiceModel.Channels.Message%
The incoming Message to be associated with an operation.

Return Value

Type: System.String
The name of the operation to be associated with the message.

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Problem debugging
I too have observed this problem. Makes it very difficult to debug using a custom IDispatchOperationSelector.
This message cannot support the operation because it has been read.
I am observing the same behavior as Johgoe. My SelectOperation gets called twice when the call originates from within the VS IDE debugger. If I run the client outside of the debugger, the SelectOperation method is called only once and everything works as expected. After the second call returns, the server reports the following error;

"This message cannot support the operation because it has been read."

 
I believe my SelectOperation is constructed correctly, I think the real question is why is it getting called twice when the client is executed in the debugger...

      public string SelectOperation(ref System.ServiceModel.Channels.Message message)
        {
            XmlDictionaryReader bodyReader = message.GetReaderAtBodyContents();

            XmlQualifiedName lookupQName = new XmlQualifiedName(bodyReader.LocalName, bodyReader.NamespaceURI);
            
            message = CreateMessageCopy(message, bodyReader);
            
            if (dispatchDictionary.ContainsKey(lookupQName))
            {
                return dispatchDictionary[lookupQName];
            }
            else
            {
                return null;
            }

        }



Error in VS debugger mode
When VS debugger is attached on client side, SelectOperation is calledtwice and although parameter message is copied (as in "Route by Body" WCF sample), client receives error "This message cannot support the operation because it has been read.".