kContext.set("ksession", ksession);
commandService = new DefaultCommandService(kContext);
QueryCommand queryCommand = new QueryCommand("out", "myQuery", new Object[]{});
SetVariableCommandFromCommand setVariableCmd = new SetVariableCommandFromCommand("__TEMP__", "query123", queryCommand);
KnowledgeContextResolveFromContextCommand resolveFromContextCommand = new KnowledgeContextResolveFromContextCommand(setVariableCmd,
null, null, "ksession", "localResults");
ExecutionResults results = (ExecutionResults) commandService.execute(resolveFromContextCommand);