cancel
Showing results for 
Search instead for 
Did you mean: 

SP6 API CreateUserSessionCommand

Former Member
0 Kudos

Hi All,

Im using MDM 5.5 SP6 and the API for the same in a Portal component.

When trying to retrieve records, I was getting an error: The current Protocol operation is not supported for the session specified.

So I read that I could use CreateUserSessionCommand..

So, I tried:


ConnectionAccessor sc=null;
sc = SimpleConnectionFactory.getInstance(sHostName);
RegionProperties regionProperties = new RegionProperties(); 
regionProperties.setLocale(Locale.ENGLISH); regionProperties.setName("English [US]"); 
regionProperties.setRegionCode("engUSA"); 
CreateUserSessionCommand createUSesCmd = new CreateUserSessionCommand(sc);

But the last line doesnt allow me to move forwards because CreateUserSessionCommand doesnt accept ConnectionAccessor as a parameter

ANy help ?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

sc should be a SimpleConnection :

SimpleConnection sc = null;

Regards,

Pierre

Former Member
0 Kudos

It still doesnt work with CreateUserSessionCommand

The error i get on that line:

CreateUserSessionCommand createUSesCmd = new CreateUserSessionCommand(sc);

is

The constructor CreateUserSessionCommand(SimpleConnection) is undefined

Former Member
0 Kudos

Hi,

Weird, this code works just fine in my applications (MDM 7.1 API but should be the same for 5.5 SP6 according to the javadoc).

Are you sure you are working with MDM 5.5 SP6 API?

Regards,

Pierre

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

use import com.sap.mdm.net.SimpleConnection; while importing

and SimpleConnection Object in createUserSession Commands constructorwhile creating object.

I think it will solve ur problem.

Regards,

Vibha

Former Member
0 Kudos

Hi Prem,

There are two classes with name CreateUserSessionCommand.... in MDM Java API jars...

One is com.sap.mdm.commands.CreateUserSessionCommand,

And another is com.sap.mdm.internal.protocol.commands.meta.CreateUserSessionCommand...

The code which you have written, should work fine if you are using first one...

Make sure you have no import packages referring to any class in com.sap.mdm.internal package...

Regards,

- Shailesh.

Former Member
0 Kudos

Hello,

here is how I am using the SP6 API:


UserSessionContext userSessionCtx = new UserSessionContext(hostName, repositoryName, language, userName);
String userSession = SessionManager.getInstance().createSession(userSessionCtx, SessionTypes.USER_SESSION_TYPE, pwd);

// get the repository schema
GetRepositorySchemaCmd cmd = new GetRepositorySchemaCmd(userSessionCtx);
cmd.setSession(userSession);
cmd.execute();
RepositorySchema repoSchema = cmd.getRepositorySchema();

I realize it is not exactly what you are trying to do, but the above code works for me.

The command constructor takes the UserSessionContext object as its arg,

and you set the session to the user session var.

Hope this helps!

Bruce Berkowicz

Former Member
0 Kudos

Bruce,

I saw you post both this and a similar thread regarding connections to the repository. Like you, I am trying to connect to MDM from a web application (in this case, Liferay Portal running on Tomcat). I've had the same problems you have regarding best practices for making a connection. I'm currently using the same process you described above (create a UserSessionContext object then create the session), but I'm seeing connections pile up on the server. I'm thinking I have to implement a cache model on the connection object but it's not clear which one actually creates the connections.

Have you tried the MDM Connector object? That seems to be the preferred way to make a JCA Connection, but I can't find any good documentation on how to set it up in my environment. All of the SAP documentation points to using either SAP Portal or an environment with NWDI.

Any insight you might have on how to properly make a connection in a non-SAP Java web environment would be greatly appreciated!

Shawn

Former Member
0 Kudos

Hi Prem,

Try using "Connectionpool" from Connectionpoolfactory class.

Former Member
0 Kudos

I tried this.... didnt work

ConnectionPool sc=null;

sc = ConnectionPoolFactory.getInstance(sHostName);

//sc = SimpleConnectionFactory.getInstance(sHostName);

RegionProperties regionProperties = new RegionProperties();

regionProperties.setLocale(Locale.ENGLISH); regionProperties.setName("English [US]");

regionProperties.setRegionCode("engUSA");

CreateUserSessionCommand createUSesCmd = new CreateUserSessionCommand(sc);

nitin_mahajan2
Contributor
0 Kudos

Can you list your imports?

~Nitin