Project.ReadProjectList Method

Gets the project name, GUID, and type of each project that is available on the Project Web App instance.

Namespace:  [Project Web service]
Service reference: http://ServerName:32843/[Project Service Application GUID]/PSI/Project.svc
Web service reference: http://ServerName/ProjectServerName/_vti_bin/PSI/Project.asmx?wsdl

[SoapDocumentMethodAttribute("http://schemas.microsoft.com/office/project/server/webservices/Project/ReadProjectList", RequestNamespace = "http://schemas.microsoft.com/office/project/server/webservices/Project/", 
	ResponseNamespace = "http://schemas.microsoft.com/office/project/server/webservices/Project/", 
	Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public ProjectDataSet ReadProjectList()

Return Value

Type: [Project Web service].ProjectDataSet
The ProjectDataSet schema contains only the Project table, with the following fields: PROJ_UID, PROJ_NAME, and PROJ_TYPE.

ReadProjectStatus can be used to get a list of projects that are visible to any Project Server user. Because it gets a list of all projects, ReadProjectList is intended for use with administrative utilities and requires a high level of permissions.

An application must be logged on to a Project Server instance with valid user credentials before it can execute ReadProjectList.

Use the Project property of the ProjectDataSet to access the list of projects.

Project Server Permissions

Permission

Description

ManageQueue

Allows a user to manage the Queuing Service. Global permission.

ManageSecurity

Allows a user to manage security settings. Global Permission.

The following example creates a sample project, and then lists the projects that are found.

For critical information about running this code sample, see Prerequisites for ASMX-Based Code Samples.

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web.Services.Protocols;
using System.Data;
using System.Threading;
using PSLibrary = Microsoft.Office.Project.Server.Library;

namespace Microsoft.SDK.Project.Samples.ReadProjectList
{
   class Program
   {
      [STAThread]
      static void Main()
      {
         try
         {
            const string PROJECT_SERVER_URI = "http://ServerName/ProjectServerName/";
            const string PROJECT_SERVICE_PATH = "_vti_bin/psi/project.asmx";
          
            // Set up the web service objects.
            ProjectWebSvc.Project projectSvc = new ProjectWebSvc.Project();

            projectSvc.Url = PROJECT_SERVER_URI + PROJECT_SERVICE_PATH;
            projectSvc.Credentials = CredentialCache.DefaultCredentials;

            // Read and display the project list.
            Console.WriteLine("Reading the project list");

            ProjectWebSvc.ProjectDataSet projectDs = projectSvc.ReadProjectList();
            foreach (ProjectWebSvc.ProjectDataSet.ProjectRow projectRow in projectDs.Project)
            {
               Console.WriteLine(projectRow.PROJ_NAME + " (" + projectRow.PROJ_UID + ")");
            }

         }
         catch (SoapException ex)
         {
            PSLibrary.PSClientError error = new PSLibrary.PSClientError(ex);
            PSLibrary.PSErrorInfo[] errors = error.GetAllErrors();
            string errMess = "==============================\r\nError: \r\n";
            for (int i = 0; i < errors.Length; i++)
            {
               errMess += "\n" + ex.Message.ToString() + "\r\n";
               errMess += "".PadRight(30, '=') + "\r\nPSCLientError Output:\r\n \r\n";
               errMess += errors[i].ErrId.ToString() + "\n";

               for (int j = 0; j < errors[i].ErrorAttributes.Length; j++)
               {
                  errMess += "\r\n\t" + errors[i].ErrorAttributeNames()[j] + ": " + errors[i].ErrorAttributes[j];
               }
               errMess += "\r\n".PadRight(30, '=');
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(errMess);
         }
         catch (WebException ex)
         {
            string errMess = ex.Message.ToString() +
               "\n\nLog on, or check the Project Server Queuing Service";
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + errMess);
         }
         catch (Exception ex)
         {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Error: " + ex.Message);
         }
         finally
         {
            Console.ResetColor();
            Console.WriteLine("\r\n\r\nPress any key...");
            Console.ReadKey();
         }
      }
   }
}

Community Additions

ADD
Show:
© 2014 Microsoft