views:

235

answers:

1

Client side I need to pass a piece of information (for this example lets say a string) to every service call I make. The services use this string (currentRole) along with user/pass credentials to retrieve a user's set of claims associated w/their current role.

The solutions I have come across thus far are:

1) Modify message headers as they go out from the client and verify that the message header is there service side.

2) Use a custom credential which from what I understand requires a custom security token as well to store the string.

Are there any other approaches I a missing such as just adding that info to an existing token/credential? And are there any pros/cons of the solutions mentioned above?

Thanks.

+1  A: 

You could also write a Client-side behavior which would add this header to the messages (so you wouldn't have to think about doing it yourself in your code).

You could implement a IClientMessageInspector and in the BeforeSendRequest method override, add a message header. When you add this behavior to each of your client endpoints, it'll add that message header automatically to each outgoing message.

See this CodeProject article for some starter infos, and this blog post for some more in-depth know-how.

Marc

marc_s
Thank you for your reply that is the approach I took with modifying the message header. I like it I just wasn't sure if there is any downside to using this approach or if there is something else out there that is more appropriate for this issue.
Hooveh