When using Project Server on-premises, custom applications were bound to use PSI services. In Project Online 2013, the interface of choice is now CSOM, and officially, PSI is no longer supported.
However CSOM has its own limitations and it doesn’t expose (yet) the full functionality of PSI, so if you’re looking for calling PSI in Project Online, you basically need to:
1. Get the authentication cookie for the account you’re going to authenticate with.
2. Set the authentication cookie on the request made by your services.
This could come in very helpful when you’re migrating to Online but have a handful of already made customizations using PSI.
Getting the authentication cookie is straightforward. Just use the SharePointOnlineCredentials class, and get the cookie:
String projectOnlineUrl = "https://yourtenant.sharepoint.com/sites/pwa";
String userName = "firstname.lastname@example.org";
String passWord = "yourpassword";
SharePointOnlineCredentials spoCred = new SharePointOnlineCredentials(userName, SecureStringFromString(passWord));
String authCookie = spoCred.GetAuthenticationCookie(new Uri(projectOnlineUrl));
Setting the cookie on the WCF service requests needs a bit more work. However, the article here helps, so after creating the CookieBehavior and CookieMessageInspector classes as described in the article, we can attach them to our clients. To simplify, we can create a custom WcfClientBase class that will do this automatically for us.
class WcfClientBase<TServiceContract> : ClientBase<TServiceContract>, TServiceContract where TServiceContract: class
public WcfClientBase(String authCookie, String serviceUrl)
Binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport),
Address = new EndpointAddress(new Uri(serviceUrl + "/_vti_bin/psi/projectserver.svc"))
Then, we can define proxies for each interface we use, and implement the methods by calling them on the base.Channel
class ProjectClient : WcfClientBase, IProject
public ProjectDataSet ReadProjectList()
Last, we can invoke the service as such:
IProject projClient = new ProjectClient(authCookie, projectOnlineUrl);
ProjectDataSet pds = projClient.ReadProjectList();
Download the PSIOnline code sample.