On 27 July 2011 23:27, lhorton <span dir="ltr">&lt;<a href="mailto:LHorton@abclegal.com">LHorton@abclegal.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
We are at 5.2.0 Final<br>
<br>The rule must now capture the<br>
return from the call to the remote service, in order to see the changes made by the remote service call.<br>
<br>
Within the rule, this change is working fine.  The RHS was:<br>
<br>
      applicationService.applyInstruction($step);<br>
<br>
as above, the $step fact would not be updated within the rule WM now that<br>
the service is called remotely.  However, when I changed this to<br>
<br>
      $step = applicationService.applyInstruction($step);<br></blockquote><div><br>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.)<br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
then $step did have the changes(I am verifying this by writing debug info to<br>
the log).  BUT, the object that was passed in to execute() on the knowledge<br>
session did NOT have the changes.  I have tried several things to fix this.<br>
one was to update($step) but this failed with &quot;Update error: handle not<br>
found for object,&quot;</blockquote><div><br>The result of the RMI is an entirely new object, which you can&#39;t update.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
 I assume because the fact handle changed in the object<br>
returned from the service call.<br>
<br>
I also tried some variations on retracting and inserting the step:<br>
<br>
        retract($step);<br>
        $step = applicationService.applyInstruction($step);<br>
        insert($step);<br>
<br></blockquote><div><br>The out-identifier of the &quot;insert&quot; command is bound to the fact handle resulting from the original insert, so you can&#39;t get another object via this identifier.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

and also tried using a different variable name:<br>
<br>
        retract($step);<br>
        $step2 = applicationService.applyInstruction($step);<br>
        insert($step2);<br>
        update($step2);<br>
<br>
both these above did not get errors, but also did not cause the updated<br>
object to return from session.execute() call.<br></blockquote><div><br>Same thing.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
To summarize:<br>
in a call to execute() on a stateless knowledge session, an object is passed<br>
in<br>
a rule fires that calls a remote service that modifies the object<br>
within the rule, we catch the changed object that is returned from the<br>
service call<br>
within the rule, the changes to the object ARE visible<br>
on the return from execute(), the changes are NOT visible<br>
<br></blockquote><div><br>You have several options.<br><br>1. Insert a second object Box { Step step;... } with an out-identifier and do <br>       retract($step);<br>
        $step = applicationService.applyInstruction($step);<br>       insert($step);<br>       modify( $box ){ setStep( $step ) }<br>With multiple Step objects being around, you&#39;ll have to use as many Boxes and associate them with the original Step object as a second field.<br>
<br>2. Store the new $step into a global Box and use the getGlobal command.<br><br>3. Use the getObjects command, possibly with a filter to get only Step objects.<br><br>-W<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

thanks for your help...<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3204887.html" target="_blank">http://drools.46999.n3.nabble.com/how-to-update-object-modified-by-call-to-remote-web-service-tp3204887p3204887.html</a><br>

Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote></div><br>