Lessons Learned from writing a PSI Extension

Christophe Fiessinger's Blog

The latest news you need to know about Microsoft Enterprise Social & Project Portfolio Management

Lessons Learned from writing a PSI Extension

  • Comments 2

After writing a PSI extension recently, Mike Shughrue and I learned the following lessons:

¾  Follow the deployment procedure – coding is easyJ, deploying a PSI extension requires multiple steps, follow each carefully. A good way to test if the web service is properly deployed is to type its address in IE and ensure it returns its definition.

¾  Locating DISCO.EXE – if you can’t find it under C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin; then install it using your Visual Studio DVD (under .NET Framework SDK -> Tools)

¾  Generating WSDL & DISCO files – if you get the following error when running DISCO.EXE under C:\Program Files\Microsoft Office Servers\12.0\WebServices\Shared\PSI:

Microsoft (R) Web Services Discovery Utility

[Microsoft (R) .NET Framework, Version 2.0.50727.42]

Copyright (C) Microsoft Corporation. All rights reserved.

ERROR: http://chrisfie03:8181/_vti_bin/PSI/reporting.asmx

  - The document at the url http://chrisfie03:8181/_vti_bin/PSI/reporting.asmx was not recognized as a known document type.

The error message from each known type may help you fix the problem:

- Report from 'http://chrisfie03:8181/_vti_bin/PSI/reporting.asmx' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'.

- Report from 'DISCO Document' is 'Discovery document at the URL http://chrisfie03:8181/_layouts/error.aspx?ErrorText=File Not Found. could not be found.'.

  - The document format is not recognized.

- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'.

- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=utf-8').'.

 

If you would like more help, please type "disco /?".

 

The workaround is to create an IIS Virtual Directory under a site which is not managed by SharePoint Services V3, for instance “Test”, copy the ASMX in that directory and run this command instead:

disco" http://chrisfie03:81/test/reporting.asmx

Then copy the DISCO and WSDL files in the proper directory and follow the rest of the procedure to adapt the files to SharePoint V3.

¾  Automatically generate and deploy the DISCO and WSDL files – you could skip the steps above and use the following tool to automatically generate the two files and do the proper XML replacement: SharePoint Web Service DISCO and WSDL Generator

¾  Reading PSI configuration settings – Ideally the configuration settings such as database connection strings, impersonation parameters should not be hard coded in the C# for ease of deployment and maintenance. In our example the settings are defined in an application settings XML file (located under C:\Program Files\Microsoft Office Servers\12.0\WebServices\Shared\PSI) and the settings are set in the constructor of the WS. Another way to do it would be to store the settings in the web.config but he could not get it to work..

¾  Validate authorisation from all method call – to ensure that the EPM security is enforced each PSI calls validates the user using such algorithm:

private bool IsAuthorized(Guid userGuid)

    {

        bool isAuthorized = false;

        try

        {

            Reporting.wsResource.ResourceAuthorizationDataSet resAuthDS = resource.ReadResourceAuthorization(userGuid);

            Reporting.wsSecurity.SecurityGroupsDataSet secGrpDS;

 

            foreach (Reporting.wsResource.ResourceAuthorizationDataSet.GroupMembershipsRow dr in resAuthDS.GroupMemberships.Rows)

            {

                secGrpDS = security.ReadGroup(dr.WSEC_GRP_UID);

                if (secGrpDS.SecurityGroups[0].WSEC_GRP_NAME == SEC_GROUP)

                {

                    isAuthorized = true;

                    break;

                }

            }

        }

        catch

        {

            // Eat the exception and return false.

        }

        return isAuthorized;

    }

Leave a Comment
  • Please add 1 and 2 and type the answer here:
  • Post
  • Hi Christophe,

    What was the problem getting the extension to read web.config?  I got this working yesterday for a customer based on our HelloWorld:-

    1. Add using System.Configuration

    2. Set a reader:-

    AppSettingsReader reader = new AppSettingsReader();

    3. Get the data by key:-

    string myAppSetting = reader.GetValue("MyAppSetting", typeof(System.String)).ToString();

    Cast needed as Value is an object.

    4. Add appsettings section to web.config in c:\Program Files\Microsoft Office Servers\12.0\WebServices\Shared\PSI

    Inside <configuration> section

    <appSettings>

    <add key="myAppSetting" value="My Application Settings from web.config"/>

    </appSettings>

    Regards,

    Brian.

  • Check out this latest addition to the Project Server 2007 tool/code sample family by Colby Africa : Microsoft

Page 1 of 1 (2 items)