PSI WCF New-WebServiceProxy

1.3k views Asked by At

Motivation:

As we can read in Project Server Architecture

The SOAP-based ASMX interface for web services in the PSI is still available in Project Server 2013, but is deprecated.

As-Is

I have some PowerShell client snippets that I use to interact with Project Server. The standard way to communicate with the server are PSI ASMX web services.

To-Be

I would like to refactor the snippets to the standard of using PSI WCF web services.

Result

For example the following simple code works fine:

$Passwd = Get-Content $home\Documents\Password.txt | ConvertTo-SecureString
$Credential = New-Object -typename System.Management.Automation.PsCredential -argumentlist "user_name",$Passwd
$PWAUrl = "http://project_server_name/PWA"
$ProjSvcURL = $PWAUrl + "/_vti_bin/PSI/Project.asmx?wsdl"
$ProjSvcProxy = New-WebServiceProxy -uri $ProjSvcURL -credential $Credential
$projDataSet = $ProjSvcProxy.ReadProjectList()
$projDataSet.Tables[0].Rows.Count

but the simple conversion:

$Passwd = Get-Content $home\Documents\Password.txt | ConvertTo-SecureString
$Credential = New-Object -typename System.Management.Automation.PsCredential -argumentlist "user_name",$Passwd
$PWAUrl = "http://project_server_name/PWA"
$ProjSvcURL = $PWAUrl + "/_vti_bin/PSI/ProjectServer.svc"
...

fails with the message:

New-WebServiceProxy : The request failed with HTTP status 400: Bad Request.

Here is IIS log excerpt:

2014-01-05 13:50:41 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 401 1 2148074254 125

2014-01-05 13:50:41 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 401 2 5 328

2014-01-05 13:50:41 10.15.43.7 GET /_vti_bin/PSI/ProjectServer.svc/ntlm - 80 user_name XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 400 0 0 140

2014-01-05 17:58:33 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 401 2 5 312

2014-01-05 17:58:33 10.15.43.7 GET /PWA/_vti_bin/PSI/ProjectServer.svc - 80 - XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 401 1 2148074254 156

2014-01-05 17:58:33 10.15.43.7 GET /_vti_bin/PSI/ProjectServer.svc/ntlm - 80 user_name XXX.XXX.XXX.XXX Mozilla/4.0+(compatible;+MSIE+6.0;+MS+Web+Services+Client+Protocol+2.0.50727.5472) 400 0 0 109

It is interesting that I cannot find any examples of using WCF PSI with PowerShell. Have anyone tried to do this? Have anyone succeed? Can anyone publish any snippet?

1

There are 1 answers

0
PowershellNinja On

I just had the same Problem as you do. Project Server Scripts using the asmx and wanting to port them to the WCF Service pendants.

After some digging I found the following MSDN Site: http://msdn.microsoft.com/en-us/library/office/ms488627(v=office.15).aspx#pj15_PSIRefOverview_PSI

On there you got this Picture, shedding some light onto the whole WCF SVC thing: They are there, just not where you would expect them to be...

https://app.box.com/s/tsi7150bgra3rpg4n6yu

I tried to call the Service - and it worked like a charm.

I hope this helps you too!

P.S. Apologies for the box link... don't have enough reputation yet to post images ;)