
| Line: 1 to 1 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
WCF Hooks Extensions | ||||||||||||||||
| Line: 25 to 22 | ||||||||||||||||
| Hooks are an optional component of the Enkompass WCF processing architecture. To enable the hooks system, you must add a configuration file to the hooks application path. You can find your hooks application path by looking in your server's registry: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | | |||||||||||||||
| Once you have this value, combine the path listed above with the following: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | | |||||||||||||||
| For example: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | \\fileserver\e\ApplicationPath\Common\Hooks\HookConfiguration.config | |||||||||||||||
The configuration fileTheHookConfiguration.config configuration file should resemble the following: | ||||||||||||||||
| Line: 45 to 32 | ||||||||||||||||
The configuration fileTheHookConfiguration.config configuration file should resemble the following: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | <-- SyntaxHighlightingPlugin --> <?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="hookLoaderConfiguration"
type="cPanel.Core.Hooks.HookLoaderConfigurationSection,cPanel.Core.Hooks" />
</configSections>
<hookLoaderConfiguration>
<hookItems>
...
</hookItems>
</hookLoaderConfiguration>
</configuration>
<-- end SyntaxHighlightingPlugin --> | |||||||||||||||
| > > | <-- SyntaxHighlightingPlugin --> <!--l version="1.0" encoding="utf-8--> <?xml version="1.0" encoding="utf-8?><configuration> <configSections> <section name="hookLoaderConfiguration"
type="cPanel.Core.Hooks.HookLoaderConfigurationSection,cPanel.Core.Hooks" /> </configSections> <hookLoaderConfiguration> <hookItems> ... </hookItems> </hookLoaderConfiguration> </configuration>
<-- end SyntaxHighlightingPlugin --> | |||||||||||||||
| You may configure a few parameters in this file. | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
The <hookLoaderConfiguration> tagYou can configure the following attributes of the<hookLoaderConfiguration> tag: | ||||||||||||||||
| Line: 68 to 41 | ||||||||||||||||
The <hookLoaderConfiguration> tagYou can configure the following attributes of the<hookLoaderConfiguration> tag: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The <hookItems> tagThe<hookItems> tag is contained in within the <hookLoaderConfiguration> tag. This tag contains the collection of hooks to install on the system. Each hook is added into the <hookItems> tag using an <add> tag like so: | ||||||||||||||||
| Line: 76 to 47 | ||||||||||||||||
The <hookItems> tagThe<hookItems> tag is contained in within the <hookLoaderConfiguration> tag. This tag contains the collection of hooks to install on the system. Each hook is added into the <hookItems> tag using an <add> tag like so: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | %CODE{lang="html"}% <add name="UrlHooks" | |||||||||||||||
| > > | %CODE{lang="html"}% <add name="UrlHooks" | |||||||||||||||
| type="cPanel.Core.Hooks.UrlHookBehaviour, cPanel.Core.Hooks" | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | externalConfigurationPath="\\10.1.15.101\e\ApplicationPath\Common\Hooks\UrlHookConfiguration.config" />
| |||||||||||||||
| > > | externalConfigurationPath="\\10.1.15.101\e\ApplicationPath\Common\Hooks\UrlHookConfiguration.config" /> | |||||||||||||||
The <add> tagYou can use the<add> tag to add a single hook behavior to the Enkompass WCF pipeline. Each behavior represents a complete and independent way that hooks are processed. This <add> tag has the following attributes: | ||||||||||||||||
| Line: 89 to 55 | ||||||||||||||||
The <add> tagYou can use the<add> tag to add a single hook behavior to the Enkompass WCF pipeline. Each behavior represents a complete and independent way that hooks are processed. This <add> tag has the following attributes: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
| ||||||||||||||||
| Line: 116 to 76 | ||||||||||||||||
%CODE{lang="html"}% | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | <--l version="1.0--> | |||||||||||||||
| action="http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive" | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | actionType="Before" command="C:\logger\log.exe" args=" -before '{0}'" /> <add name="AfterAmIAlive" | |||||||||||||||
| > > | actionType="Before" command="C:\logger\log.exe" args=" -before '{0}'" /> <add name="AfterAmIAlive" | |||||||||||||||
| action="http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive" | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | actionType="After" command="C:\logger\log.exe" args=" -after '{0}'" /> | |||||||||||||||
| > > | actionType="After" command="C:\logger\log.exe" args=" -after '{0}'" /> | |||||||||||||||
| %ENDCODE% | ||||||||||||||||
| Line: 140 to 88 | ||||||||||||||||
The <commandHookConfiguration> tagThe<commandHookConfiguration> tag has the following attributes: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The <handledMessages> tagThis tag contains a list of the messages that will be processed by the command hook behavior. Each message must be specified by an<add> tag. | ||||||||||||||||
| Line: 157 to 101 | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The command, called by the command hook, should expect the incoming message data on standard input. It should send output to standard output and errors to standard error.
For hooks with action Type = Before, the input message format is as follows: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
| Log.exe Information: 0 : [ ] 2011-06-07 17:23:45Z [INFO : ] - Command Hook Application - Main - Before 'http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive' Message ID: f9fdae87-eb37-4a54-afa9-665691706297 | ||||||||||||||||
| Line: 177 to 119 | ||||||||||||||||
| Request:
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
For hooks with action Type = After, the input message format is as follows: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
| Log.exe Information: 0 : [ ] 2011-06-07 17:23:45Z [INFO : ] - Command Hook Application - Main - After 'http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive' Message ID: 27d2a629-8101-4338-bc5a-202fe40ccfd6 | ||||||||||||||||
| Line: 196 to 135 | ||||||||||||||||
| | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
Writing a commandWhen designing the command to process the hooked event, the process will pass the event name on the command line. | ||||||||||||||||
| Line: 208 to 144 | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
| ||||||||||||||||
| Line: 212 to 148 | ||||||||||||||||
| ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
Sample log | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | | |||||||||||||||
| Before http://tempuri.org/ICalculator/Divide Message ID: edbf2452-36db-4acd-a8ad-96f9f40b30aa | ||||||||||||||||
| Line: 241 to 174 | ||||||||||||||||
| | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
URL hooksURL hooks allow you to send WCF messages to a URL to be processed. The URL should use standard HTTP requests and response mechanisms. | ||||||||||||||||
| Line: 251 to 181 | ||||||||||||||||
%CODE{lang="html"}% | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | <--l version="1.0--> | |||||||||||||||
| %ENDCODE% | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
The <urlHookConfiguration> tag | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
| ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
The <add> tagThis tag configures the URL hook for a single message. Each message you want to process should include an<add> tag. | ||||||||||||||||
| Line: 279 to 195 | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The URL called by the command hook should expect incoming message data as part of the HTTP request body and should return data via the HTTP response body.
For hooks with actionType = Before, the input message format is as follows: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
| cPanel.Web Information: 0 : [ ] 2011-06-07 17:43:06Z [INFO : ] - Test - LogMessage - http://10.1.15.102:2086/logger/logmessage.aspx?action=Before&message=http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive cPanel.Web Information: 0 : [ ] 2011-06-07 17:43:06Z [INFO : ] - Test - LogMessage - Message ID: dd26771a-63f1-4e3c-bd89-0ab38310c21a | ||||||||||||||||
| Line: 299 to 213 | ||||||||||||||||
| Request:
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
For hooks with actionType = After, the input message format is as follows: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
| cPanel.Web Information: 0 : [ ] 2011-06-07 17:43:06Z [INFO : ] - Test - LogMessage - http://10.1.15.102:2086/logger/logmessage.aspx?stage=After&message=http://www.cpanel.net/schemas/2008/03/IServerAdministratorService/AmIAlive cPanel.Web Information: 0 : [ ] 2011-06-07 17:43:06Z [INFO : ] - Test - LogMessage - Message ID: b2cf36ce-8e6c-4b71-981a-f4faeed51f52 | ||||||||||||||||
| Line: 318 to 229 | ||||||||||||||||
| | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
| The URL hook should return one of the following HTTP status codes. You may use some of these codes to modify the message's processing cycle. | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| ||||||||||||||||
| Line: 330 to 239 | ||||||||||||||||
| ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
Hook configuration samplesThe following is an example ofHookConfiguration.config: | ||||||||||||||||
| Line: 355 to 263 | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | ||||||||||||||||
The following is an example of CommandHookConfiguration.config: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
|
| ||||||||||||||||
| Line: 381 to 285 | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The following zip files are examples for TestCommand and CommandHook: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > | ||||||||||||||||
The following is an example of UrlHookConfiguration.config: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ||||||||||||||||
| > > | ||||||||||||||||
|
| ||||||||||||||||
| Line: 415 to 313 | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < |
| |||||||||||||||
| > > |
| |||||||||||||||
The following zip file is an example of a test page for UrlHook: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
To make the logger above record information to your SAI log file, you must change system.diagnostics in your SAI web.config to: | ||||||||||||||||
| Line: 426 to 321 | ||||||||||||||||
To make the logger above record information to your SAI log file, you must change system.diagnostics in your SAI web.config to: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ![]() | |||||||||||||||
| > > | ![]() | |||||||||||||||
Extending hooksThe command and URL hooks classes were designed to allow developers to extend functionality to support the integration scenario beyond our current implementation. There are many extension points in both of these classes. | ||||||||||||||||
| Line: 436 to 329 | ||||||||||||||||
| The command hook contains three main groups of classes: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ![]() The CommandHook class summary | |||||||||||||||
| > > | ![]() The CommandHook class summary | |||||||||||||||
| The first class is the CommandHook class, which is derived from the hook class: | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | ![]() The CommandHook class | |||||||||||||||
| > > | ![]() The CommandHook class | |||||||||||||||
The command hook, as described above, provides a way to map a message received by the WCF API to an external, executable command. Out of the box, this class comes with fairly limited command and argument formatting. However, the FormatCommand() and FormatArguments() methods are virtual methods. This means that if the services provided by the class are inadequate, you can create your own CommandHook-derived class as seen below. | ||||||||||||||||
| Line: 445 to 338 | ||||||||||||||||
The command hook, as described above, provides a way to map a message received by the WCF API to an external, executable command. Out of the box, this class comes with fairly limited command and argument formatting. However, the FormatCommand() and FormatArguments() methods are virtual methods. This means that if the services provided by the class are inadequate, you can create your own CommandHook-derived class as seen below.
Additionally, if you do not like the current way the command hook writes messages to the input stream or processes the command response, you can override WriteMessage() or ProcessCommandResponse(). A sample custom implementation is shown below: | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | %CODE{lang="C"}% using System; using System.Collections.Generic; using System.Linq; using System.Text; using cPanel.Core.Hooks; namespace Sample { public class CustomCommandHook : CommandHook { protected override string FormatCommand(string command, HookExtension call, Stage stage, CommandHookMessage config) { // Do what you want here to create the command call string return base.FormatCommand(command, call, stage, config); } protected override string FormatArguments(string arguments, HookExtension call, Stage stage, CommandHookMessage config) { // Do what you want here to create the command arguments string return base.FormatArguments(arguments, call, stage, config); } } } | |||||||||||||||
| > > | %CODE{lang="C"}% using System; using System.Collections.Generic; using System.Linq; using System.Text; using cPanel.Core.Hooks; namespace Sample { public class CustomCommandHook : CommandHook { protected override string FormatCommand(string command, HookExtension call, Stage stage, CommandHookMessage config) { // Do what you want here to create the command call string return base.FormatCommand(command, call, stage, config); } protected override string FormatArguments(string arguments, HookExtension call, Stage stage, CommandHookMessage config) { // Do what you want here to create the command arguments string return base.FormatArguments(arguments, call, stage, config); } } } | |||||||||||||||
| %ENDCODE% | ||||||||||||||||
| Line: 481 to 353 | ||||||||||||||||
%CODE{lang="C"}% | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | public class CustomCommandHookBehavior : HookBehaviour | |||||||||||||||
| > > | public class CustomCommandHookBehavior : HookBehaviour | |||||||||||||||
| %ENDCODE% | ||||||||||||||||
| Line: 493 to 361 | ||||||||||||||||
With these three classes, you have a complete extension solution for the command hook. You can now add your custom hooks to your $cPanelApplicationPath$\Common\Hooks\HookConfiguration.config file, as you did with the hooks that we provided. | ||||||||||||||||
| Deleted: | ||||||||||||||||
| < < | ||||||||||||||||
| Changed: | ||||||||||||||||
| < < | <-- SyntaxHighlightingPlugin --> <add name="CustomCommandHooks" type="Sample.UrlHookBehaviour, Sample" externalConfigurationPath="\\10.1.15.101\e\ApplicationPath\Common\Hooks\CommandHookConfiguration.config" /> <-- end SyntaxHighlightingPlugin --> | |||||||||||||||
| > > | <-- SyntaxHighlightingPlugin --> <add name="CustomCommandHooks" type="Sample.UrlHookBehaviour, Sample" externalConfigurationPath="\\10.1.15.101\e\ApplicationPath\Common\Hooks\CommandHookConfiguration.config" /> <-- end SyntaxHighlightingPlugin --> | |||||||||||||||
| ||||||||||||||||