Issues while POST

45 views
Skip to first unread message

sreekanda...@gmail.com

unread,
Aug 2, 2016, 2:21:51 PM8/2/16
to Drools Usage
Hi Team,

I have created a rule engine with KIE Work Bench and KIE server as the deployment interface. I was able to publish the rule in the server.
When i try to POST data to the rule i'm getting the following exception


org.kie.server.client.KieServicesException: Unexpected HTTP response code when requesting URI 'http://localhost:8080/kie-server/services/rest/server/containers/Myrules'! Error code: 405, message: Method Not Allowed
at org.kie.server.client.impl.KieServicesClientImpl.createExceptionForUnexpectedResponseCode(KieServicesClientImpl.java:416)
at org.kie.server.client.impl.KieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(KieServicesClientImpl.java:213)
at org.kie.server.client.impl.KieServicesClientImpl.executeCommands(KieServicesClientImpl.java:133)
at com.ust.digital.common.util.TestUtlity.main(TestUtlity.java:89)


Here is the code for calling the RestService


CategoryObj cat = new CategoryObj();
Map count = new HashMap<>();
Map sorted = new HashMap<>();
sorted.put("A", "NEGATIVE");
sorted.put("A", "NEGATIVE");
sorted.put("B", "NEGATIVE");
sorted.put("B", "POSITIVE");
sorted.put("B", "POSITIVE");
count.put("A", 2);
count.put("B", 3);
cat.setCountMap(count);
cat.setSortedMap(sorted);
InsertObjectCommand insertObjectCommand = new InsertObjectCommand(cat, "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);
       
       
       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("Myrules", xStreamXml); 
       System.out.println(response.getResult());



Please let me know the you need any further information.

Thanks
Sree


Maciej Swiderski

unread,
Aug 3, 2016, 2:17:01 AM8/3/16
to Drools Usage
don't marshall commands yourself using String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML(command) just pass the commands to the execute method of RuleServicesClient and it will do the marshalling for you.

Maciej

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/e9b2695c-ef0f-4964-b402-59c7c5729e7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages