on 02-17-2011 2:37 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you very kindly Kanstantsin!
I have just tried that, yet end up with the same System.ArgumentException. It seems to be related to the region info in the MDM server or the region related APIs or misalignment between the two. Here is my revised code and stack trace.
Revise Code:
string serverName = "asd00fe";
string repName = "HMK_Material_001";
string dbms = "SD01";
string repUser = "Admin";
string repPswd = "sapmdm";
string regName = "English US";
RepositorySessionContext repCtx = new RepositorySessionContext(serverName, repName, repUser);
SimpleConnection conn = SimpleConnectionFactory.getInstance(serverName);
cmd.RepositoryIdentifier = new RepositoryIdentifier(repName, dbms, DBMSType.DB2_ZOS);
cmd.execute();
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
RefExMdmApp.MdmConnector.getServerData() in C:\Users\kknapp\Documents\Visual Studio 2010
\Projects\RefExSolution\Main\RefExSolution\RefExMdmApp\MdmConnector.cs:line 59 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
Hello Kevin Knapp
SAP MDM server shoul be started and repository running.
and Language variable should be the same as in repository.
Please, check that too.
in API we have three types of sessions
from manual:
ServerSessionContext sessionContext = new ServerSessionContext(serverName)
RepositorySessionContext sessionContext = new RepositorySessionContext(serverName, repositoryName, userName)
UserSessionContext sessionContext = new UserSessionContext(serverName, repositoryName, regionName,
userName)
If you want to create new repository i dont thin so you select right session.
Regards
Kanstantsin Chernichenka
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");
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");
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.