From b62b7bfe7dc03bc6ceca45716eda2264ae1b66e3 Mon Sep 17 00:00:00 2001 From: rubiii Date: Mon, 3 Jun 2013 16:59:16 +0200 Subject: [PATCH] added support for soap headers this supports multiple explicit and implicit header parts and it works the same as the request body. renamed the accessor for the http headers from #headers to #http_headers to separate it from the new Operation#header method for specifying the soap header to send. /cc savonrb/wasabi#27 --- lib/savon/envelope.rb | 39 +- lib/savon/{body.rb => message.rb} | 2 +- lib/savon/operation.rb | 32 +- lib/savon/wsdl/binding_operation.rb | 48 +- lib/savon/wsdl/operation.rb | 47 +- spec/fixtures/wsdl/bronto.wsdl | 3285 +++++++++++++++++ spec/fixtures/wsdl/yahoo.wsdl | 2425 ++++++++++++ spec/integration/amazon_spec.rb | 2 +- spec/integration/authentication_spec.rb | 2 +- spec/integration/awse_spec.rb | 2 +- spec/integration/betfair_spec.rb | 2 +- spec/integration/bookt_spec.rb | 2 +- spec/integration/bronto_spec.rb | 176 + spec/integration/crowd_spec.rb | 2 +- spec/integration/data_exchange_spec.rb | 2 +- spec/integration/economic_spec.rb | 2 +- spec/integration/email_verification_spec.rb | 2 +- spec/integration/interhome_spec.rb | 35 +- spec/integration/jira_spec.rb | 2 +- spec/integration/namespaced_actions_spec.rb | 2 +- spec/integration/oracle_spec.rb | 2 +- spec/integration/ratp_spec.rb | 2 +- spec/integration/taxcloud_spec.rb | 2 +- spec/integration/team_software_spec.rb | 2 +- spec/integration/telefonkatalogen_spec.rb | 2 +- spec/integration/wasmuth_spec.rb | 2 +- spec/integration/yahoo_spec.rb | 116 + spec/savon/operation/document_literal_spec.rb | 6 +- spec/savon/operation/rpc_literal_spec.rb | 6 +- spec/savon/operation_spec.rb | 12 +- 30 files changed, 6178 insertions(+), 85 deletions(-) rename lib/savon/{body.rb => message.rb} (99%) create mode 100644 spec/fixtures/wsdl/bronto.wsdl create mode 100644 spec/fixtures/wsdl/yahoo.wsdl create mode 100644 spec/integration/bronto_spec.rb create mode 100644 spec/integration/yahoo_spec.rb diff --git a/lib/savon/envelope.rb b/lib/savon/envelope.rb index e7d8f71a..33618889 100644 --- a/lib/savon/envelope.rb +++ b/lib/savon/envelope.rb @@ -1,21 +1,17 @@ require 'builder' -require 'savon/body' +require 'savon/message' class Savon class Envelope NSID = 'lol' - def initialize(operation, body) + def initialize(operation, header, body) @logger = Logging.logger[self] @operation = operation - @body = body - - unless @body - @logger.warn("No request body Hash given for the #{operation.name.inspect} operation.") - @body = {} - end + @header = header || {} + @body = body || {} @nsid_counter = -1 @namespaces = {} @@ -26,10 +22,7 @@ def register_namespace(namespace) end def to_s - body = Body.new(self, @operation.input).build(@body) - body = build_rpc_wrapper(body) if rpc_call? - - build_envelope(body) + build_envelope(build_header, build_body) end private @@ -39,11 +32,27 @@ def create_nsid "#{NSID}#{@nsid_counter}" end - def build_envelope(body) + def build_header + return "" if @header.empty? + Message.new(self, @operation.header_parts).build(@header) + end + + def build_body + return "" if @body.empty? + body = Message.new(self, @operation.body_parts).build(@body) + + if rpc_call? + build_rpc_wrapper(body) + else + body + end + end + + def build_envelope(header, body) builder = Builder::XmlMarkup.new(indent: 2) builder.tag! :env, :Envelope, collect_namespaces do |xml| - xml.tag!(:env, :Header) + xml.tag!(:env, :Header) { |xml| xml << header } xml.tag!(:env, :Body) { |xml| xml << body } end @@ -52,7 +61,7 @@ def build_envelope(body) def build_rpc_wrapper(body) name = @operation.name - namespace = @operation.binding_operation.input[:body][:namespace] + namespace = @operation.binding_operation.input_body[:namespace] nsid = register_namespace(namespace) if namespace tag = [nsid, name].compact.join(':') diff --git a/lib/savon/body.rb b/lib/savon/message.rb similarity index 99% rename from lib/savon/body.rb rename to lib/savon/message.rb index 7b7dbed2..4f730adc 100644 --- a/lib/savon/body.rb +++ b/lib/savon/message.rb @@ -1,7 +1,7 @@ require 'builder' class Savon - class Body + class Message def initialize(envelope, parts) @logger = Logging.logger[self] diff --git a/lib/savon/operation.rb b/lib/savon/operation.rb index 1056bebf..207c19ae 100644 --- a/lib/savon/operation.rb +++ b/lib/savon/operation.rb @@ -36,43 +36,51 @@ def initialize(operation, wsdl, http) attr_accessor :encoding # Public: Returns a Hash of HTTP headers to send. - def headers - return @headers if @headers + def http_headers + return @http_headers if @http_headers headers = {} headers['SOAPAction'] = %{"#{soap_action}"} if soap_action headers['Content-Type'] = CONTENT_TYPE[soap_version] % encoding - @headers = headers + @http_headers = headers end # Public: Sets the Hash of HTTP headers. - attr_writer :headers + attr_writer :http_headers + + # Public: Sets the request header Hash. + attr_accessor :header + + # Public: Create an example request header Hash. + def example_header + ExampleMessage.new(@operation.header_parts).to_hash + end # Public: Sets the request body Hash. attr_accessor :body # Public: Create an example request body Hash. def example_body - ExampleMessage.new(@operation.input).to_hash + ExampleMessage.new(@operation.body_parts).to_hash + end + + # Public: Returns the input body parts used to build the request body. + def body_parts + @operation.body_parts.inject([]) { |memo, part| memo + part.to_a } end # Public: Build the request XML for this operation. def build - Envelope.new(@operation, body).to_s + Envelope.new(@operation, header, body).to_s end # Public: Call the operation. def call - raw_response = @http.post(endpoint, headers, build) + raw_response = @http.post(endpoint, http_headers, build) Response.new(raw_response) end - # Public: Returns the input parts. - def input_parts - @operation.input.inject([]) { |memo, part| memo + part.to_a } - end - # Public: Returns the input style for this operation. def input_style @input_style ||= @operation.input_style diff --git a/lib/savon/wsdl/binding_operation.rb b/lib/savon/wsdl/binding_operation.rb index ccdf8ca0..ee611037 100644 --- a/lib/savon/wsdl/binding_operation.rb +++ b/lib/savon/wsdl/binding_operation.rb @@ -22,36 +22,50 @@ def name end # TODO: maybe use proper classes to clean this up. - def input - return @input if @input - input = { header: {}, body: {} } + def input_headers + return @input_headers if @input_headers + input_headers = [] + + if header_nodes = find_input_child_nodes('header') + header_nodes.each do |header_node| + input_headers << { + encoding_style: header_node['encodingStyle'], + namespace: header_node['namespace'], + use: header_node['use'], + message: header_node['message'], + part: header_node['part'] + } + end + end - input_node = @operation_node.element_children.find { |node| node.name == 'input' } - return unless input_node + @input_headers = input_headers + end - if header_node = input_node.element_children.find { |node| node.name == 'header' } - input[:header] = { - encoding_style: header_node['encodingStyle'], - namespace: header_node['namespace'], - use: header_node['use'], - message: header_node['message'], - part: header_node['part'] - } - end + # TODO: maybe use proper classes to clean this up. + def input_body + return @input_body if @input_body + input_body = {} - if body_node = input_node.element_children.find { |node| node.name == 'body' } - input[:body] = { + if body_node = find_input_child_nodes('body').first + input_body = { encoding_style: body_node['encodingStyle'], namespace: body_node['namespace'], use: body_node['use'] } end - input + @input_body = input_body end private + def find_input_child_nodes(child_name) + input_node = @operation_node.element_children.find { |node| node.name == 'input' } + return unless input_node + + input_node.element_children.select { |node| node.name == child_name } + end + def find_soap_operation_node @operation_node.element_children.each do |node| namespace = node.namespace.href diff --git a/lib/savon/wsdl/operation.rb b/lib/savon/wsdl/operation.rb index 4e433025..2e7f25a7 100644 --- a/lib/savon/wsdl/operation.rb +++ b/lib/savon/wsdl/operation.rb @@ -9,7 +9,6 @@ def initialize(name, endpoint, binding_operation, port_type_operation, wsdl) @endpoint = endpoint @binding_operation = binding_operation @port_type_operation = port_type_operation - @wsdl = wsdl end @@ -26,24 +25,62 @@ def soap_version end end - def input_style - "#{@binding_operation.style}/#{@binding_operation.input[:body][:use]}" + def header_parts + build_parts unless @header_parts + @header_parts end - def input - @input ||= build_message(@port_type_operation.input) + def body_parts + build_parts unless @body_parts + @body_parts + end + + def input_style + "#{@binding_operation.style}/#{@binding_operation.input_body[:use]}" end def output_style "#{@binding_operation.style}/#{@binding_operation.output[:body][:use]}" end + # TODO: do something useful with this! def output @output ||= build_message(@port_type_operation.output) end private + def build_parts + body_parts = collect_body_parts + header_parts = collect_header_parts + + # remove explicit header parts from the body parts + header_part_names = header_parts.map { |part| part[:name] } + body_parts.reject! { |part| header_part_names.include? part[:name] } + + @header_parts = MessageBuilder.new(@wsdl).build(header_parts) + @body_parts = MessageBuilder.new(@wsdl).build(body_parts) + end + + def collect_body_parts + message_name = @port_type_operation.input[:message] + find_message(message_name).parts + end + + def collect_header_parts + parts = [] + + @binding_operation.input_headers.each do |header| + next unless header[:message] && header[:part] + message_parts = find_message(header[:message]).parts + + # only add the single header part from the message + parts << message_parts.find { |part| part[:name] == header[:part] } + end + + parts + end + def build_message(input_output) message_name = input_output[:message] parts = find_message(message_name).parts diff --git a/spec/fixtures/wsdl/bronto.wsdl b/spec/fixtures/wsdl/bronto.wsdl new file mode 100644 index 00000000..36f92d4e --- /dev/null +++ b/spec/fixtures/wsdl/bronto.wsdl @@ -0,0 +1,3285 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/fixtures/wsdl/yahoo.wsdl b/spec/fixtures/wsdl/yahoo.wsdl new file mode 100644 index 00000000..7d364901 --- /dev/null +++ b/spec/fixtures/wsdl/yahoo.wsdl @@ -0,0 +1,2425 @@ + + + + + + + 10.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/spec/integration/amazon_spec.rb b/spec/integration/amazon_spec.rb index f814f098..f94e7646 100644 --- a/spec/integration/amazon_spec.rb +++ b/spec/integration/amazon_spec.rb @@ -26,7 +26,7 @@ namespace = 'http://fps.amazonaws.com/doc/2008-09-17/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['Pay'], { namespace: namespace, form: 'qualified', singular: true }], [['Pay', 'SenderTokenId'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], [['Pay', 'RecipientTokenId'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], diff --git a/spec/integration/authentication_spec.rb b/spec/integration/authentication_spec.rb index 623a1230..d20216db 100644 --- a/spec/integration/authentication_spec.rb +++ b/spec/integration/authentication_spec.rb @@ -28,7 +28,7 @@ namespace = 'http://v1_0.ws.auth.order.example.com/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['authenticate'], { namespace: namespace, form: 'qualified', singular: true }], [['authenticate', 'user'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], [['authenticate', 'password'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }] diff --git a/spec/integration/awse_spec.rb b/spec/integration/awse_spec.rb index cfa9f2c1..2d7dca18 100644 --- a/spec/integration/awse_spec.rb +++ b/spec/integration/awse_spec.rb @@ -58,7 +58,7 @@ namespace = 'http://webservices.amazon.com/AWSECommerceService/2011-08-01' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['CartAdd'], { namespace: namespace, form: 'qualified', singular: true }], [['CartAdd', 'MarketplaceDomain'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], [['CartAdd', 'AWSAccessKeyId'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], diff --git a/spec/integration/betfair_spec.rb b/spec/integration/betfair_spec.rb index 35b800dc..440c48ad 100644 --- a/spec/integration/betfair_spec.rb +++ b/spec/integration/betfair_spec.rb @@ -30,7 +30,7 @@ ns = 'http://www.betfair.com/publicapi/v5/BFExchangeService/' ns2 = 'http://www.betfair.com/publicapi/types/exchange/v5/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['getMUBetsLite'], { namespace: ns, form: 'qualified', singular: true }], diff --git a/spec/integration/bookt_spec.rb b/spec/integration/bookt_spec.rb index 02a6df10..ab7072f2 100644 --- a/spec/integration/bookt_spec.rb +++ b/spec/integration/bookt_spec.rb @@ -44,7 +44,7 @@ namespace = 'https://connect.bookt.com/connect' - expect(get_booking.input_parts).to eq([ + expect(get_booking.body_parts).to eq([ [['GetBooking'], { namespace: namespace, form: 'qualified', singular: true }], [['GetBooking', 'apiKey'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], [['GetBooking', 'bookingID'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }], diff --git a/spec/integration/bronto_spec.rb b/spec/integration/bronto_spec.rb new file mode 100644 index 00000000..eecf17f7 --- /dev/null +++ b/spec/integration/bronto_spec.rb @@ -0,0 +1,176 @@ +require 'spec_helper' + +describe 'Integration with Bronto' do + + subject(:client) { Savon.new fixture('wsdl/bronto') } + + let(:service_name) { :BrontoSoapApiImplService } + let(:port_name) { :BrontoSoapApiImplPort } + + it 'returns a map of services and ports' do + expect(client.services).to eq( + 'BrontoSoapApiImplService' => { + ports: { + 'BrontoSoapApiImplPort' => { + type: 'http://schemas.xmlsoap.org/wsdl/soap/', + location: 'https://api.bronto.com/v4' + } + } + } + ) + end + + it 'knows the operations' do + operation = client.operation(service_name, port_name, :addLogins) + + expect(operation.soap_action).to eq('') + expect(operation.endpoint).to eq('https://api.bronto.com/v4') + + namespace = 'http://api.bronto.com/v4' + + expect(operation.body_parts).to eq([ + [['addLogins'], { namespace: namespace, form: 'qualified', singular: true }], + [['addLogins', 'accounts'], { namespace: namespace, form: 'unqualified', singular: false }], + [['addLogins', 'accounts', 'username'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'password'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation'], { namespace: namespace, form: 'unqualified', singular: true }], + [['addLogins', 'accounts', 'contactInformation', 'organization'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'firstName'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'lastName'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'email'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'phone'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'address'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'address2'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'city'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'state'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'zip'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'country'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'contactInformation', 'notes'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], + [['addLogins', 'accounts', 'permissionAgencyAdmin'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionAdmin'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionApi'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionUpgrade'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionFatigueOverride'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionMessageCompose'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionMessageApprove'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionMessageDelete'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionAutomatorCompose'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionListCreateSend'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionListCreate'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionSegmentCreate'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionFieldCreate'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionFieldReorder'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionSubscriberCreate'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }], + [['addLogins', 'accounts', 'permissionSubscriberView'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:boolean' }] + ]) + end + + # explicit headers. reference: http://www.ibm.com/developerworks/library/ws-tip-headers/index.html + it 'creates an example header' do + operation = client.operation(service_name, port_name, :addLogins) + + expect(operation.example_header).to eq( + sessionHeader: { + sessionId: 'string' + } + ) + end + + it 'creates an example body' do + operation = client.operation(service_name, port_name, :addLogins) + + expect(operation.example_body).to eq( + addLogins: { + + # TODO: should this be an Array? + accounts: { + username: 'string', + password: 'string', + contactInformation: { + organization: 'string', + firstName: 'string', + lastName: 'string', + email: 'string', + phone: 'string', + address: 'string', + address2: 'string', + city: 'string', + state: 'string', + zip: 'string', + country: 'string', + notes: 'string' + }, + permissionAgencyAdmin: 'boolean', + permissionAdmin: 'boolean', + permissionApi: 'boolean', + permissionUpgrade: 'boolean', + permissionFatigueOverride: 'boolean', + permissionMessageCompose: 'boolean', + permissionMessageApprove: 'boolean', + permissionMessageDelete: 'boolean', + permissionAutomatorCompose: 'boolean', + permissionListCreateSend: 'boolean', + permissionListCreate: 'boolean', + permissionSegmentCreate: 'boolean', + permissionFieldCreate: 'boolean', + permissionFieldReorder: 'boolean', + permissionSubscriberCreate: 'boolean', + permissionSubscriberView: 'boolean' + } + } + ) + end + + it 'creates a request with a header' do + operation = client.operation(service_name, port_name, :addLogins) + + operation.header = { + sessionHeader: { + sessionId: '23' + } + } + + operation.body = { + addLogins: { + accounts: { + username: 'admin', + password: 'secert', + contactInformation: { + firstName: 'brew', + email: 'brew@example.com', + }, + permissionApi: true, + } + } + } + + expected = Nokogiri.XML(' + + + + 23 + + + + + + admin + secert + + brew + brew@example.com + + true + + + + + ') + + expect(Nokogiri.XML operation.build). + to be_equivalent_to(expected).respecting_element_order + end + +end diff --git a/spec/integration/crowd_spec.rb b/spec/integration/crowd_spec.rb index 95bf4b04..76e0300a 100644 --- a/spec/integration/crowd_spec.rb +++ b/spec/integration/crowd_spec.rb @@ -28,7 +28,7 @@ ns2 = 'http://authentication.integration.crowd.atlassian.com' ns3 = 'http://soap.integration.crowd.atlassian.com' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['addAttributeToGroup'], { namespace: ns1, form: 'qualified', singular: true }], [['addAttributeToGroup', 'in0'], { namespace: ns1, form: 'qualified', singular: true }], [['addAttributeToGroup', 'in0', 'name'], { namespace: ns2, form: 'qualified', singular: true, type: 'xsd:string' }], diff --git a/spec/integration/data_exchange_spec.rb b/spec/integration/data_exchange_spec.rb index b17c133a..2fe95228 100644 --- a/spec/integration/data_exchange_spec.rb +++ b/spec/integration/data_exchange_spec.rb @@ -29,7 +29,7 @@ # but we're currently listing it, because we're not properly separating between # known built-in simple types and unknown types so we can't make that choice. - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['in0'], { namespace: nil, form: 'unqualified', type: 'soapenc:string', singular: true }], [['in1'], { namespace: nil, form: 'unqualified', type: 'soapenc:string', singular: true }], diff --git a/spec/integration/economic_spec.rb b/spec/integration/economic_spec.rb index 37e774d2..c9a20840 100644 --- a/spec/integration/economic_spec.rb +++ b/spec/integration/economic_spec.rb @@ -31,7 +31,7 @@ namespace = 'http://e-conomic.com' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['Account_GetDataArray'], { namespace: namespace, form: 'qualified', singular: true }], [['Account_GetDataArray', 'entityHandles'], { namespace: namespace, form: 'qualified', singular: true }], [['Account_GetDataArray', 'entityHandles', 'AccountHandle'], { namespace: namespace, form: 'qualified', singular: false }], diff --git a/spec/integration/email_verification_spec.rb b/spec/integration/email_verification_spec.rb index 32b986e0..bc551b08 100644 --- a/spec/integration/email_verification_spec.rb +++ b/spec/integration/email_verification_spec.rb @@ -33,7 +33,7 @@ namespace = 'http://ws.cdyne.com/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['VerifyEmail'], { namespace: namespace, form: 'qualified', singular: true }], [['VerifyEmail', 'email'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }], [['VerifyEmail', 'LicenseKey'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }] diff --git a/spec/integration/interhome_spec.rb b/spec/integration/interhome_spec.rb index 77a1d472..6a08a72c 100644 --- a/spec/integration/interhome_spec.rb +++ b/spec/integration/interhome_spec.rb @@ -25,15 +25,14 @@ end it 'knows the operations' do - service, port = 'WebService', 'WebServiceSoap' - operation = client.operation(service, port, 'ClientBooking') + operation = client.operation(service_name, port_name, 'ClientBooking') expect(operation.soap_action).to eq('http://www.interhome.com/webservice/ClientBooking') expect(operation.endpoint).to eq('https://webservices.interhome.com/quality/partnerV3/WebService.asmx') namespace = 'http://www.interhome.com/webservice' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['ClientBooking'], { namespace: namespace, form: 'qualified', singular: true }], [['ClientBooking', 'inputValue'], { namespace: namespace, form: 'qualified', singular: true }], [['ClientBooking', 'inputValue', 'SalesOfficeCode'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }], @@ -82,7 +81,19 @@ ]) end - it 'creates an example request including optional elements' do + # implicit headers. reference: http://www.ibm.com/developerworks/library/ws-tip-headers/index.html + it 'creates an example header' do + operation = client.operation(service_name, port_name, :Availability) + + expect(operation.example_header).to eq( + ServiceAuthHeader: { + Username: 'string', + Password: 'string' + } + ) + end + + it 'creates an example body including optional elements' do operation = client.operation(service_name, port_name, :Availability) expect(operation.example_body).to eq( @@ -102,10 +113,17 @@ it 'skips optional elements in the request' do operation = client.operation(service_name, port_name, :Availability) + operation.header = { + ServiceAuthHeader: { + Username: 'test', + Password: 'secret' + } + } + operation.body = { Availability: { inputValue: { - # We're leaving out two elements on purpose. + # Leaving out two optional elements on purpose. AccommodationCode: 'secret' } } @@ -115,7 +133,12 @@ - + + + test + secret + + diff --git a/spec/integration/jira_spec.rb b/spec/integration/jira_spec.rb index 8874e96b..3063a769 100644 --- a/spec/integration/jira_spec.rb +++ b/spec/integration/jira_spec.rb @@ -26,7 +26,7 @@ namespace = 'http://beans.soap.rpc.jira.atlassian.com' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['in0'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }], [['in1'], { namespace: nil, form: 'unqualified', singular: true }], [['in1', 'name'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xsd:string' }], diff --git a/spec/integration/namespaced_actions_spec.rb b/spec/integration/namespaced_actions_spec.rb index c74f52b5..ad3d122a 100644 --- a/spec/integration/namespaced_actions_spec.rb +++ b/spec/integration/namespaced_actions_spec.rb @@ -27,7 +27,7 @@ expect(operation.soap_action).to eq('http://api.example.com/api/Client.Delete') expect(operation.endpoint).to eq('https://api.example.com/api/api.asmx') - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['Client.Delete'], { namespace: 'http://api.example.com/api/', form: 'qualified', singular: true }], [['Client.Delete', 'ApiKey'], { namespace: 'http://api.example.com/api/', form: 'qualified', singular: true, type: 's:string' }], [['Client.Delete', 'ClientID'], { namespace: 'http://api.example.com/api/', form: 'qualified', singular: true, type: 's:string' }] diff --git a/spec/integration/oracle_spec.rb b/spec/integration/oracle_spec.rb index db68426c..7e499fc0 100644 --- a/spec/integration/oracle_spec.rb +++ b/spec/integration/oracle_spec.rb @@ -42,7 +42,7 @@ namespace = 'urn://oracle.bi.webservices/v7' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['joinGroups'], { namespace: namespace, form: 'qualified', singular: true }], [['joinGroups', 'group'], { namespace: namespace, form: 'qualified', singular: false }], [['joinGroups', 'group', 'name'], { namespace: namespace, form: 'qualified', singular: true, type: 'xsd:string' }], diff --git a/spec/integration/ratp_spec.rb b/spec/integration/ratp_spec.rb index 9d6165ff..42bd9a07 100644 --- a/spec/integration/ratp_spec.rb +++ b/spec/integration/ratp_spec.rb @@ -34,7 +34,7 @@ ns1 = 'http://wsiv.ratp.fr' ns2 = 'http://wsiv.ratp.fr/xsd' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['getStations'], { namespace: ns1, form: 'qualified', singular: true }], [['getStations', 'station'], { namespace: ns1, form: 'qualified', singular: true }], [['getStations', 'station', 'direction'], { namespace: ns2, form: 'qualified', singular: true }], diff --git a/spec/integration/taxcloud_spec.rb b/spec/integration/taxcloud_spec.rb index cff110ef..4affbb36 100644 --- a/spec/integration/taxcloud_spec.rb +++ b/spec/integration/taxcloud_spec.rb @@ -30,7 +30,7 @@ namespace = 'http://taxcloud.net' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['VerifyAddress'], { namespace: namespace, form: 'qualified', singular: true }], [['VerifyAddress', 'uspsUserID'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }], [['VerifyAddress', 'address1'], { namespace: namespace, form: 'qualified', singular: true, type: 's:string' }], diff --git a/spec/integration/team_software_spec.rb b/spec/integration/team_software_spec.rb index 696ad6a0..668b7ed3 100644 --- a/spec/integration/team_software_spec.rb +++ b/spec/integration/team_software_spec.rb @@ -42,7 +42,7 @@ namespace = 'http://tempuri.org/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['Login'], { namespace: namespace, form: 'qualified', singular: true }], [['Login', 'MappingKey'], { namespace: namespace, form: 'qualified', singular: true, type: 'xs:string' }] ]) diff --git a/spec/integration/telefonkatalogen_spec.rb b/spec/integration/telefonkatalogen_spec.rb index 7b919bca..109f9a8a 100644 --- a/spec/integration/telefonkatalogen_spec.rb +++ b/spec/integration/telefonkatalogen_spec.rb @@ -26,7 +26,7 @@ # notice how this contains 9 parts with one element each. # it does not include the rpc wrapper. - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['sender'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }], [['cellular'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }], [['msg'], { namespace: nil, form: 'unqualified', singular: true, type: 'xsd:string' }], diff --git a/spec/integration/wasmuth_spec.rb b/spec/integration/wasmuth_spec.rb index b74e5a3b..7330f4e8 100644 --- a/spec/integration/wasmuth_spec.rb +++ b/spec/integration/wasmuth_spec.rb @@ -36,7 +36,7 @@ namespace = 'http://ws.online.msw/' - expect(operation.input_parts).to eq([ + expect(operation.body_parts).to eq([ [['getStTables'], { namespace: namespace, form: 'qualified', singular: true }], [['getStTables', 'username'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], [['getStTables', 'password'], { namespace: namespace, form: 'unqualified', singular: true, type: 'xs:string' }], diff --git a/spec/integration/yahoo_spec.rb b/spec/integration/yahoo_spec.rb new file mode 100644 index 00000000..5d78a938 --- /dev/null +++ b/spec/integration/yahoo_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +describe 'Integration with Yahoo‘s AccountService' do + + subject(:client) { Savon.new fixture('wsdl/yahoo') } + + let(:service_name) { :AccountServiceService } + let(:port_name) { :AccountService } + + it 'returns a map of services and ports' do + expect(client.services).to eq( + 'AccountServiceService' => { + ports: { + 'AccountService' => { + type: 'http://schemas.xmlsoap.org/wsdl/soap/', + + # symbolic endpoint + location: 'https://USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE/services/V10/AccountService' + } + } + } + ) + end + + it 'knows the operations' do + operation = client.operation(service_name, port_name, :updateStatusForManagedPublisher) + + expect(operation.soap_action).to eq('') + expect(operation.endpoint).to eq('https://USE_ADDRESS_RETURNED_BY_LOCATION_SERVICE/services/V10/AccountService') + + namespace = 'http://apt.yahooapis.com/V10' + + expect(operation.body_parts).to eq([ + [['updateStatusForManagedPublisher'], { namespace: namespace, form: 'qualified', singular: true }], + [['updateStatusForManagedPublisher', 'accountID'], { namespace: namespace, form: 'qualified', singular: true, type: 'xsd:string' }], + [['updateStatusForManagedPublisher', 'accountStatus'], { namespace: namespace, form: 'qualified', singular: true, type: 'xsd:string' }] + ]) + end + + # multiple implicit headers. reference: http://www.ibm.com/developerworks/library/ws-tip-headers/index.html + it 'creates an example header' do + operation = client.operation(service_name, port_name, :updateStatusForManagedPublisher) + + expect(operation.example_header).to eq( + Security: { + UsernameToken: { + Username: 'string', + Password: 'string' + } + }, + license: 'string', + accountID: 'string' + ) + end + + it 'creates an example body' do + operation = client.operation(service_name, port_name, :updateStatusForManagedPublisher) + + expect(operation.example_body).to eq( + updateStatusForManagedPublisher: { + accountID: 'string', + accountStatus: 'string' + } + ) + end + + it 'creates a request with multiple headers' do + operation = client.operation(service_name, port_name, :updateStatusForManagedPublisher) + + operation.header = { + Security: { + UsernameToken: { + Username: 'admin', + Password: 'secret' + } + }, + license: 'abc-license', + accountID: '23' + } + + operation.body = { + updateStatusForManagedPublisher: { + accountID: '23', + accountStatus: 'closed' + } + } + + expected = Nokogiri.XML(' + + + + + admin + secret + + + abc-license + 23 + + + + 23 + closed + + + + ') + + expect(Nokogiri.XML operation.build). + to be_equivalent_to(expected).respecting_element_order + end + +end diff --git a/spec/savon/operation/document_literal_spec.rb b/spec/savon/operation/document_literal_spec.rb index 9f9faf61..5881415d 100644 --- a/spec/savon/operation/document_literal_spec.rb +++ b/spec/savon/operation/document_literal_spec.rb @@ -11,7 +11,7 @@ op1 = client.operation('SampleService', 'Sample', 'op1') expect(op1.input_style).to eq('document/literal') - expect(op1.input_parts).to eq([ + expect(op1.body_parts).to eq([ [ ['op1'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ], [ ['op1', 'in'], { namespace: 'http://apiNamespace.com', form: 'unqualified', singular: true } ], [ ['op1', 'in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], @@ -25,7 +25,7 @@ op2 = client.operation('SampleService', 'Sample', 'op2') expect(op2.input_style).to eq('document/literal') - expect(op2.input_parts).to eq([ + expect(op2.body_parts).to eq([ [ ['op2'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ], [ ['op2', 'in'], { namespace: 'http://apiNamespace.com', form: 'unqualified', singular: true } ], [ ['op2', 'in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], @@ -39,7 +39,7 @@ op3 = client.operation('SampleService', 'Sample', 'op3') expect(op3.input_style).to eq('document/literal') - expect(op3.input_parts).to eq([ + expect(op3.body_parts).to eq([ [ ['op3'], { namespace: 'http://apiNamespace.com', form: 'qualified', singular: true } ], [ ['op3', 'DataElem'], { namespace: 'http://dataNamespace.com', form: 'qualified', singular: true } ], [ ['op3', 'DataElem', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], diff --git a/spec/savon/operation/rpc_literal_spec.rb b/spec/savon/operation/rpc_literal_spec.rb index 97b1249f..a584e215 100644 --- a/spec/savon/operation/rpc_literal_spec.rb +++ b/spec/savon/operation/rpc_literal_spec.rb @@ -11,7 +11,7 @@ op1 = client.operation('SampleService', 'Sample', 'op1') expect(op1.input_style).to eq('rpc/literal') - expect(op1.input_parts).to eq([ + expect(op1.body_parts).to eq([ [ ['in'], { namespace: nil, form: 'unqualified', singular: true } ], [ ['in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], [ ['in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ] @@ -24,7 +24,7 @@ op2 = client.operation('SampleService', 'Sample', 'op2') expect(op2.input_style).to eq('rpc/literal') - expect(op2.input_parts).to eq([ + expect(op2.body_parts).to eq([ [ ['in'], { namespace: nil, form: 'unqualified', singular: true } ], [ ['in', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], [ ['in', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ] @@ -37,7 +37,7 @@ op3 = client.operation('SampleService', 'Sample', 'op3') expect(op3.input_style).to eq('rpc/literal') - expect(op3.input_parts).to eq([ + expect(op3.body_parts).to eq([ [ ['DataElem'], { namespace: 'http://dataNamespace.com', form: 'qualified', singular: true } ], [ ['DataElem', 'data1'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], [ ['DataElem', 'data2'], { namespace: 'http://dataNamespace.com', form: 'unqualified', singular: true, type: 'int' } ], diff --git a/spec/savon/operation_spec.rb b/spec/savon/operation_spec.rb index 36176cf7..30cd053a 100644 --- a/spec/savon/operation_spec.rb +++ b/spec/savon/operation_spec.rb @@ -51,9 +51,9 @@ end end - describe '#headers' do + describe '#http_headers' do it 'returns a Hash of HTTP headers for a SOAP 1.2 operation' do - expect(operation.headers).to eq( + expect(operation.http_headers).to eq( 'SOAPAction' => '"http://www.webserviceX.NET/ConvertTemp"', 'Content-Type' => 'application/soap+xml;charset=UTF-8' ) @@ -63,17 +63,17 @@ wsdl_operation = wsdl.operation('ConvertTemperature', 'ConvertTemperatureSoap', 'ConvertTemp') operation = Savon::Operation.new(wsdl_operation, wsdl, http_mock) - expect(operation.headers).to eq( + expect(operation.http_headers).to eq( 'SOAPAction' => '"http://www.webserviceX.NET/ConvertTemp"', 'Content-Type' => 'text/xml;charset=UTF-8' ) end it 'can be overwritten' do - header = { 'SecretToken' => 'abc'} - operation.headers = header + headers = { 'SecretToken' => 'abc'} + operation.http_headers = headers - expect(operation.headers).to eq(header) + expect(operation.http_headers).to eq(headers) end end