cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Authentication fails while accessing Windchill API from client m/c

Highlighted
Level 1

Authentication fails while accessing Windchill API from client m/c

I am trying toaccess Windchill API's from a client sidejava program. For this I have written two classes:

1. TestServer.java : This class implements RemoteAccess and it includes a method getDocument(), which queries Windchill Database and prints the retrieved document details. This class is deployed on Windchill server(wt_home\codebase).

2. TestClient.java : This is a simple java class that uses Java RMI api's to access Windchill MethodServer remote object. Then using this remote object, I am trying to invoke remote method getDocument() from TestServer.java. This class is deployed outside Windchill server on another m/c. For accessing Methodserver remote object, I am using following code:

System.setSecurityManager(new RMISecurityManager());
try
{
String url;
url = "rmi://172.28.35.84:5001/ServerManager";
String names[] = Naming.list(url);
ServerManager remoteObject;
remoteObject = (ServerManager) Naming.lookup(url);
System.out.println("Got remote object");
Vector servers = remoteObject.getAllServers("MethodServer");
MethodServer rms = (MethodServer) servers.get(0);
System.out.println("methodserver info: " + rms.getInfo());
Class aclass[] = {String.class};
Object aobject[] = {"0000000124"};
MethodArgs margs = new MethodArgs();
margs.argObjects = aobject;
margs.argTypes = aclass;
margs.targetClass = "ext.server.TestServer";
margs.targetMethod = "getDocument";
margs.targetObject = null;
margs.authentication = new String("wcadmin");
rms.invoke(margs);
System.out.println("methodserver : method executed successfully..");
} catch (Exception exc)
{
System.out.println("Error: " + exc.toString());
}

I am able to invoke getDocument() on Windchill server but it fails to execute any Windchill API's. I think this might be happening because of authentication is not done properly.

2 REPLIES 2

Authentication fails while accessing Windchill API from client m/c

Why don't you use Windchill API to connect to the method server ??

Interactive java login :
SessionHelper.getPrincipal()

For automatic login:

RemoteMethodServer methodServer = RemoteMethodServer.getDefault(); / getInstance(String instance);
methodServer.setUserName(user);
methodServer.setPassword(password);

You will need to add your wt.jar file in the client classpath !!

Yogesh Wadile a écrit :
>
> I am trying to access Windchill API's from a client side java program.
> For this I have written two classes:
>
> 1. TestServer.java : This class implements RemoteAccess and it
> includes a method getDocument(), which queries Windchill Database and
> prints the retrieved document details. This class is deployed on
> Windchill server (wt_home\codebase).
>
> 2. TestClient.java : This is a simple java class that uses Java RMI
> api's to access Windchill MethodServer remote object. Then using this
> remote object, I am trying to invoke remote method getDocument() from
> TestServer.java. This class is deployed outside Windchill server on
> another m/c. For accessing Methodserver remote object, I am using
> following code:
>
> System.setSecurityManager(new RMISecurityManager());
> try
>         {
>             String url;
>             url = "rmi://172.28.35.84:5001/ServerManager";
>             String names[] = Naming.list(url);
>             ServerManager remoteObject;
>             remoteObject = (ServerManager) Naming.lookup(url);
>             System.out.println("Got remote object");
>             Vector servers = remoteObject.getAllServers("MethodServer");
>             MethodServer rms = (MethodServer) servers.get(0);
>             System.out.println("methodserver info: " + rms.getInfo());
>             Class aclass[] = {String.class};
>             Object aobject[] = {"0000000124"};
>             MethodArgs margs = new MethodArgs();
>             margs.argObjects = aobject;
>             margs.argTypes = aclass;
>             margs.targetClass = "ext.server.TestServer";
>             margs.targetMethod = "getDocument";
>             margs.targetObject = null;
>             margs.authentication = new String("wcadmin");
>             rms.invoke(margs);
>             System.out.println("methodserver : method executed
> successfully..");
>         } catch (Exception exc)
>         {
>             System.out.println("Error: " + exc.toString());
>         }
>
> I am able to invoke getDocument() on Windchill server but it fails to
> execute any Windchill API's. I think this might be happening because
> of authentication is not done properly.
>
>
>
> ----------

RE: Authentication fails while accessing Windchill API from client m/c

Hi Julien,

Thanks a lot for the information :-)

Actually i tried this previously, but that time wt.jar was not in the classpath. So it didn't worked.

Now I copied wt.jar on client m/c and added to its classpath and its working fine..

Thanks a lot again..