Skip to main content
1-Visitor
November 6, 2018
Question

Java api CmdRunner execute si about example always returns result null

  • November 6, 2018
  • 1 reply
  • 3923 views

Hello all,

I'm trying to work with the java api and I use the examples found on PTC_IntegrationsBuilderGuide_Integrity_11_2.pdf

 

IntegrationPointFactory integrationPointFactory = IntegrationPointFactory.getInstance();
try {
    IntegrationPoint integrationPoint = integrationPointFactory.createIntegrationPoint(hostName, port, APIVersion.API_4_16);
   
    Session session = integrationPoint.createNamedSession(null, null, userName, password);
   
    CmdRunner cmdRunner = session.createCmdRunner();
   
    Command cmd = new Command(Command.SI, "about");
   
    Response response = cmdRunner.execute(cmd);
   
    ...

 

what is wrong in my test code ? Is the session correctly created ?

 

 

 

1 reply

21-Topaz I
November 6, 2018

It is difficult to know without seeing the error message returned but there is another sample code block in knowledgebase article CS159760 which you could try.

efc41-VisitorAuthor
1-Visitor
November 7, 2018
Many thanks, this example works fine. I have just a problem with giving the username and password to create the session. The tool I'm writing should work without specifying username/password. Is it possible to take username/password specified in the client preferences ? Like using im/si commands in the shell ?
21-Topaz I
November 7, 2018

There are some server-side properties which allow you to define a default API user and password. Found in the <IntegrityServer>\config\properties\is.properties file:

 

mksis.apiSession.defaultUser=MyUser
mksis.apiSession.defaultPassword=MyPassword

 

Setting the above values will allow API connections to be made without explicitly defining user credentials in your code. This must be a valid user within Integrity and have the appropriate permissions for the operations you will be doing with your code. Note that making changes to the is.properties file requires an Integrity Server service restart before they are recognized.