lib/openwfe/participants/soapparticipants.rb in openwferu-0.9.5 vs lib/openwfe/participants/soapparticipants.rb in openwferu-0.9.6

- old
+ new

@@ -55,12 +55,12 @@ # "getQuote", # operation name # [ "symbol" ]) # param arrays (workitem fields) # # engine.register_participant("quote_service", quote_service) # - # TODO #8425 : use blocks as hooks for the mapping (pre/post) - # of workitems into webservice operation params. + # You can override the method handle_call_result for better mappings + # between web service calls and the workitems. # class SoapParticipant include LocalParticipant def initialize \ @@ -77,20 +77,40 @@ @driver.add_method(method_name, *params) end def consume (workitem) - call_params = [] + call_params = prepare_call_params(workitem) - @params.each do |param| - call_params << get_param(workitem, param) + call_result = @driver.send(@method_name, *call_params) + + handle_call_result(call_result, workitem) + + reply_to_engine(workitem) + end + + # + # The base implementation : assumes that for each webservice operation + # param there is a workitem field with the same name. + # + # Feel free to override this method. + # + def prepare_call_params (workitem) + + @params.collect do |param| + get_param(workitem, param) end + end - result = @driver.send(@method_name, *call_params) + # + # This implementation simply stuffs the result into the workitem + # as an attribute named "__result__". + # + # Feel free to override this method. + # + def handle_call_result (result, workitem) workitem.attributes["__result__"] = result - - reply_to_engine(workitem) end protected def get_param (workitem, param_name)