lib/shapewear/wsdl.rb in shapewear-0.0.3 vs lib/shapewear/wsdl.rb in shapewear-0.0.4

- old
+ new

@@ -1,5 +1,7 @@ +# encoding: UTF-8 + require 'builder' #noinspection RubyArgCount,RubyResolve module Shapewear::WSDL # reference: http://www.w3.org/TR/wsdl @@ -8,50 +10,51 @@ xm.instruct! xm.definitions :name => self.name, 'targetNamespace' => namespaces['tns'], 'xmlns' => namespaces['wsdl'], 'xmlns:soap' => namespaces['soap'], + 'xmlns:xsd' => namespaces['xsd'], 'xmlns:xsd1' => namespaces['xsd1'], 'xmlns:tns' => namespaces['tns'] do |xdef| xdef.types do |xtypes| xtypes.schema 'xmlns' => namespaces['xsd'], 'targetNamespace' => namespaces['xsd1'] do |xschema| # define elements for each defined method - instance_methods(false).each do |m| - build_type_elements_for_method(m, xschema) + operations.each do |m, op_opts| + build_type_elements_for_method(m, op_opts, xschema) end end end - instance_methods(false).each do |m| - xdef.message :name => "#{m.camelize}Input" do |xmsg| - xmsg.part :name => :body, :element => "xsd1:#{m.camelize}Request" + operations.each do |m, op_opts| + xdef.message :name => "#{op_opts[:public_name]}Input" do |xmsg| + xmsg.part :name => :body, :element => "xsd1:#{op_opts[:public_name]}Request" end unless instance_method(m).arity == 0 - xdef.message :name => "#{m.camelize}Output" do |xmsg| - xmsg.part :name => :body, :element => "xsd1:#{m.camelize}Response" + xdef.message :name => "#{op_opts[:public_name]}Output" do |xmsg| + xmsg.part :name => :body, :element => "xsd1:#{op_opts[:public_name]}Response" end end xdef.portType :name => "#{self.name}PortType" do |xpt| - instance_methods(false).each do |m| - xpt.operation :name => m.camelize do |xop| - xop.input :message => "tns:#{m.camelize}Input" unless instance_method(m).arity == 0 - xop.output :message => "tns:#{m.camelize}Output" + operations.each do |m, op_opts| + xpt.operation :name => op_opts[:public_name] do |xop| + xop.input :message => "tns:#{op_opts[:public_name]}Input" unless instance_method(m).arity == 0 + xop.output :message => "tns:#{op_opts[:public_name]}Output" end end end xdef.binding :name => "#{self.name}Binding", :type => "tns:#{self.name}PortType" do |xbind| - xbind.tag! 'soap:binding', :style => 'document', :transport => 'http://schemas.xmlsoap.org/soap/http' + xbind.tag! 'soap:binding', :style => 'rpc', :transport => 'http://schemas.xmlsoap.org/soap/http' operations.each do |op, op_opts| xbind.operation :name => op_opts[:public_name] do |xop| doc = op_opts[:documentation] rescue nil xop.documentation doc unless doc.nil? xop.tag! 'soap:operation', :soapAction => "#{namespaces['tns']}/#{op_opts[:public_name]}" - xop.input { |xin| xin.tag! 'soap:body', :use => 'literal' } unless instance_method(op).arity == 0 - xop.output { |xin| xin.tag! 'soap:body', :use => 'literal' } + xop.input { |xin| xin.tag! 'soap:body', :use => 'literal', :namespace => namespaces['tns'] } unless instance_method(op).arity == 0 + xop.output { |xin| xin.tag! 'soap:body', :use => 'literal', :namespace => namespaces['tns'] } end end end xdef.service :name => self.name do |xsrv| @@ -61,14 +64,13 @@ end end end end - def build_type_elements_for_method(m, xschema) + def build_type_elements_for_method(m, op_options, xschema) # element for method arguments um = instance_method(m) - op_options = options[:operations][m.to_sym] rescue nil if um.arity > 0 xschema.element :name => "#{op_options[:public_name]}Request" do |xreq| xreq.complexType do |xct| xct.all do |xall| @@ -104,10 +106,10 @@ end end end # element for method result - xschema.element :name => "#{op_options[:public_name]}" do |xreq| + xschema.element :name => "#{op_options[:public_name]}Response" do |xreq| xreq.complexType do |xct| xct.all do |xall| ret = op_options[:returns] rescue nil if ret.nil? xall.element :name => 'result', :type => 'xsd:any'