My first recommendation is to rework your solution to get rid of the .jar file and use the built-in facilities of IS to interact with the Broker. I imagine you’re trying to leverage some library from way back when IS and Broker weren’t so integrated. Long term, I think you’ll be better off if you abandon that library. Of course, that’s just a preliminary opinion based on the info at hand.
You’re not going to be able to “retain” any session. You’ll need to create one (or more). Here’s a code snippet that used unpublished classes to do what you’re looking for:
// Place this code in a method in the library. It
// will not have an IS session/context established but needs
// one to invoke the desired service. This code mimics what
// the Scheduler does to establish a session when running a
// scheduled task.
IData input = IDataFactory.create();
IDataCursor idc = input.getCursor();
IDataUtil.put(idc, “foo”, “some parameter”);
IDataUtil.put(idc, “bar”, “another input to the service”);
idc.destroy();
// UserManager not documented; User is
User u = UserManager.getUser(“Administrator”); // May want to make the username configurable
// StateManager not documented; Session is
// The next line is the method signature
// public static Session StateManager.createContext(long timeout, String name, User sessionUser)
Session s = StateManager.createContext(0x7fffffffL, “system”, u);
s.setUser(u); // documented
s.clearModified(); // not documented
try
{
// Session.invoke not documented
s.invoke(u, NSName.create(“the.name.of.your:service”), Values.use(input));
// Undocumented class–shortcut to do what pub.flow:debugLog does
JournalLogger.log(JournalLogger.LOG_MSG, JournalLogger.FAC_DEBUG,
JournalLogger.DEBUG, “I did some work”);
}
catch(Exception e)
{
// You may want/need to do something else here
ServerAPI.logError(e);
e.printStackTrace(System.out);
}
finally
{
// StateManager not documented
StateManager.deleteContext(s.getSessionID());
}
#Flow-and-Java-services#webMethods#Integration-Server-and-ESB