Filnet P8 Connection

Renaming the C# Source File

When you created the project, Visual Studio generated a C# source file, Program.cs, by default. Rename this file to better reflect its purpose.
  1. In the Solution Explorer pane, right-click Program.cs and click Rename.
  2. Type over the existing name, for example, P8Connector.cs.
  3. In the prompt for renaming all project references to this file, click Yes.

Coding the Connection

  1. If the C# source file is not already open, double-click its name in the Solution Explorer pane.
  2. In the code pane, immediately above the namespace line (such as namespace P8ApiSample), insert the following code, replacing the existing usingstatements.
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using FileNet.Api.Authentication;
    using FileNet.Api.Core;
    using FileNet.Api.Util;copy to clipboard
  3. In the code pane, within the class definition (such as within class P8Connector), insert the following code, replacing the existing Main method. Substitute the actual values for your environment for the connection parameter placeholders. (The default ports are 9080 for WebSphere® , 8080 for JBoss, and 7001 for WebLogic.)
     
    static void Main(string[] args)
    {
        try
        {
            // Set connection parameters; substitute for the placeholders.
            String uri = "https://<hostname>:<portnumber>/wsi/FNCEWS40MTOM/";
            String username = "<username>";
            String password = "<password>";
    
            // Get client context.
            IConnection conn = Factory.Connection.GetConnection(uri);
            UsernameCredentials creds = new UsernameCredentials(username, password);
            ClientContext.SetProcessCredentials(creds);
    
            // Get default domain.
            IDomain domain = Factory.Domain.FetchInstance(conn, null, null);
            Debug.WriteLine("Domain: " + domain.Name);
    
            // Get object stores for domain.
            foreach (IObjectStore store in domain.ObjectStores)
            {
               Debug.WriteLine("Object store: " + store.Name);
            }
            Debug.WriteLine("Connection to Content Platform Engine successful");
        }
            catch (Exception exc)
            {
               Debug.WriteLine(exc.ToString());
            }
    }
      copy to clipboard
  4. In the Visual Studio menu bar, click File > Save All.
  5. If the Output pane is not already open, click the View > Output.
  6. In the Solution Explorer pane, click your project.
  7. In the Visual Studio menu bar, click Build > Build Solution.
If your code does not compile, verify that you:

Comments

Popular posts from this blog

IBM FileNet: Bulk Processing using JavaScript

DB2 Date Time Functions

File Net Insert Document