Message message = new Message();message.setMessage("Hello");message.setStatus(0); InsertObjectCommand insertObjectCommand = new InsertObjectCommand(message, "f1");
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand("myFireCommand");
List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();commands.add(insertObjectCommand);commands.add(fireAllRulesCommand);BatchExecutionCommand command = new BatchExecutionCommandImpl(commands);
String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML(command); // actual XML request
KieServicesConfiguration config = KieServicesFactory.newRestConfiguration("http://localhost:8080/kie-server/services/rest/server", "kieserver", "kieserver1!");KieServicesClient client = KieServicesFactory.newKieServicesClient(config);// the request "xStreamXml" we generated in previous step
// "ListenerReproducer" is the name of the Container ServiceResponse<String> response = client.executeCommands("HelloWorld", xStreamXml); System.out.println(response.getResult());
Exception in thread "main" org.kie.server.client.KieServicesException: Unexpected HTTP response code when requesting URI 'http://localhost:8080/kie-server/services/rest/server/containers/HelloWorld'! Error code: 405, message: at org.kie.server.client.impl.AbstractKieServicesClientImpl.createExceptionForUnexpectedResponseCode(AbstractKieServicesClientImpl.java:467) at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(AbstractKieServicesClientImpl.java:187) at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(AbstractKieServicesClientImpl.java:173) at org.kie.server.client.impl.KieServicesClientImpl.executeCommands(KieServicesClientImpl.java:227) at com.att.research.drools.eventConsumer.EventSubscriber.main(EventSubscriber.java:137)