Project.ReadProjectList Method

Gets the project name and GUID for each project that is available on the current instance of Project Server.

Namespace:  WebSvcProject
Assembly:  ProjectServerWebServices (in ProjectServerWebServices.dll)

Syntax

'Declaration
<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 Function ReadProjectList As ProjectDataSet
'Usage
Dim instance As Project
Dim returnValue As ProjectDataSet

returnValue = instance.ReadProjectList()
[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: WebSvcProject.ProjectDataSet
Returns a ProjectDataSetpopulated with the project name and GUID for each project on the current instance of Project Server.

Remarks

ReadProjectStatus() should be used to get a list of 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

Manage the Queuing Service. Global permission.

ManageSecurity

Manage security settings. Global Permission.

Examples

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

Please see Prerequisites for Reference Code Samples for critical information on running this code sample.

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();
         }
      }
   }
}

See Also

Reference

Project Class

Project Members

WebSvcProject Namespace