How do I get list of projects from TFS server using webservice?
Is documentation available for the TFS Webservices?
How do I get list of projects from TFS server using webservice?
Is documentation available for the TFS Webservices?
Your best bet is to use the TFS DLLs and that API, which is at http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx and http://msdn.microsoft.com/en-us/library/bb130334(v=VS.80).aspx . From what I understand, hitting the webservice directly is frowned upon.
To get a list of projects, I think there's multiple ways to do this. I posted code I used: use the GetServer method to get a project collection, then list through the ListProjects() method. I needed to do this because I needed to get the areas and iterations as well. This requires the Microsoft.TeamFoundation.Client namespace.
var tfs = TeamFoundationServerFactory.GetServer(Constants.TEAMFOUNDSERVER);
var projectCollection = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
foreach (var projectInfo in projectCollection.ListProjects())
{
//do stuff here
}
I concur with bryanjonker as well. Don't call the webservice directly, that's really reserved for internal use. Create your own access layer and call the API.
You can also use the object model to get access to the ICommonStructureService. I've recently started using this, and find it to be cleaner. The code below does the same as bryanjonker's example:
var tfs = TeamFoundationServerFactory.GetServer(serverUri);
var projectCollection = tfs.GetService<ICommonStructureService>();
foreach (var projectInfo in projectCollection.ListProjects())
{
listBox1.Items.Add(projectInfo.Name);
}