Kashif Nizam Qureshi

How to configure to access Project Server 2010 through PSI?

Hi folks,

I’ve seen many people roaming around to configure or much better to say, access Project Server 2010 via PSI. Here I’ll try to be as concise as possible. So, lets get started!

First download the Project Server SDK from here.

Compile Project Server Dll

Navigate to “C:\Program Files (x86)\Microsoft SDKs\Project 2010\Documentation\Intellisense\WCF”, unzip Source.zip and run CompileWCFProxyAssembly by double clicking it. (If it throws error that Source location couldn’t find, check that the source files should be under this hierarchy “…\WCF\Source\(*.cs)”).

Adding Project Server Dll to Visual Studio 2010

Right click the reference in VS 2010 and add reference, browse where your new ddl is located and click add.

Note: The Intellisense XML files (“C:\Program Files (x86)\Microsoft SDKs\Project 2010\Documentation\Intellisense”) need to be in the same directory as the assemblies to which you set references. It is easiest to put the assembly and copies of the documented Project Server assemblies in one directory, and then copy the Intellisense XML files to the same place. You then set references to those assemblies in the Visual Studio Solution Explorer.

Configuring Web.config

We’ll define EndPoints in the application’s web.config (e.g: http://kashif/pwa). By default, you’ll see the following section in web.config

Note: The same can be done dynamically through code. See this article.


<system.serviceModel>
  <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  <bindings>
    <basicHttpBinding>
      <binding name="projectBasicHttpConf" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" maxBufferSize="4194304" maxReceivedMessageSize="500000000" messageEncoding="Text" transferMode="StreamedResponse">
        <security mode="TransportCredentialOnly">
          <transport clientCredentialType="Windows" proxyCredentialType="Windows" realm="" />
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
</system.serviceModel>

Following contains five Endpoints for accessing different wcf services of PSI. Don’t forget to change server name with yours.


<system.serviceModel>
<!-- For EPM Customization Start-->
<behaviors>
<endpointBehaviors>
<behavior name="basicHttpBehavior">
<clientCredentials>
<windows allowedImpersonationLevel="Impersonation" />
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<!-- For EPM Customization End-->
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="projectBasicHttpConf" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="true" maxBufferSize="4194304" maxReceivedMessageSize="500000000" messageEncoding="Text" transferMode="StreamedResponse">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" realm="" />
</security>
</binding>
<!-- For EPM Customization Start-->
<binding name="basicHttpConf" sendTimeout="01:00:00" maxBufferSize="500000000" maxReceivedMessageSize="500000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="500000000" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" realm="" />
</security>
</binding>
<!-- For EPM Customization End-->
</basicHttpBinding>
</bindings>
<!-- For EPM Customization Start-->
<client>
<endpoint address="http://kashif/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcProject.Project" name="basicHttp_Project" />
<endpoint address="http://kashif/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcCustomFields.CustomFields" name="basicHttp_CustomFields" />
<endpoint address="http://kashif/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcResource.Resource" name="basicHttp_Resource" />
<endpoint address="http://kashif/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcQueueSystem.QueueSystem" name="basicHttp_QueueSystem" />
<endpoint address="http://kashif/pwa/_vti_bin/PSI/ProjectServer.svc" behaviorConfiguration="basicHttpBehavior" binding="basicHttpBinding" bindingConfiguration="basicHttpConf" contract="SvcLookupTable.LookupTable" name="basicHttp_LookupTable" />
</client>
<!-- For EPM Customization End-->
</system.serviceModel>

That’s it! Now you can access Project Server 2010’s data via PSI. Now in your code you can add Project Server data as shown below. Don’t forget to add the dll from the SDK. I’ve used the default namespace as ‘SvcProject’.

public static SvcProject.ProjectClient projectClient;

projectClient = new SvcProject.ProjectClient("basicHttp_Project"); // name of binding as defined above in web.config

SvcProject.ProjectDataSet currentProjDs = null;

currentProjDs = EPMHelper.projectClient.ReadProject(new Guid(Request.QueryString["ProjUID"]), SvcProject.DataStoreEnum.WorkingStore); // getting project by project uid from querystring

lblProjectName.Text= currentProjDs.Project[0].PROJ_NAME;// retrieving project name and displaying it
Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s