locked
WCF API for Master Data Services RRS feed

  • Question

  • I am new to MDS and was trying to use the MDS API to create a Windows application, which would show all the details that we get in the Stewardship portal. To start with, I want to get the list of all models on the server. Can anyone please let me know how to do it?

    Thanks in advance.

    Regards

    Manoj

    Tuesday, July 27, 2010 11:05 AM

Answers

  • Hi Manoj,

    Here it goes an example:  

    MDSService.ServiceClient service = new ServiceClient();
    
    International international = new International();
    
    MetadataResultOptions metadataResultOptions = new MetadataResultOptions();
    metadataResultOptions.Models = ResultType.Identifiers;
    
    MetadataSearchCriteria searchCriteria = new MetadataSearchCriteria();
    searchCriteria.SearchOption = SearchOption.BothUserDefinedAndSystemObjects;
    
    OperationResult operationResult;
    
    Metadata metadata = service.MetadataGet(international, metadataResultOptions, searchCriteria, out operationResult);
    
    foreach (var model in metadata.Models)
    {
       Console.WriteLine("Code: {0}, Name: {1}", model.Identifier.Id, model.Identifier.Name);
    }
    

    You can learn more about SearchCriteria here: http://msdn.microsoft.com/en-us/library/microsoft.masterdataservices.services.datacontracts.metadatasearchcriteria_members.aspx. It has very good documentation.

    In the MetadataResultOptions I chose to get only the model identifiers (code and name) by setting ResultType.Identifiers but if you have other model classification attributes you can chose ResultType.Details

    Hope it helps.


    Helena Monteiro
    • Marked as answer by Manoj Nair Friday, August 6, 2010 10:37 AM
    Thursday, August 5, 2010 2:24 PM

All replies

  • Hello Manoj -

    You can use the MetadataGet operation to get a list of models.  The API and its operations are documented in Books On Line here:

    http://msdn.microsoft.com/en-us/library/ee633803.aspx

    Cheers,
    John

     

    Wednesday, July 28, 2010 11:59 PM
  • Hi John,

    Thanks for your reply. I checked out the MetadataGet operation but wasnt able to find out how to get a list of models that have been published on the server. What condition needs to set in the SearchCriteria property?

    Regards

    Manoj

    Tuesday, August 3, 2010 5:42 AM
  • Hi Manoj,

    Here it goes an example:  

    MDSService.ServiceClient service = new ServiceClient();
    
    International international = new International();
    
    MetadataResultOptions metadataResultOptions = new MetadataResultOptions();
    metadataResultOptions.Models = ResultType.Identifiers;
    
    MetadataSearchCriteria searchCriteria = new MetadataSearchCriteria();
    searchCriteria.SearchOption = SearchOption.BothUserDefinedAndSystemObjects;
    
    OperationResult operationResult;
    
    Metadata metadata = service.MetadataGet(international, metadataResultOptions, searchCriteria, out operationResult);
    
    foreach (var model in metadata.Models)
    {
       Console.WriteLine("Code: {0}, Name: {1}", model.Identifier.Id, model.Identifier.Name);
    }
    

    You can learn more about SearchCriteria here: http://msdn.microsoft.com/en-us/library/microsoft.masterdataservices.services.datacontracts.metadatasearchcriteria_members.aspx. It has very good documentation.

    In the MetadataResultOptions I chose to get only the model identifiers (code and name) by setting ResultType.Identifiers but if you have other model classification attributes you can chose ResultType.Details

    Hope it helps.


    Helena Monteiro
    • Marked as answer by Manoj Nair Friday, August 6, 2010 10:37 AM
    Thursday, August 5, 2010 2:24 PM
  • Hello

     

    as an alternate solution, you can find a sample code on msdn that uses MasterDataServices DLL to get the models list

    http://code.msdn.microsoft.com/ModelDApiSample

    very simple to use

    dll used are

    Microsoft.MasterDataServices.Core.dll

    Microsoft.MasterDataServices.Deployment.dll;

    Microsoft.MasterDataServices.Services.dll;

    that you can find in 

    C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin (from the computer where MDS web app is installed)

    basicaly, the way to get the models list (console app) with this method is:

     

     

     Microsoft.MasterDataServices.Deployment.ModelReader reader = new ModelReader();

     

                Collection<Identifier> models = reader.GetModels();

                foreach (Identifier modelId in models)

                {

                    Console.WriteLine(modelId.Name);

                }

     

    Regards

     

     


    Xavier Averbouch
    Friday, August 6, 2010 7:41 AM
  • Thanks Helena. It works like a charm :)

    Here is the code that I have written

     

    MetadataGetRequest request = new MetadataGetRequest();

    request.SearchCriteria =

    new MetadataSearchCriteria();

    request.ResultOptions =

    new MetadataResultOptions() { Models = ResultType.Identifiers };

     

    MetadataGetResponse response = new MetadataGetResponse();

    response = mdService.MetadataGet(request);

     

     

    foreach (var model in response.Metadata.Models)

    {

     

    Console.WriteLine("Code: {0}, Name: {1}", model.Identifier.Id, model.Identifier.Name);

     

    }

    Friday, August 6, 2010 10:37 AM
  • Hi Helena,

        Could you please help me on how to get the security previlages for an entity for a windows uers ?

        Please reach me -  tnr.bala@hotmail.com , if you know the answer.

    Thanks & Regards,

    Bala.R


    Bala.R

    Wednesday, May 15, 2013 12:48 PM
  • Hi John,

     Could you please help me on how to get the security previlages for an entity for a windows uers ?

        Please reach me -  tnr.bala@hotmail.com , if you know the answer.

    Thanks & Regards,

    Bala.R


    Bala.R

    Wednesday, May 15, 2013 12:49 PM