Friday, June 6, 2008

How to use PSI web service?

For any development regarding project server 2007 or project web access (PWA), we need to use PSI (project service interface) provided by project server.

There are many web service provided for different- different operation. Here is the MSDN link for Finding the PSI Web Services.

But first question is How to use PSI web service?
For that you need to login first for using any of the web service.

So here is the post how to login to use PSI web service?

For login we have to use “_vti_bin/PSI/LoginWindows.asmx” web service.

Here is the code snippet to login using loginwindows.asmx
private LoginWindows objLoginWindows = null;
private void button8_Click(object sender, EventArgs e)
{
if (Login())
{
//go ahead
}
else
{
//throw login failed error
}
}

private bool Login()
{
try
{
SetCredentials();
return objLoginWindows.Login();
}
catch (Exception ex)
{
return false;
}
}

private void SetCredentials()
{
try
{
objLoginWindows.Url = "http://pwaserver:7777/pwa/_vti_bin/PSI/LoginWindows.asmx";
//use dynamic referance and use url from web/app.config
objLoginWindows.Credentials = CredentialCache.DefaultCredentials;
//DefaultCredentials will use curently login user
}
catch
{
//log your error;
}
}

This way you can log in using loginwindows.asmx

After login successfully you can use any other web service according your permission.

Note: you have to need login every time whenever you want to access PSI.
Note: its good practice to log off using Logoff() method of the same loginwindows.asmx after completion of your work.
objLoginWindows.Logoff();

6 comments:

Jorge Flor said...

Hi! I have a c# application that uses PSI webservices. When I run it in Visual Studio .net it works normally, but if i create a virtual directory in the ISS, the method LoginWS.Login() send me the next error: 401 Unauthorized.

Note: in the security directories, i Check the "Anonymous Access" CheckBox.

SharePoint Kings said...

Jorge Flor,

since we had not tried it but we think for PSI service you need to use authentication.

anonymous access will not work.

Mohsen Hassan said...

Dears,

I use SharePoint Designer(SPD) 2007 with Project Web Access (PWA) for development. but it doesn't work and many sites and posts reported that SPD 2007 not work well with PWA.
So, I ask what the suitable editor for PWA Site development (to develope pages and services using project server 2007).

VS2005, 2008 anthor or what.

my development environment now is:
WinServer2003
SP2007
Project Server 2007
Development Editor [SPD 2007 not work well]??

Waiting your advices.

Thanks,

SharePoint Kings said...

Mohsen,

we are into development so not much idea about how designer worked with PWA. sorry about that.

Mohsen Hassan said...

Dear Sir,

Thanks you for your reply.

but I ask if I can make PWA site and customize it?

Where I can develop PWA, Write code and use PSI API.

Thanks for your help and reply.

SharePoint Kings said...

Mohsen,
That's what we are saying that we do not have much idea about customization.




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com