Message Headers for WCF Request
Often do we want to pass some data to some or maybe all our service operations. This data is usually context data such as user tokens (user information), or environmental preferences of the user or machine (in Respond terminology: UserConext object).
In these kind of situations, we would rather not add additional context parameters to the contracts or our services, because we don’t want to involve implementation data / context data with the business parameters of our services. A nice and easy way to pass that data is to use MessageHeaders. In order to do this we follow these steps: Add the context data to the outgoing message headers. Call the operation (Nothing special here). Extract the data from the incoming message headers. Using an OperationContextScope In order to add the message header, you should have a OperationContext for your call. An OperationContext will automaticly be created for the call, and will be available in the service side. If one wishes to add the message he...
Comments