OperationContext
OperationContext is a type from the System.ServiceModel namespace that provides access to the
execution context for a service request. OperationContext.Current provides access to this context for the lifetime of a
request. You used the OperationContext in Chapter 3 to access the callback channel for duplex communications, but there
are other properties that will be useful in this chapter and in subsequent chapters. Here
are a few of the key properties exposed by the OperationContext:
HostProvides access to the
ServiceHostinstance associated with the service type. Through this reference, you can access information about service endpoints, the service description, and service behaviors associated with the request channel.ChannelProvides access to the callback channel if applicable. In this case, the channel reference is returned as an
IContextChannelreference. When you invokeGetCallbackChannel<T>( ), a method exposed byOperationContext, the strongly typed channel is returned (see Chapter 3).SessionIdProvides access to the session identifier if the request is part of a session. This will be put to use in this chapter.
ServiceSecurityContextProvides access to the security context for the request, which means you can access information about the authenticated caller among other security details to be discussed in Chapter 7.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access