lib/shapewear/wsdl.rb in shapewear-0.1.2 vs lib/shapewear/wsdl.rb in shapewear-0.1.4

- old
+ new

@@ -1,10 +1,10 @@ # encoding: UTF-8 require 'builder' -#noinspection RubyArgCount,RubyResolve +#noinspection RubyArgCount,RubyResolve,RubyLiteralArrayInspection module Shapewear::WSDL # reference: http://www.w3.org/TR/wsdl def to_wsdl xm = Builder::XmlMarkup.new @@ -15,11 +15,11 @@ 'xmlns:soap12' => namespaces['soap12'], 'xmlns:xsd' => namespaces['xsd'], 'xmlns:tns' => namespaces['tns'] do |xdef| xdef.types do |xtypes| - xtypes.schema 'xmlns' => namespaces['xsd'], :elementFormDefault => 'qualified', 'targetNamespace' => namespaces['tns'] do |xschema| + xtypes.schema 'xmlns' => namespaces['xsd'], :elementFormDefault => 'qualified', :targetNamespace => namespaces['tns'] do |xschema| # define elements for each defined method operations.each do |m, op_opts| build_type_elements_for_method(m, op_opts, xschema) end @@ -52,20 +52,20 @@ xbind.operation :name => op_opts[:public_name] do |xop| doc = op_opts[:documentation] rescue nil xop.documentation doc unless doc.nil? xop.tag! "soap#{sv}:operation", :soapAction => "#{namespaces['tns']}/#{op_opts[:public_name]}", :style => 'document' xop.input { |xin| xin.tag! "soap#{sv}:body", :use => 'literal' } - xop.output { |xin| xin.tag! "soap#{sv}:body", :use => 'literal' } + xop.output { |xout| xout.tag! "soap#{sv}:body", :use => 'literal' } end end end end # service definition for soap 1.1 and 1.2 - ['', '12'].each do |sv| - xdef.service :name => "#{options[:service_name]}#{sv}" do |xsrv| - xsrv.documentation "WSDL auto-generated by shapewear." + xdef.service :name => "#{options[:service_name]}" do |xsrv| + xsrv.documentation "WSDL auto-generated by shapewear." + ['', '12'].each do |sv| xsrv.port :name => "#{options[:service_name]}Soap#{sv}", :binding => "tns:#{options[:service_name]}Soap#{sv}" do |xport| xport.tag! "soap#{sv}:address", :location => options[:endpoint_url] end end end @@ -117,18 +117,17 @@ ret = op_options[:returns] rescue nil xschema.element :name => "#{op_options[:public_name]}Response" do |xreq| xreq.complexType do |xct| xct.sequence do |xseq| - if ret.nil? - xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => 'xsd:any' - elsif ret.is_a?(Class) - xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => to_xsd_type(ret) - elsif ret.is_a?(Hash) - xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, :type => "tns:#{op_options[:public_name]}Struct" - else - raise "Could not interpret #{ret.inspect} as a return type definition" - end + xseq.element :name => "#{op_options[:public_name]}Result", :minOccurs => 0, :maxOccurs => 1, + :type => case ret + when NilClass then 'xsd:any' + when Class then to_xsd_type(ret) + when Hash then "tns:#{op_options[:public_name]}Struct" + else + raise "Could not interpret #{ret.inspect} as a return type definition" + end end end end if ret.is_a?(Hash)