Skip to Content
avatar image
Former Member

MDM .Net API does not work

I'm following the SAP MDM .Net API help pages and keep getting a System.ArgumentException with many different variations of this otherwise simple code. We are running MDM 7.1 SP05 and have downloaded the 7.1.5.92 .Net API and referenced it from Visual Studio 2010.

I have sent messages to SAP and still can not find a solution. Any help is greatly appreciated!!

Here's the code:

string serverName = "asd00fe";

string repName = "HMK_Material_001";

string repUser = "Admin";

string repPswd = "sapmdm";

string regName = "English [US]";

UserSessionContext userCtx = new UserSessionContext(serverName, repName, regName, repUser);

userCtx.ApplicationName = "TestDotNetApp";

userCtx.RegionLocale = new System.Globalization.CultureInfo("en-US"); //I also commented out this line RegionLocale line without any change in results

string userSessionText = SessionManager.Instance.createSession(userCtx, SessionTypes.USER_SESSION_TYPE, repPswd);

Here's the Exception Stack Trace:

at com.sap.mdm.intern.langstrings.CultureInfoFactory.Create(String languageCode, String countryCode) at com.sap.mdm.intern.RegionDefinitionHelper.convertFrom(RegionDefinition srcRegDef) at com.sap.mdm.commands.GetRepositoryRegionListCommand.execute() at com.sap.mdm.intern.session.InternalSessionManager.getRepositoryRegions(UserSessionContext ctx) at com.sap.mdm.intern.session.InternalSessionManager.createUserSession(UserSessionContext ctx, String password) at com.sap.mdm.intern.session.InternalSessionManager.innerGetSession(IDictionary sessionCache, MdmSessionContext ctx, Int32 sessionType, String password) at com.sap.mdm.intern.session.InternalSessionManager.createSession(MdmSessionContext ctx, Int32 sessionType, String password) at com.sap.mdm.session.SessionManager.createSession(MdmSessionContext ctx, Int32 sessionType, String password) at RefExMdmApp.MdmConnector.getServerData() in C:\Users\kknapp\Documents\Visual Studio 2010\Projects\RefExSolution\Main\RefExSolution\RefExMdmApp\MdmConnector.cs:line 66 at RefExWebAppProject.MdmAccess.Get_MdmData(Object sender, EventArgs e) in C:\Users\kknapp\Documents\Visual Studio 2010\Projects\RefExSolution\Main\RefExSolution\RefExWebAppProject\MdmAccess.aspx.cs:line 23

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    avatar image
    Former Member
    Feb 17, 2011 at 08:27 PM

    Hello Kevin Knapp

    Where is your Connection?

    Did you Connect to repository before create your session?

    more about DotNet API is here:

    http://help.sap.com/saphelp_nwmdm71/helpdata/en/13/041975d8ce4d4287d5205816ea955a/content.htm

    Regards

    Kanstantsin Chernichenka

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Thank you for the continued help and our initial goals are very simple. We are simply trying to make a good connection to the MDM server from the .Net API. Once that basic element works, then we will try to inquire on a material for display in a Sharepoint webpart.

      The language code on the MDM server is "eng" and the country code is "US".

      I have tried setting the userContext RegionName and RegionLocale to virtually every possibility with no change in the resutls

      For example:

      userCtx.RegionName = "English US"; //also tried "eng", "US, "USA", etc.

      userCtx.RegionLocale = new System.Globalization.CultureInfo("en-US");

  • avatar image
    Former Member
    Feb 28, 2011 at 02:57 PM

    I am having exactly the same problem. I have tried every combination of culture settings and region code I can think of but I have not made any progress. - Just thought I would post this here so that you know you are not alone and if I do find out how to fix this problem i will post the answer here

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 11, 2011 at 04:17 PM

    Our SAP expert suggested that I try using an earlier version of the ,net framework (not .net 4) and i can confirm that I can connect without any issues using .net 3.5. For reference my code is below:

    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    using com.sap.mdm.session;
    
    namespace connect45
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("started");
    
                string mdsName = "******"; // the name of the Master Data Server
                string repositoryName = "PocHierarchy11";
                string regionName = "English [US]";
                string regionLocale = "en-US";
                string userName = "******"; 
                string password = "******"; 
                Program program = null;
    
                start(mdsName, repositoryName, regionName, regionLocale, userName, password, program);
            }
    
            private static void start(String serverName, String repositoryName, String regionName, String regionLocale, String user, String password, Program program)
            {
                // create a user session context
                UserSessionContext context = new UserSessionContext(serverName, repositoryName, regionName, user);
                
                context.ConnectionType = ConnectionTypes.LOCAL_SIMPLE_CONNECTION;            
                context.RegionLocale = new CultureInfo(regionLocale);
                context.RegionName = regionName;
    
                Console.WriteLine("Setup context");
    
                // create a user session
                SessionManager.Instance.createSession(context, SessionTypes.USER_SESSION_TYPE, password);
    
                Console.WriteLine("Session started");
            }
        }
    }
    

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thank you for the helpful reply Richard!

      I suspect you are correct and will give this a try soon.