You need to do this way.
RemoteMethodServer rms = RemoteMethodServer.getDefault();
rms.setUserName("***");
rms.setPassword("***");
rms.invoke("yourMethodName", Yourclass.class.getName,null,argTypes,argValues);
// Put your logic inside your method
public yourMethodName() {
WTChangeOrder2 cho = (WTChangeOrder2)( new ReferenceFactory()).getReference("VR:wt.change2.WTChangeOrder2:16423065").getObject();
wt.fc.QueryResult qr = wt.change2.ChangeHelper2.service.getChangeablesBefore(cho);
wt.doc.WTDocument wtd = null;
wt.fc.QueryResult qr2 = new wt.fc.QueryResult();
while (qr.hasMoreElements())
{
wtd = (wt.doc.WTDocument)qr.nextElement();
State st=State.toState(String state);
LifeCycleHelper.service.setLifeCycleState(wtd,st);
}
}
Let me know if you need further detail