views:

38

answers:

1

When writing a custom channel how can I get the name of the service method that will be called.

For example, if the operation contract looks like the following, how can I know if Method1 or Method2 is being called?

[OperationContract]
void Method1( int data );

[OperationContract]
void Method2( int data );

The channel itself doesn't perform any major function on the Message, it just adds some extra data. What I am looking for is to customize the extra data added in the channel depending on the method being called (or more specifically if it is decorated with something).

A: 

If you are creating a transport channel, then that's completely up to you. The responsibility is on you to take the incoming bytes and translate it to a message which will then be pushed down the channel stack.

If you are creating a protocol channel, you can just access the OperationContext (it should be set by that time) and check the IncomingMessageHeaders property and get the action header. This is what is used to map to the OperationContract.

What exactly are you trying to do here, and at what point are you trying to do it? What kind of channel are you trying to create exactly? Your question doesn't have enough information to really give an answer.

casperOne