Unable to access Execution Server using kie.server.client API

857 views
Skip to first unread message

krina patel

unread,
Mar 3, 2016, 6:31:13 PM3/3/16
to Drools Usage
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.
               "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());



Using the kie-server-client APIs in the above code, I am trying to insert facts into the kie-server. However, I am end-up getting the following Exception. Can you please kindly guide me what's wrong here and how can I fix it?



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)



Many thanks,
KPatel

Bill S

unread,
Mar 4, 2016, 11:27:00 AM3/4/16
to Drools Usage
Karina,

I believe you and I are in a similar boat.  I have made it past this part a little while ago, but I am still struggling to get rule results back from the server.

Take a look at this example, and let me know if that helps you.  

Bill
Reply all
Reply to author
Forward
0 new messages