DCS Scopes

When you deploy a DCS service and define a service instance, you can specify a list of scopes that the service instance will respond to. A scope is a structured string identifier associated with the service instance.

When a client connects to a service through the DCS Discovery service, it must provide two pieces of information: the service contract, and the scope of the service instance to connect to. The service contract specifies the functionality of the service to connect to, and the scope helps match the client to the most appropriate service instance.

Scope Elements and Scope Matching Rules

The strings that DCS services use for scope values can contain multiple elements. For example, the scope ContosoBank is a simple scope identifier with a single element. A client application that requests a connection to a service instance with this scope only has to construct a corresponding scope value of ContosoBank in the context object passed to the proxy.

The scope ContosoBank:Albany is an example of a multi-element identifier. The DCS Discovery Service uses the colon character (:) to separate elements of a scope when it searches for a service instance that a client application can connect to. A client application that requests a connection to a service instance with this scope constructs a scope value of ContosoBank:Albany.

The scope-matching rules that the Discovery Service uses enable a client application to provide a very specific scope. However, the Discovery Service also returns all service endpoints that have less specific scopes. The scope matching rules implement a strict hierarchy based on the left-to-right order of scope elements. For example, if a client application requests a connection to a service instance with the scope ContosBank:Albany:SubBranchA, the Discovery Service will return endpoints for all available service instances that have the specified scope and those that have less specific scopes. In this example, it will return endpoints with the following scopes to the proxy:

  • ContosoBank:Albany:SubBranchA
  • ContosoBank:Albany
  • ContosoBank

The proxy object determines which of the endpoints returned by the Discovery Service most closely matches the client application request. In the example, this is the endpoint for the service that has the scope ContosoBank:Albany:SubBranchA. The proxy object then routes requests to that endpoint.

If a service instance that has the scope ContosoBank:Albany:SubBranchB is available, the endpoint for this service instance will not be included in the list returned to the proxy because it differs from or is less specific than the scope that the client application requested. Similarly, if a client application requests a connection to a service instance with a scope of ContosoBank:Albany, then the endpoint for the service instance with the scope ContosoBank:Albany:SubBranchA will not be included in the list returned to the proxy.

Note

 You can customize how the client proxy handles scopes and how it selects an endpoint to use. For more information, see Building a Custom Scope Provider and Ranker andBuilding a Custom Endpoint Selector.

Specifying Scope in a Client Application

The context object that a client application passes to the Discovery Service through the proxy contains two properties that are used to match elements of a service instance scope. These two properties are called Organization and Environment.

The Organization property contains some properties of its own which are also used by the scope-matching process. These properties are as follows:

  • Plant
  • Holding
  • BusinessUnit
  • OrganizationalUnit

The Environment property is a single string that lets you define the business environment in which the application should run.

A client application populates these properties with string values that the DCS Discovery Service uses to construct the scope for the request. The string values appear in the order shown in the following example.

Organization.Plant:Environment:Organization.Holding:Organization.BusinessUnit:Organization.OrganizationalUnit

For example, if a client application specifies a value of ContosoBank in the Organization.Plant property of the context object and leaves every other property as a null value, the DCS Discovery Service handles this as the single element scope ContosoBank. If a client application specifies ContosoBank in the Organization.Plant property and Albany in the Environment property of the context object and leaves every other property as a null value, the DCS Discovery Service handles this as the multi-element scope ContosoBank:Albany. If a client application specifies ContosoBank in the Organization.Plant property, Albany in the Environment property of the context object, and SubBranchA in the Organization.Holding property and leaves every other property as a null value, the DCS Discovery Service handles this as the multi-element scope ContosoBank:Albany:SubBranchA.

For more information about how to specify the scope for a service in a client application, Invoking a DCS Service from a Client Application.

Note

You can replace the default scheme implemented by the Context class (Plant, Holding, BusinessUnit, OrganizationalUnit) with a different custom scheme if it does not match the structural requirements of your organization. For more information, see Building a Custom Context Class.

See Also

Building a Custom Scope Provider and Ranker

Building a Custom Endpoint Selector

Building a Custom Context Class

Invoking a DCS Service from a Client Application.