AppSense Personalization API: Getting Started and Loading the Proxy DLL

As you may know last week AppSense released the 8.3 version of there AppSense Environment Manager product. It has several impressive features added, like user self-service. The feature that I found the most thrilling is the inclusion of the AppSense Personalization API. Now I am not sure if this is a new API or just the documentation of the existing functionality. Nevertheless it is a huge step in automation of AppSense Personalization.  I have on multiple occasions stated that if AppSense were to at least document their API then I would be more than happy to create a PowerShell module. Its time to keep up on my end of the promise so I will be working on creating a PowerShell module for the AppSense API.

You don’t need a special module to interact with the AppSense Personalization API as it is a Windows Communication Foundation (WCF)service. However a module will encapsulate the functions and make it easier to operate against.  In the documentation for the AppSense Personalization API they even have a Windows PowerShell example for calling the API. A small snippet is included below.

[codesyntax lang=”powershell” highlight_lines=”2,4″]

# Load service model
[Reflection.Assembly]::LoadWithPartialName("System.ServiceModel") > $null
# Load proxy dll
[Reflection.Assembly]::LoadFrom("$homeProfileManagement.dll") > $null
# Create binding
$wsHttpBinding = new-object System.ServiceModel.WSHttpBinding
$wshttpBinding.MaxReceivedMessageSize = 67108864
# Create endpoint
$endpoint = new-object System.ServiceModel.EndpointAddress(“http://localhost/PersonalizationServer/ProfileManagementService.svc”)

# And return client
new-object ProfileManagementClient($wsHttpBinding,$endpoint)

[/codesyntax]

In the snippet, Lines 2 and 4 load the WCF framework and the proxy dll for the Personalization service respectively.  These lines use the static methods from the System.Reflection.Assembly .Net class.

If you are using PowerShell version 2, and you should be using version 2 by now, there is a better way. Use the Add-Type cmdlet.  In the snippet below the respective lines have been replaced with the Add-Type cmdlet. This is a much cleaner implementation.

[codesyntax lang=”powershell” highlight_lines=”2,4″]

# Load service model
Add-Type -Assembly "System.ServiceModel"
# Load proxy dll
Add-Type -Path "$homeProfileManagement.dll"
# Create binding
$wsHttpBinding = new-object System.ServiceModel.WSHttpBinding
$wshttpBinding.MaxReceivedMessageSize = 67108864
# Create endpoint
$endpoint = new-object System.ServiceModel.EndpointAddress(“http://localhost/PersonalizationServer/ProfileManagementService.svc”)

# And return client
new-object ProfileManagementClient($wsHttpBinding,$endpoint)

[/codesyntax]

 Related articles