Custom SmartObject Service Brokers

You can think of K2 SmartObjects as an "Abstracted Data Access Layer" which exposes data and services from Providers (such as SQL databases, SharePoint lists and so on) to applications (such as Reports, Workflows and User Interfaces). SmartObjects are essentially a “middle layer” between sources of data and applications that require the data. K2 provides a number of standard "connectors" (known as "Service Brokers") that can expose common LOB systems (such as SQL databases, Oracle Databases, Active Directory, SharePoint, Microsoft CRM and many more) as SmartObjects, However, it is certainly possible to extend the standard set of brokers by writing custom Service Brokers that integrate with other LOB systems. SmartObjects are the preferred mechanism to integrate with LOB systems and therefore it is quite common to write custom Service Brokers to connect to other systems not supported by K2 out-of-the-box.

SmartObjects act as a translator (or “adapter”) which takes the complex "language" of the LOB system and converts the data and methods into an easy-to-understand, consistent interface that the consumers can understand. Internally, this is achieved through the use of system-specific "connectors" called Service Brokers and exposing those as Service Objects, which can be used to assemble SmartObjects that in turn are used in Form, Workflows and Reports.

SmartObjects are executed by the K2 Server. Essentially, the K2 server acts as the "engine" that will query the Provider through the Service Broker when a SmartObject is executed. While you can certainly use or "call" SmartObjects in many consuming applications, it is not the application itself that does the actual processing to retrieve the data from the underlying system: that task is performance by the K2 server. The K2 server does not cache SmartObject data. This means that K2 will always retrieve the latest data from the Provider whenever the SmartObject is executed.

Service Brokers are implemented by creating a .NET class library which references SourceCode.SmartObjects.Services.ServiceSDK.dll and then inherits and extends the SourceCode.SmartObjects.Services.ServiceSDK.ServiceAssemblyBase base class. The class library would implement all the necessary logic to expose the Provider's Objects as Service Objects and handle all interaction with the Provider. Once the assembly is coded and built, you would copy the resulting .dll file to each of the physical K2 servers in your environment, and then use a K2 tool or utility to register the Broker with the K2 environment and create Service Instance(s) for the Broker.

The K2 Market on the K2 community site has a number of community-developed and shared Service brokers, often including full source code. While these brokers are not provided nor supported by K2, you may want to review the available Service Brokers if you need to integrate with a particular technology; someone else may already have written a Broker that you can download and use.

K2 blackpearl Developers Reference4.7
Video Links Learn Support
No videos found for this article
K2 on YouTube
No Additional links found for this article
No self-learning content for this article
Try some scenarios...
No relevant support links available for this article