This simplified Hello World example displays settings and content from a remote application in an AquaLogic Ensemble pagelet. This page provides instructions and sample code for .NET developers.
Note: This example assumes you have installed the AquaLogic Interaction Development Kit (IDK) version 6.0. For details on installing the IDK, see the IDK Product Documentation.
The steps below are for the Visual Studio .NET IDE.
Start Visual Studio and click File | New Project | C# Projects | ASP.NET Web Service. Type an intuitive name in the Location field.
Delete Service1.asmx and Web.config.
In the new project, click File | Add Existing Item.
Browse to the \devkit folder in the IDK installation directory.
In the File Types mask, click All Files.
Select all the .asmx files and Web.config. Do not select the \bin directory.
Click Open. You will be prompted to create a class file for each .asmx file; click No for each file.
Add the IDK assemblies:
In the Solution Explorer (usually in the upper right), you should see the project you created in Step 1.
Right-click References and click Add Reference.
Browse to the \devkit\bin folder in the IDK installation directory.
Select all the .dll files (Ctrl+A). These are the assemblies that resolve the references in the *.asmx files.
Click Open | OK.
In the Solution Explorer References, you should now see edk, openfoundation, etc.
Click File | Add New Item to create new classes and complete your project.
As noted above, this example creates a pagelet that displays information from the proxy, including setting values. .NET pagelets use a code-behind page (.aspx.cs) to retrieve settings and a Web form (.aspx) to display the portlet.
The code-behind page instantiates the IDK and uses the IProxyContext interface to retrieve IProxyRequest and IProxyUser objects to access information about the user and the settings associated with the pagelet.
using System; namespace IDKProxyWS { /// <summary> public class IDKPagelet : System.Web.UI.Page private
void Page_Load(object sender, System.EventArgs e) private
void InitializeCSP() IProxyRequest proxyRequest; try factory
= ProxyContextFactory.getInstance(); proxyUser = proxyRequest.GetUser(); Att1 = (String)proxyRequest.GetSetting("attr1"); byte[] bpayload = proxyRequest.GetPayload().GetText(); } } #region Web Form Designer generated
code // } /// <summary> this.AddButton.Click
+= new } } } |
The Web form that displays the pagelet (IDKPagelet.aspx) displays the information retrieved by the code-behind page (IDKPagelet.aspx.cs).
<%@ Page Language="c#" runat="server" CodeBehind="IDKPagelet.aspx.cs" AutoEventWireup="false" inherits="IDKProxyWS.IDKPagelet" %> <%@ import Namespace="System.Collections"
%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <body MS_POSITIONING="GridLayout"> Proxy Pagelet <BR> <% Response.Write("IDK Proxy Pagelet<BR>"); Response.Write("Pagelet Attributes:<BR>"); Response.Write("Pagelet
XML Payload:<BR>"); %> </span> |
Note: These steps are for IDK version 6.0.
After Visual Studio is set up for development against the .NET IDK as described above, follow the steps below to deploy new services.
Compile the class that implements the interface.
If you do not already have a virtual directory in IIS for your services, add one using the steps below:
Click Start | Settings | Control Panel | Administrative Tools | Internet Services Manager (Internet Information Services).
Select Default Web Site.
Click Action | New | Virtual Directory and type the name of your Visual Studio Location. Click Next twice. Type the path to the home directory for the IDK: <installdir>\idk\6.0\devkit\dotnet.
Check both the Read and Scripts only checkboxes if they are cleared (they should be checked by default). Click Next, then click Finish.
The class files will be compiled to the \bin folder in the <installdir>\idk\6.0\devkit\dotnet directory.
To deploy the pagelet in Ensemble, follow the steps below.
Note: These steps are for IDK version 6.0 and AquaLogic Ensemble 1.0.
Create a new Producer resource in Ensemble.
Go to Applications | Resources and click Create New. Name the new resource "idkProxy".
On the Connections tab, for the Internal URL Prefix, enter the URL to the remote server location that hosts the pagelet (http://<hostname>:<port#>/idkProxy/). For the External URL Prefix, enter "/idkProxyProducer/".
Click Save.
Create a new pagelet using the Producer resource created in step 1. Go to Applications | Pagelets and click Create New.
Go to Applications | Pagelets and click Create New. Name the new pagelet "idkProxy". For the Library, enter "idkProxyLib".
To choose the resource, click Select and choose the Producer resource you created in step 1 (idkProxy).
On the Location tab, for the URL Suffix, enter the name of the pagelet on the remote server (IDKPagelet.aspx).
On the Parameters tab, add the two parameters used by the pagelet: Att1 and Att2. For the Type, enter String.
Click Save.
Go to the General tab and copy the sample code for the pagelet (you will need it in step 4 below).
In the /idkProxy
directory, create a new HTML page called "consumer.html" and
paste in the sample code you copied in the previous step. The embedded
pt:ensemble.inject
tag retrieves content from the resource/pagelet you created in the previous
steps. This example uses the ALI
Scripting Framework to set the session preference used in pagelet.jsp.
The HTML page is required to display the pagelet content in Ensemble.
The HTML page can be hosted on any server accessible to Ensemble; this
example uses a single web application (idkProxy) for simplicity.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <title>IDK Proxy Pagelet</title> </head> <body>
<pt:ensemble.inject xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:name="idkProxyLib:idkProxy" Att1="value1" Att2="value2"> <xml> <payload>Here is the xml payload!</payload> </xml> </pt:ensemble.inject> </body> |
Note: You must include the namespace xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' in the pt:ensemble.inject tag or the tag will not work.
Create a new Consumer resource in Ensemble. This resource will host the consumer.html page that consumes the resource/pagelet.
Go to Applications | Resources and click Create New. Name the new resource "idkProxyConsumer".
On the Connections tab, for the Internal URL Prefix, enter the URL to the remote server location that hosts the consumer.html page (http://<hostname>:<port#>/idkProxy/). For the External URL Prefix, enter "/idkProxyConsumer/".
Click Save.
To view the pagelet
in Ensemble, hit the consumer.html page on the Consumer resource: http://<Ensemble_proxy_host>:<Ensemble_proxy_port>/idkProxyConsumer/consumer.html.
Note: By default, new pagelets and resources are only accessible
by the "administrator" user. For additional information on configuration,
see the Ensemble documentation.
To deploy this pagelet as a portlet in the AquaLogic Interaction portal, you could register the pagelet.jsp file as a Pagelet Web Service object. Payload functionality is not supported in the ALI portal. For details on the main differences between pagelet and portlet development, see Pagelet vs Portlet.