def serialize_soap_result(op_options, r)
      xb = Builder::XmlMarkup.new
      xb.instruct!

      xb.Envelope :xmlns => soap_env_ns, 'xmlns:xsi' => namespaces['xsi'] do |xenv|
        xenv.Body do |xbody|
          xbody.tag! "#{op_options[:public_name]}Response", :xmlns => namespaces['tns'] do |xresp|
            if r.nil?
              xresp.tag! "#{op_options[:public_name]}Result", 'xsi:nil' => 'true'
            else
              ret = op_options[:returns] rescue nil
              case ret
                when NilClass, Class
                  xresp.tag! "#{op_options[:public_name]}Result", r
                when Hash
                  xresp.tag! "#{op_options[:public_name]}Result" do |xres|
                    ret.each do |k, v|
                      extract_and_serialize_value(xres, r, k, v)
                    end
                  end
                else
                  raise "Unsupported return type: #{ret.inspect}"
              end
            end
          end
        end
      end
    end
def serialize_soap_result(op_options, r)
      xb = Builder::XmlMarkup.new
      xb.instruct!

      xb.Envelope :xmlns => soap_env_ns, 'xmlns:xsi' => namespaces['xsi'] do |xenv|
        xenv.Body do |xbody|
          xbody.tag! "#{op_options[:public_name]}Response", :xmlns => namespaces['tns'] do |xresp|
            if r.nil?
              xresp.tag! "#{op_options[:public_name]}Result", 'xsi:nil' => 'true'
            else
              ret = op_options[:returns] rescue nil
              case ret
                when NilClass, Class
                  xresp.tag! "#{op_options[:public_name]}Result", r
                when Hash
                  xresp.tag! "#{op_options[:public_name]}Result" do |xres|
                    ret.each do |k, v|
                      extract_and_serialize_value(xres, r, k, v)
                    end
                  end
                else
                  raise "Unsupported return type: #{ret.inspect}"
              end
            end
          end
        end
      end
    end
Serializes the result of an operation as a SOAP Envelope.

 @param op_options [Hash] The operation options.
 @param r [Hash,Object] The operation result.
noinspection RubyArgCount