Class OpenWFE::SoapParticipant
In: lib/openwfe/participants/soapparticipants.rb
Parent: Object

Wrapping a simple web service call within an OpenWFEru participant.

    quote_service = OpenWFE::SoapParticipant.new(
        "http://services.xmethods.net/soap",        # service URI
        "urn:xmethods-delayed-quotes",              # namespace
        "getQuote",                                 # operation name
        [ "symbol" ])                               # param arrays (workitem fields)

    engine.register_participant("quote_service", quote_service)

By default, call params for the SOAP operations are determined by iterating the parameters and fetching the values under the corresponding workitem fields. This behaviour can be changed by overriding the prepare_call_params() method.

On the return side, you can override the method handle_call_result for better mappings between web service calls and the workitems.

Methods

Included Modules

LocalParticipant

Public Class methods

[Source]

    # File lib/openwfe/participants/soapparticipants.rb, line 70
70:         def initialize \
71:             (endpoint_url, namespace, method_name, params, param_prefix="")
72: 
73:             super()
74: 
75:             @driver = SOAP::RPC::Driver.new(endpoint_url, namespace)
76: 
77:             @method_name = method_name
78:             @params = params
79:             @param_prefix = param_prefix
80: 
81:             @driver.add_method(method_name, *params)
82:         end

Public Instance methods

The method called by the engine when the flow reaches an instance of this Participant class.

[Source]

    # File lib/openwfe/participants/soapparticipants.rb, line 88
88:         def consume (workitem)
89: 
90:             call_params = prepare_call_params(workitem)
91: 
92:             call_result = @driver.send(@method_name, *call_params)
93: 
94:             handle_call_result(call_result, workitem)
95: 
96:             reply_to_engine(workitem)
97:         end

This implementation simply stuffs the result into the workitem as an attribute named "result".

Feel free to override this method.

[Source]

     # File lib/openwfe/participants/soapparticipants.rb, line 118
118:         def handle_call_result (result, workitem)
119: 
120:             workitem.attributes["__result__"] = result
121:         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.

[Source]

     # File lib/openwfe/participants/soapparticipants.rb, line 105
105:         def prepare_call_params (workitem)
106: 
107:             @params.collect do |param|
108:                 get_param workitem, param
109:             end
110:         end

Protected Instance methods

[Source]

     # File lib/openwfe/participants/soapparticipants.rb, line 125
125:             def get_param (workitem, param_name)
126: 
127:                 param_name = @param_prefix + param_name if @param_prefix
128: 
129:                 workitem.attributes[param_name] || ""
130:             end

[Validate]