class WsdlFactory
attr_accessor :namespace_uri, :service_methods, :choice_elements
def initialize(new_options = {})
options = {
:namespace_uri => "http://some.example.com",
:service_methods => {"findById" => ["id"]},
:choice_elements => {}
}.update(new_options)
@namespace_uri = options[:namespace_uri]
@service_methods = options[:service_methods]
@choice_elements = options[:choice_elements]
end
def build
wsdl = '
'
wsdl << build_elements
wsdl << ''
wsdl << build_complex_types
wsdl << '
'
wsdl << build_messages
wsdl << ''
wsdl << build_operation_input_output
wsdl << '
'
wsdl << build_operation_input_output_body
wsdl << '
'
end
def build_elements
wsdl = service_methods.keys.map { |method|
'
'
}.to_s
wsdl << choice_elements.map { |c_method, c_elements|
c_elements.map { |c_element|
''
}.to_s
}.to_s
wsdl
end
def build_complex_types
service_methods.map { |method, inputs|
wsdl = ''
inputs.each do |input|
if choice_elements.keys.include? input
wsdl << ''
wsdl << choice_elements[input].map { |element|
''
}.to_s
wsdl << ''
else
wsdl << ''
end
end
wsdl << ''
wsdl << build_complex_types_choice_elements
wsdl << '
'
}.to_s
end
def build_complex_types_choice_elements
choice_elements.map { |c_method, c_elements|
c_elements.map { |c_element|
'
'
}.to_s
}.to_s
end
def build_messages
service_methods.keys.map { |method|
'
'
}.to_s
end
def build_operation_input_output
service_methods.keys.map { |method|
'
'
}.to_s
end
def build_operation_input_output_body
service_methods.keys.map { |method|
'
'
}.to_s
end
end