Example 22.16
andExample 22.17
from the 6.3.0 documentation. The program seems to run fine except that I am always getting an empty result set back. What am I doing wrong?<batch-execution><insert><org.mortgages.LoanApplication><amount>140000</amount><deposit>10000</deposit><lengthYears>30</lengthYears></org.mortgages.LoanApplication></insert><insert><org.mortgages.IncomeSource><amount>100</amount><type>Asset</type></org.mortgages.IncomeSource></insert><fire-all-rules/></batch-execution>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><execution-results><results/><facts/></execution-results>
package org.jboss.docs;import java.util.ArrayList;import java.util.List;import org.drools.core.command.impl.GenericCommand;import org.drools.core.command.runtime.BatchExecutionCommandImpl;import org.drools.core.command.runtime.rule.FireAllRulesCommand;import org.drools.core.command.runtime.rule.InsertObjectCommand;import org.kie.api.command.BatchExecutionCommand;import org.kie.internal.runtime.helper.BatchExecutionHelper;import org.kie.server.api.model.ServiceResponse;import org.kie.server.client.KieServicesClient;import org.kie.server.client.KieServicesConfiguration;import org.kie.server.client.KieServicesFactory;import org.mortgages.IncomeSource;import org.mortgages.LoanApplication;public class DecisionClient {public static void main(String args[]) {LoanApplication app = new LoanApplication();app.setAmount(1);IncomeSource source = new IncomeSource();source.setType("Asset");source.setAmount(100);InsertObjectCommand insertApp = new InsertObjectCommand(app);InsertObjectCommand insertSource = new InsertObjectCommand(source);FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();commands.add(insertApp);commands.add(insertSource);commands.add(fireAllRulesCommand);BatchExecutionCommand command = new BatchExecutionCommandImpl(commands);String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML(command); // actual XML requestSystem.out.println(xStreamXml);//user "anton" must have role "kie-server" assignedKieServicesConfiguration config = KieServicesFactory.newRestConfiguration("http://10.33.65.82:32823/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 ContainerServiceResponse<String> response = client.executeCommands("instances/mortgages", xStreamXml);System.out.println(response.getResult());}}
--
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/a300c1c9-988c-4004-95a1-35947bb2b732%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
22:20:44,558 ERROR [org.kie.server.services.impl.KieContainerCommandServiceImpl] (default task-15) Error calling container 'loan1': org.kie.server.api.marshalling.MarshallingException: Can't marshall input object: org.drools.core.runtime.impl.ExecutionResultImpl@2fc581abat org.kie.server.api.marshalling.jaxb.JaxbMarshaller.marshall(JaxbMarshaller.java:187) [kie-server-api-6.3.0.Final.jar:6.3.0.Final]at org.kie.server.services.impl.KieContainerCommandServiceImpl.callContainer(KieContainerCommandServiceImpl.java:114) [kie-server-services-common-6.3.0.Final.jar:6.3.0.Final]
public static final String svrUrlLcl = "http://192.168.99.100:32775/kie-server/services/rest/server"; public static final String MINILOAN = "loan1/";
public static void main(String args[]) { MiniLoanTest(svrUrlLcl, MINILOAN); }
public static void MiniLoanTest(String svrUrl, String container) {
Borrower borrower = new Borrower(); borrower.setName("John Doe"); borrower.setCreditScore(230); borrower.setYearlyIncome(80000); Loan loan = new Loan(); loan.setAmount(3500); loan.setDuration(20); loan.setInterestRage(0.5); InsertObjectCommand iocB = new InsertObjectCommand(borrower, "borrower"); InsertObjectCommand iocL = new InsertObjectCommand(loan, "MiniLoan"); FireAllRulesCommand farc = new FireAllRulesCommand();
List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>(); commands.add(iocB); commands.add(iocL); commands.add(farc); BatchExecutionCommand command = new BatchExecutionCommandImpl(commands);
String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML( command); // actual XML request System.out.println("------------------------------"); System.out.println(xStreamXml);
KieServicesConfiguration config = KieServicesFactory .newRestConfiguration(svrUrl, "kieserver", "kieserver1!"); KieServicesClient client = KieServicesFactory .newKieServicesClient(config);
ServiceResponse<String> response = client.getServicesClient( RuleServicesClient.class) .executeCommands(container, xStreamXml); System.out.println("------------------------------"); System.out.println(response.getResult()); }
String xStreamXml = BatchExecutionHelper.newXStreamMarshaller().toXML( command); // actual XML request System.out.println("------------------------------"); System.out.println(xStreamXml);To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/d631a967-98a0-48cc-9320-5e65f47c47a6%40googlegroups.com.
Borrower borrower = new Borrower("John Doe", 530, 80000); Loan loan = new Loan(3500, 20, 0.5);
InsertObjectCommand iocB = new InsertObjectCommand(); iocB.setObject(borrower); iocB.setOutIdentifier("borrower"); iocB.setReturnObject(true);
InsertObjectCommand iocL = new InsertObjectCommand(); iocL.setObject(loan); iocB.setOutIdentifier("loan"); iocL.setReturnObject(true);
...
ServiceResponse<String> response = ruleClient.executeCommands( containerId, executionCommand);
Exception in thread "main" org.kie.server.client.KieServicesException: Error while serializing request data! at org.kie.server.client.impl.AbstractKieServicesClientImpl.serialize(AbstractKieServicesClientImpl.java:430) at org.kie.server.client.impl.AbstractKieServicesClientImpl.makeHttpPostRequestAndCreateServiceResponse(AbstractKieServicesClientImpl.java:169) at org.kie.server.client.impl.RuleServicesClientImpl.executeCommands(RuleServicesClientImpl.java:52)
RuleServicesClient ruleClient = kieServicesClient .getServicesClient(RuleServicesClient.class); ServiceResponse<String> response = ruleClient.executeCommands( containerId, executionCommand);
System.out.println("------------------------------"); System.out.println(response.getResult());
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><execution-results> <results> <item key="person"> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">john</value> </item> <item key="loan"> <value xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">borrower</value> </item> </results> <facts> <item key="person"> <value xsi:type="defaultFactHandle" external-form="0:94:1078503604:3267851:94:DEFAULT:NON_TRAIT:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> </item> <item key="loan"> <value xsi:type="defaultFactHandle" external-form="0:95:1648091748:2097810786:95:DEFAULT:NON_TRAIT:java.lang.String" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/> </item> </facts></execution-results>