SmartObject WCF Services
K2 provides a Windows Communication Foundation (WCF)-based service that utilizes SOAP-based messaging to interact with a SmartObject from custom .NET applications. This allows developers to interact with a SmartObject at runtime through a web service without requiring a reference to any SourceCode client .dlls.
The WCF services are generally used for .NET solutions with server-side processing, and they provide strongly-typed access to SmartObjects. The service supports SOAP and ATOM formats and is accessible over HTTP or HTTPS.
For authentication, the service supports all standard and custom K2 security providers.
The WCF services are set up by changing the K2HostServer.exe.config file’s <smoServices> section. In this configuration file you may decide how SmartObjects will be exposed (for example, the address where they should be exposed and whether to use HTTP or HTTPS) and which SmartObjects should be exposed as WCF service endpoints. (You may have a large selection of SmartObjects in your K2 environment but only want to expose certain SmartObjects as WCF services.).
Each SmartObject or SmartObject category/folder that is exposed as a WCF service gets a dedicated WCF Service Endpoint. The Endpoint describes the SmartObject data and service contract, and when you add a reference to the endpoint you will obtain strongly-typed access to the SmartObject, its properties and its methods. You can change the endpoint address in the K2HostServer.exe.config file, and K2 will then append a path for the selected SmartObjects. These endpoints are dynamically generated and can be dynamically updated whenever a new SmartObject is deployed to the K2 server or when a SmartObject definition is updated on the K2 server.
The generated endpoints will look something like this
The Service Root URI is defined by the K2HostServer.exe.config file, while the Service path is defined by the SmartObject’s location in the category system or by the Alias value specified in the K2HostServer.exe.config file.
To review the available endpoints for a K2 environment, you can browse to a XML file located in the SmartObject Services URI. The address will look something like this (the exact address depends on the configuration of the smoServices section of the K2HostServer.exe.config file)
http(s)://[Server]:[Port]/SmartObjectServices/endpoints/endpoints.xml
For code samples demonstrating the basic use of the SmartObjects WCF services, see the topic SmartObjects WCF Services Samples. For more information on the configuration of this service, see the topic SmartObject WCF Services Reference
Troubleshooting
Issue:
You get the error: Object 'X' has been disconnected or does not exist at the server.
Details:
A timeout occurs when executing endpoints SmartObjects, such as those based on WCF, Web Services, and assemblies.
Endpoint SmartObjects create their own appdomains that use an appdomain communcation channel when you execute a SmartObject method. When the lifetime of the channel expires, you get a timeout error. You can change a setting in the K2HostServer.config file to adjust the time the channel stays open waiting for a response, in minutes.
Resolution:
- Stop the K2 Server
-
Add the attribute appdomainproxytimeout to <sourcecode.smartobjects.runtime node of the <install drive>:\Program Files\K2\Host Server\Bin\K2HostServer.exe.config file
-
And specify your desired timeout in minutes.
-
Start the K2 server.