On 27 July 2011 23:27, lhorton <LHorton@abclegal.com> wrote:
We are at 5.2.0 Final

The rule must now capture the
return from the call to the remote service, in order to see the changes made by the remote service call.

Within the rule, this change is working fine.  The RHS was:

     applicationService.applyInstruction($step);

as above, the $step fact would not be updated within the rule WM now that
the service is called remotely.  However, when I changed this to

     $step = applicationService.applyInstruction($step);

This just changes a local (binding) variable; it does not change the object the reference of which is availabe via the variable. (As in Java.)
 

then $step did have the changes(I am verifying this by writing debug info to
the log).  BUT, the object that was passed in to execute() on the knowledge
session did NOT have the changes.  I have tried several things to fix this.
one was to update($step) but this failed with "Update error: handle not
found for object,"

The result of the RMI is an entirely new object, which you can't update.

 
I assume because the fact handle changed in the object
returned from the service call.

I also tried some variations on retracting and inserting the step:

       retract($step);
       $step = applicationService.applyInstruction($step);
       insert($step);


The out-identifier of the "insert" command is bound to the fact handle resulting from the original insert, so you can't get another object via this identifier.
 
and also tried using a different variable name:

       retract($step);
       $step2 = applicationService.applyInstruction($step);
       insert($step2);
       update($step2);

both these above did not get errors, but also did not cause the updated
object to return from session.execute() call.

Same thing.
 

To summarize:
in a call to execute() on a stateless knowledge session, an object is passed
in
a rule fires that calls a remote service that modifies the object
within the rule, we catch the changed object that is returned from the
service call
within the rule, the changes to the object ARE visible
on the return from execute(), the changes are NOT visible


You have several options.

1. Insert a second object Box { Step step;... } with an out-identifier and do
       retract($step);
       $step = applicationService.applyInstruction($step);
       insert($step);
       modify( $box ){ setStep( $step ) }
With multiple Step objects being around, you'll have to use as many Boxes and associate them with the original Step object as a second field.

2. Store the new $step into a global Box and use the getGlobal command.

3. Use the getObjects command, possibly with a filter to get only Step objects.

-W

 
thanks for your help...


--
View this message in context: http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3204887.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users