So, I am working on a Proof of Concept that integrates TFS 2008, Project Server 2007 and MOSS.
After I create a site based upon a custom site template I then create a project using the PWA web services (UpdateProjectWorkspaceAddress). The project is created but when I try and update the project workspace URL using the wssinterop web service it fails with a WSSWebIsNotProjectWorkspace error.
The template has the correct features activated and if I manually (through the PWA Admin UI) set the project workspace to the same web it works.
I don't know why it fails since everything looks good but I did discover a workaround after looking at it for many hours.
Call the same method twice. Catch the first error and ignore it. On the second call it returns sucessfully and sure enough it does update the URL.
I figured I would share that and save someone a few hours of frustration.
Example ( string projectName, Guid projectId, projectSvc which is reference to the webservice: http://servername/pwa/_vti_bin/psi/Project.asmx are passed in )
private void SetWSSURL(string projectName, Guid projectId, PWA.Project projectSvc)
{
WssInterop.
#region
WssInterop wssInterOpSvc = new WssInterop.WssInterop();
wssInterOpSvc.Url = http://servername/pwa/_vti_bin/psi/wssinterop.asmx;
wssInterOpSvc.Credentials = CredentialCache.DefaultCredentials; Get workspace info
// Get the admin settings necessary for site linkage
WssInterop.WssSettingsDataSet dsCurrentWssInfo = wssInterOpSvc.ReadWssSettings();
WssInterop.WssSettingsDataSet.WssAdminRow adminRow = dsCurrentWssInfo.WssAdmin[0];
Guid wssWebAppUid = adminRow.WADMIN_CURRENT_STS_SERVER_UID;
//I am not using the default site collection. I am using the TFS one (Sites/)
//if (!adminRow.IsWADMIN_DEFAULT_SITE_COLLECTIONNull())
//{
// siteCollection = adminRow.WADMIN_DEFAULT_SITE_COLLECTION;
//}
#endregion
#region Change Workspace Address
//try it once and ignore the output -- always fails the first time.
try
{
projectSvc.UpdateProjectWorkspaceAddress(projectId, "Sites/" + projectName, wssWebAppUid);
}
catch{ }
//do it again and it works. Don't ask me it's microsofts interface.
projectSvc.UpdateProjectWorkspaceAddress(projectId, "Sites/" + ProjectName, wssWebAppUid);
#endregion
}