Windchill Remote Method Server Access API

To invoke Windchill server side code from outside method server, we need to use RMI calls. Windchill provides mechanism to do this by using RemoteMethodServer class.

The method signature
RemoteMethodServer.getDefault().invoke(String methodName, String className, Object obj, Class[] paramClassTypeArray, Objet[] paramValuesArray);

The core code to invoke remote method is
RemoteMethodServer remotemethodserver = RemoteMethodServer.getDefault();

Class argTypes[] = {String.class, String.class};//add all remote method parameter data types
Object argValues[] = {"param_1_value", "param_2_value"};//respective data value

Object returnObj = remotemethodserver.invoke(methodName, className, null, argTypes, argValues);

If you want the user who is executing the code should provide username and password explicitly using basic authentication handled by framework, skip the username and password set to RemoteMethodServer and user SessionHelper.manager.getPrincipal(); Adding this will give popup for username and password if not available.
Keep in mind that there may be an issue if you are executing the remote access code from some external terminal like putty session. The popup will not work by default and need some additional settings.

In the next post we will see a command line utility skeleton which uses RemoteMethodServer API.


Surya Prakash said...

Hey Mahesh,

This is surya..I hope you do remember me. Great Job... Really very helpful to analyaze and revise concepts of windchill. Please do keeping sharing..

Mahesh Mhetre said...

Thanks Surya.
How can I forget you guys. That was the team who leads me to do the blogging :)
And now your comments keep me motivated to continue ...

ashish said...

Hi Mahesh
Ours is a flexPLM system.
I'm trying to build a java program to load LCSProduct data from data files similar to how the OOTB loader works, the intention here is to feed the java program into a cron job and schedule the whole process for periodic loading.

However I'm stuck in the process of invoking the FlexType.
We have a clustered environment, with one master and one slave.
I'm executing this program in the Master Server.
Please find the details of the issue below:

Issue : Unable to invoke Remote Method Server, as a result the program cannot invoke the FlexType.

Program Details :

I have tried the standard Remote Method Server Invocation process which involves the following code :

RemoteMethodServer remotemethodserver = RemoteMethodServer.getDefault();
String lv_username = new String();
String lv_password = new String();
lv_username = "wcadmin";
lv_password = "wcadmin";
String type = "Product\\GE Lighting\\Product";
FlexType flextype = FlexTypeCache.getFlexTypeFromPath(type);
Error :

FTCMessenger Initialized
Introspection Runtime Mode = true
My Exception (wt.fc.fcResource/0) wt.util.WTException: The operation: "getPrincipal" failed.
Nested exception is: wt.util.WTRemoteException: Unable to invoke remote method; nested exception is:
I have also tried to use the api to invoke remote method, it failed producing the same error
code :
public class TestLoader{
MethodServerMBean msm;
public static void main (String [] args) throws RemoteException, InvocationTargetException{ // TODO Auto-generated method stub RemoteMethod ("Invoke Remote Method Server");
public static void RemoteMethod(String msg) throws RemoteException, InvocationTargetException{
//String serurl = msm.getJmxServiceURL();
try {
String servname = "";
String CLASSNAME = (;
Class argTypes [];
Object svrArgs [];
argTypes = (new Class[] {String.class});
svrArgs = (new Object []{msg});
RemoteMethodServer rms;
rms = RemoteMethodServer.getInstance(new URL(""));
rms = RemoteMethodServer.getDefault();
wt.method.MethodContext mc = new wt.method.MethodContext("Extraction", rms);
rms.getDefault().invoke("pirntMsg", CLASSNAME, null, argTypes, svrArgs);
}catch(Exception e)
System.out.println("Exception 123 "+e); System.exit(0);
public static void pirntMsg (String msg) { System.out.println (msg);

Anonymous said...


first of all thank you for sharing your Windchill tips.

I would like to ask one question:

Your example shows how to invoke a method on the remote method server.
In your case, no data are returned back to the client.

Is it possible to invoke a remote method and get back some Windchill data?

I tried to search and return back some EPMDocument instances, but the client is not able to deserialize (unmarshall) the objects from the ObjectOutputStream.

Would you have any advice for this scenario?

Thank you in advance


Yogesh said...

Using same code,my method is called twice.Please tell me the reason why this remote method executes twice

Mahesh Mhetre said...

Hi Michal,
Yes I observed the same. In my understanding this is happening due to two different JVMs. The remote call is invoked by your local JVM to the Windchill JVM. Your local JVM is unaware of Windchill object definitions and so failing to deserialize return object.

Mahesh Mhetre said...

Hi Yogesh,
Please check my post below for command line utility skeleton which is using the remote method call.

The method calls twice if the code in the method needs user authentication and re-execute after authentication. This can be avoided by using SessionHelper.manager.getPrincipal();
at the beginning of the method.

Anonymous said...

The code I use to keep from putting the passwd in the code is:

import wt.httpgw.GatewayAuthenticator;
import wt.method.RemoteMethodServer;
import java.rmi.RemoteException;

public class XXX {

public static void main(String[] args) {
RemoteMethodServer rms = RemoteMethodServer.getDefault();
GatewayAuthenticator auth = new GatewayAuthenticator();

Unknown said...

Hi Mahesh

I am trying to build a Remote Client for Windchill.

My code is working fine if i include complete codebase directory in eclipse project.
However exporting the project as a runnnable jar its not working.

Can you suggest the jars need to be included.