.NET Code Sample

using System;

using Project.ApplicationAPI;
using Project.AuthenticateAPI;

namespace TestFramework
{
    /// <summary>
    /// 
    /// <summary>
    public class SAMPLE
    {
        public SAMPLE()
        {
            // 
            // TODO: Add constructor logic here
            //
        }

        //User, password, DataSource Name are use to authenticate with the service
        static String username = "administrator";
        static String password = "ibmrpm";
        static String dsn = "jdbc/RPMDATASOURCE";

        //Session ID is use for all transaction and is get from the 
        //Authenticate.login function. The session ID will replace the
        //User password while transacting
        private static String sessionid;

        //The url will describe the location of all the services
        //It will need to have the service attach to the url like
        //http://localhost:8080/rpm/services/Application
        private static String url = "http://localhost:9081/rpm/services/";

        //Object AuthenticateService which provide de 
        //login/logout/change password interface
        //It is a wsdl imported from project->addWebReference
        static AuthenticateService auth;

        //Object ApplicationService which provide de
        //Save/load/checkin/checkout interface
        //It is a wsdl imported from project->addWebReference
        static ApplicationService service;

        //Containers to be save/load in the database
        static Pool pool;
        static Resource resource;
        /// <summary>
        /// The main entry point for the application.
        /// <summary>
        [STAThread]
        static void Main()
        {
            //Get an instance of authenticateService
            auth = new AuthenticateService();

            //Specify the url to connect to which is represented
            //by the location of all the services and the specified
            //service Authenticate
            auth.Url = url + "Authenticate";

            //Login from the authenticateService api with your
            //user/password/dsn. This will return your session ID
            //To use for the application acces.
            sessionid = auth.login(username, password, dsn);

            //Create a container to save in the RPM Database
            //The creation of the container pool is being done
            //by the application api. All the container are held
            //Within the application wsdl
            pool = new Pool();
            //Specify a name or anything you want for the Specific 
            //pool
            pool.name = "DOTNET";


            //Get an instance of ApplicationService
            service = new ApplicationService();

            //Specify the url to connect to which is represented
            //by the location of all the services and the specified
            //service Application
            service.Url = url + "Application";

            //Use the service instance to save the pool with the
            //sessionID, to be authenticate, the pool, which you're
            //looking to save, and the scope, to represente the
            //structure of multiple linked container
            ReloadType saved = new ReloadType();
            saved = ReloadType.ReloadResult;

            service.save(sessionid, pool, null, saved);

            //Query the Pool you have saved in the RPM Repository
            //with an XPath that has the name of the pool in it
            //The Query return an array of Pool 
            //that has the name you have query

            RPMObject[] poolarray = service.loadFromXpath(sessionid,
            "/Pool[name='DOTNET']", null).rpmObjectList;

            //Take the first object of the returned array
            pool = (Pool)poolarray[0];

            //Create a new resource that will be save
            resource = new Resource();
            resource.fullName = "youfullrname";
            resource.userName = "yourusername";
            resource.password = "yourpswd";
            resource.active = true;


            //Set a resource that is contain within the pool
            //There can be multiple resource under the pool
            //This is why you need to saved them in an array
            pool.resources = new Resource[] { resource };

            //The pool scope is use to specify the hiearchy of the
            //the containers saved in the database
            PoolScope scope = new PoolScope();
            //Set a Resource under the pool represents a multi-level structure
            //If it is not set, the only container save will be the pool
            scope.resources = new ResourceScope();

            //The application interface will connect to 
            //the server with the sessionId
            //Send the container with the scope so it is 
            //correctly saves in the RPM Database
            service.save(sessionid, pool, scope, ReloadType.SavedResult);

            //Delete the Pool from the RPM Repository
            service.delete(sessionid, pool);

            auth.logout(sessionid);
        }
    }
}