To communicate with the portal via the Portal Remote Client (PRC), you must first establish a session with the portal. This session is used to manipulate portal objects via the PRC, as shown in the topics on the following pages.
Note: Before writing any code, you must prepare a custom project that references the standard EDK library (Java: edk.jar / .NET: edk.dll). For instructions, see The Plumtree Development Environment: Setting up the EDK.
To establish a session with the portal, acquire a reference to an IRemoteSession object (for background information on portal objects, see Plumtree Object Model). The simple code snippets below do the following:
Create a new class (HelloWorldSession).
Create a new remote session using RemoteSessionFactory. (The code below logs in with a username of "administrator" and no password.)
Print out the portal API version from the remote session.
(If you cannot see the code snippet you need, reset the language filter at the top of the page.)
Java:
import java.net.URL; import com.plumtree.remote.prc.*; public class HelloWorldSession { public static void main(String[] args) throws Exception { try { IRemoteSession session = RemoteSessionFactory.getExplicitLoginContext( new URL("http://portalserver/ptapi/services/QueryInterfaceAPI"), "administrator","");
System.out.println(session.getAPIVersion()); } catch(Exception e) { System.err.println(e.getMessage()); e.printStackTrace(System.err); } } }
C#:
using System; using Plumtree.Remote.PRC; public class HelloWorldSession { public static void Main(string[] args) { try { IRemoteSession session = RemoteSessionFactory.getExplicitLoginContext( new Uri("http://portalserver/ptapi/services/QueryInterfaceAPI"), "administrator","");
Console.Out.WriteLine(session.GetAPIVersion()); } catch(Exception e) { Console.Error.WriteLine(e.Message); Console.Error.WriteLine(e.StackTrace); } } }
VB:
Imports System Imports Plumtree.Remote.PRC Module HelloWorldSession
Sub Main() Try Dim session As IRemoteSession session = RemoteSessionFactory.GetExplicitLoginContext( _ New Uri("http://portalserver/ptapi/services/QueryInterfaceAPI"), _ "administrator", _"") Console.Out.WriteLine(session.GetAPIVersion()) Catch e As Exception Console.Error.WriteLine(e.Message) Console.Error.WriteLine(e.StackTrace) End Try End Sub
End Module
You can also access an IRemoteSession through the EDK Portlet API (IPortletContext.GetRemoteSession). For details on EDK methods, see the EDK API documentation, available on the Developer Center (http://devcenter.plumtree.com).
Once you have initiated a session with the portal, you can use PRC methods to manipulate portal objects. For details and sample code, see one of the PRC topics. (For a detailed explanation of each topic, see Remote APIs.)
Extending Portal Server Functionality
Object Management
Portlet Operations
User Operations
Knowledge Directory Operations
Portal Jobs
Extending Search Server Functionality
Extending Collaboration Server Functionality