Setting PSI Configuration Dynamically

Many folks trouble setting up PSI configuration. Following code could be used before accessing Project Server data via PSI. The code is an excerpt from Microsoft article.

private void SetClientEndpoint(string SiteUrl)
    Uri pwaUri = new Uri(SiteUrl);
    const int MAXSIZE = 500000000;
    const string svcRouter = "/_vti_bin/PSI/ProjectServer.svc";
    pwaUrl = pwaUri.Scheme + Uri.SchemeDelimiter + pwaUri.Host + ":" + pwaUri.Port + pwaUri.AbsolutePath;
    BasicHttpBinding binding = null;

    if (pwaUri.Scheme.Equals(Uri.UriSchemeHttps))
        binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
        binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);

    binding.Name = "basicHttpConf";
    binding.SendTimeout = TimeSpan.MaxValue;
    binding.MaxReceivedMessageSize = MAXSIZE;
    binding.ReaderQuotas.MaxNameTableCharCount = MAXSIZE;
    binding.MessageEncoding = WSMessageEncoding.Text;
    binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Ntlm;

    EndpointAddress address = new EndpointAddress(pwaUrl + svcRouter);

    projectClient = new SvcProject.ProjectClient(binding, address);
    = TokenImpersonationLevel.Impersonation;
    projectClient.ChannelFactory.Credentials.Windows.AllowNtlm = true;


One thought on “Setting PSI Configuration Dynamically

  1. Santosh

    Thanks a ton. I have configured successfully PSI using WCF after seeing your code. Expecting few more examples for PSI using WCF.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s