none
Project Server setting (Custom Fields and Lookup Tables) RRS feed

  • Question

  • Hi,

          I'm using ReadCustomFields(String.Empty,false) and ReadLookupTable(String.Empty,false,0) for reading all the CustomFields and Lookuptables from the PS Server settings using PSI, but I'm not getting the expected output instead I'm getting SOAPException and 401 error on both the functions.

          Could any one update the code to reading the CustomFields and LookupTables.

    Code for Lookup Tables 

    using (LookupTableWS.LookupTableDataSet lookupTablesDataSet = lookupTable.ReadLookupTables(String.Empty, false,0))  ---> error in this line
                {
                    foreach (LookupTableWS.LookupTableDataSet.LookupTableRow group in lookupTablesDataSet.LookupTables.Rows)
                    {
                        string ddlTitleClass = group.MD_PROP_NAME.ToString();
                     }
                }

    Code for Custom Fields 

    using (CustomFieldsWS.CustomFieldsDataSet customFieldsDataSet = customFields.ReadCustomFields(String.Empty, false))---> error in this line
                {
                    foreach (CustomFieldsWS.CustomFieldDataSet.CustomFieldsRow group in customFieldsDataSet .CustomFieldsRow .Rows)
                    {
                        string ddlTitleClass = group.MD_PROP_NAME.ToString();
                     }
                }

    Thanks

    -Bob

    Friday, August 27, 2010 2:54 PM

Answers

  • Hi Bob,

    According to the ReadLookupTables method in the SDK:  "The language parameter is used only if xmlFilter is an empty string." There is no LCID with a value of 0. Try, e.g., 1033 for English.

    Also, there are several global permissions required for ReadCustomFields. The errors you are getting seem to indicate a permission problem and/or a problem with initializing the lookupTable and customFields objects. Are you using Project Server 2007 or 2010? Can you use other PSI methods OK?

    Here is a sample that works for WCF in Project Server 2010 (the following code does not show the app.config file, the WriteFaultOutput method, or the ConfigClientEndpoints method; for examples of those methods, see the WCF sample in QueueCreateProject).

    using System;
    using System.Text;
    using System.ServiceModel;
    using System.Xml;
    using PSLibrary = Microsoft.Office.Project.Server.Library;

    namespace Microsoft.SDK.Project.Samples.ReadCustomFieldsTest
    {
        class Program
        {
            private const string ENDPOINT_CUSTOMFIELDS = "basicHttp_CustomFields";
            private const string ENDPOINT_LOOKUPTABLE = "basicHttp_LookupTable";
            // Change the output directory for your computer.
            private const string OUTPUT_FILES = @"C:\Project\Samples\Output\";

            private static SvcCustomFields.CustomFieldsClient customFieldsClient;
            private static SvcLookupTable.LookupTable lookupTableClient;

            private static string outFileCustomFieldsDs;
            private static string outFileLookupTableDs;
            private static int language = 1033;         // Use the English LCID by default.

            static void Main(string[] args)
            {
                if (args.Length > 0 && args.Length < 3)
                {
                    if (args[0].ToLower() == "-lcid")
                    {
                        language = Convert.ToInt32(args[1]);
                    }
                }

                outFileCustomFieldsDs = OUTPUT_FILES + "CustomFieldDataSet.xml";
                outFileLookupTableDs = OUTPUT_FILES + "LookupTableDataSet.xml";
                ConfigClientEndpoints(ENDPOINT_CUSTOMFIELDS);
                ConfigClientEndpoints(ENDPOINT_LOOKUPTABLE);

                try
                {
                    Console.WriteLine("Reading custom fields...");
                    SvcCustomFields.CustomFieldDataSet customFieldDs =
                        customFieldsClient.ReadCustomFields2(string.Empty, false);

                    Console.WriteLine(
                        "\nXML output of the CustomFieldDataSet:\n\t{0}",
                        outFileCustomFieldsDs);
                    customFieldDs.WriteXml(outFileCustomFieldsDs);

                    Console.WriteLine("Reading lookup tables...");
                    SvcLookupTable.LookupTableDataSet lookupTableDs =
                        lookupTableClient.ReadLookupTables(string.Empty, false, language);

                    Console.WriteLine(
                        "\nXML output of the LookupTableDataSet:\n\t{0}",
                        outFileCustomFieldsDs);
                    lookupTableDs.WriteXml(outFileLookupTableDs);
                }
                catch (FaultException fault)
                {
                    // Use the WCF FaultException, because the ASMX SoapException does not
                    // exist in a WCF-based application.
                    WriteFaultOutput(fault);
                }
                catch (EndpointNotFoundException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("\nInnerException: \n" + ex.InnerException.Message);
                }
                Console.Write("\nPress any key to exit... ");
                Console.ReadKey(true);
            }

    --Jim

    Saturday, August 28, 2010 5:18 AM

All replies

  • Hi Bob,

    According to the ReadLookupTables method in the SDK:  "The language parameter is used only if xmlFilter is an empty string." There is no LCID with a value of 0. Try, e.g., 1033 for English.

    Also, there are several global permissions required for ReadCustomFields. The errors you are getting seem to indicate a permission problem and/or a problem with initializing the lookupTable and customFields objects. Are you using Project Server 2007 or 2010? Can you use other PSI methods OK?

    Here is a sample that works for WCF in Project Server 2010 (the following code does not show the app.config file, the WriteFaultOutput method, or the ConfigClientEndpoints method; for examples of those methods, see the WCF sample in QueueCreateProject).

    using System;
    using System.Text;
    using System.ServiceModel;
    using System.Xml;
    using PSLibrary = Microsoft.Office.Project.Server.Library;

    namespace Microsoft.SDK.Project.Samples.ReadCustomFieldsTest
    {
        class Program
        {
            private const string ENDPOINT_CUSTOMFIELDS = "basicHttp_CustomFields";
            private const string ENDPOINT_LOOKUPTABLE = "basicHttp_LookupTable";
            // Change the output directory for your computer.
            private const string OUTPUT_FILES = @"C:\Project\Samples\Output\";

            private static SvcCustomFields.CustomFieldsClient customFieldsClient;
            private static SvcLookupTable.LookupTable lookupTableClient;

            private static string outFileCustomFieldsDs;
            private static string outFileLookupTableDs;
            private static int language = 1033;         // Use the English LCID by default.

            static void Main(string[] args)
            {
                if (args.Length > 0 && args.Length < 3)
                {
                    if (args[0].ToLower() == "-lcid")
                    {
                        language = Convert.ToInt32(args[1]);
                    }
                }

                outFileCustomFieldsDs = OUTPUT_FILES + "CustomFieldDataSet.xml";
                outFileLookupTableDs = OUTPUT_FILES + "LookupTableDataSet.xml";
                ConfigClientEndpoints(ENDPOINT_CUSTOMFIELDS);
                ConfigClientEndpoints(ENDPOINT_LOOKUPTABLE);

                try
                {
                    Console.WriteLine("Reading custom fields...");
                    SvcCustomFields.CustomFieldDataSet customFieldDs =
                        customFieldsClient.ReadCustomFields2(string.Empty, false);

                    Console.WriteLine(
                        "\nXML output of the CustomFieldDataSet:\n\t{0}",
                        outFileCustomFieldsDs);
                    customFieldDs.WriteXml(outFileCustomFieldsDs);

                    Console.WriteLine("Reading lookup tables...");
                    SvcLookupTable.LookupTableDataSet lookupTableDs =
                        lookupTableClient.ReadLookupTables(string.Empty, false, language);

                    Console.WriteLine(
                        "\nXML output of the LookupTableDataSet:\n\t{0}",
                        outFileCustomFieldsDs);
                    lookupTableDs.WriteXml(outFileLookupTableDs);
                }
                catch (FaultException fault)
                {
                    // Use the WCF FaultException, because the ASMX SoapException does not
                    // exist in a WCF-based application.
                    WriteFaultOutput(fault);
                }
                catch (EndpointNotFoundException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine("\nInnerException: \n" + ex.InnerException.Message);
                }
                Console.Write("\nPress any key to exit... ");
                Console.ReadKey(true);
            }

    --Jim

    Saturday, August 28, 2010 5:18 AM
  • Thanks Jim,

    Appreciated for your response. I'll try this...

    -Bob

     

    Monday, August 30, 2010 12:57 PM
  • Hi Jim,

            I fixed the problem, you are right its all permission issue. I added the login credentails to the webservice.

    Thanks

    -Bob

     

     

    Wednesday, September 1, 2010 2:24 AM