Configuring Context Policy for an Operation
The Context policy lets you specify that client applications must provide context information in the SOAP header of all messages that pass to an operation.
The Context policy provides two properties. The following table describes these properties.
|
Property Name |
Description |
|---|---|
|
enableContext |
Determines whether DCS applies task filters based on the Context object. If this is set to False, client applications can invoke operations with null contexts, and DCS performs no filter matching on the operation. However, service-level scope filtering still applies. If set to True, DCS performs task filtering as usual. |
|
requireContext |
Determines whether the operation requires a context object from the client application for every call. If this is True, clients that pass a null context receive a ProtocolException stating that a Context object is required. |
The enableContext property overrides the requireContext property. If the enableContext property is set to False, DCS does not apply task filters, and any client application can invoke the operation regardless of the status of the application’s Context object regardless of the requireContext property value.
To define Context policy for an individual operation
- In the DCS Management Services Console, expand the Policy Management node, expand the service node that contains the required operation, and then expand Operations.
- In the left pane, click the operation that you want to configure, right-click the operation, and then click New.
- In the Edit Policy dialog box, in the Policy Type list, click Microsoft.ConnectedIndustry.ServiceModel.Application.Policy.ContextPolicy.
- In the Direction list, select the message direction on which to specify the policy.
Note:In the DCS Context policy, only the wildcard (*) and Request options have any significance, and both have the same effect. - Set the enableContext and requireContext properties, and then click OK.
When you configure a context policy on the service, you must also configure the client application to consume the policy configuration. You must add the following section to the client application configuration file.
<system.serviceModel>
...
<client>
<metadata>
<policyImporters>
...
<extension type="Microsoft.ConnectedIndustry.ServiceModel.Application.Context.ContextBindingElement, Microsoft.ConnectedIndustry.ServiceModel.Application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
...
</policyImporters>
</metadata>
</client>
...
</system.serviceModel>