savon 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGELOG +11 -0
  2. data/README.rdoc +5 -3
  3. data/Rakefile +2 -0
  4. data/lib/savon.rb +1 -0
  5. data/lib/savon/client.rb +54 -13
  6. data/lib/savon/core_ext.rb +0 -0
  7. data/lib/savon/core_ext/array.rb +20 -6
  8. data/lib/savon/core_ext/datetime.rb +0 -0
  9. data/lib/savon/core_ext/hash.rb +36 -15
  10. data/lib/savon/core_ext/net_http.rb +1 -2
  11. data/lib/savon/core_ext/object.rb +1 -3
  12. data/lib/savon/core_ext/string.rb +9 -2
  13. data/lib/savon/core_ext/symbol.rb +0 -0
  14. data/lib/savon/core_ext/uri.rb +1 -1
  15. data/lib/savon/logger.rb +56 -0
  16. data/lib/savon/request.rb +42 -50
  17. data/lib/savon/response.rb +62 -9
  18. data/lib/savon/soap.rb +157 -42
  19. data/lib/savon/wsdl.rb +71 -6
  20. data/lib/savon/wsdl_stream.rb +2 -2
  21. data/lib/savon/wsse.rb +36 -5
  22. data/spec/basic_spec_helper.rb +0 -0
  23. data/spec/endpoint_helper.rb +0 -0
  24. data/spec/fixtures/response/response_fixture.rb +0 -0
  25. data/spec/fixtures/response/xml/authentication.xml +0 -0
  26. data/spec/fixtures/response/xml/multi_ref.xml +0 -0
  27. data/spec/fixtures/response/xml/soap_fault.xml +0 -0
  28. data/spec/fixtures/response/xml/soap_fault12.xml +0 -0
  29. data/spec/fixtures/wsdl/wsdl_fixture.rb +0 -0
  30. data/spec/fixtures/wsdl/xml/authentication.xml +0 -0
  31. data/spec/fixtures/wsdl/xml/geotrust.xml +0 -0
  32. data/spec/fixtures/wsdl/xml/namespaced_actions.xml +0 -0
  33. data/spec/fixtures/wsdl/xml/no_namespace.xml +0 -0
  34. data/spec/http_stubs.rb +0 -0
  35. data/spec/integration/http_basic_auth_spec.rb +0 -0
  36. data/spec/integration/server.rb +0 -0
  37. data/spec/savon/client_spec.rb +5 -1
  38. data/spec/savon/core_ext/array_spec.rb +0 -0
  39. data/spec/savon/core_ext/datetime_spec.rb +0 -0
  40. data/spec/savon/core_ext/hash_spec.rb +10 -1
  41. data/spec/savon/core_ext/net_http_spec.rb +0 -0
  42. data/spec/savon/core_ext/object_spec.rb +0 -0
  43. data/spec/savon/core_ext/string_spec.rb +6 -2
  44. data/spec/savon/core_ext/symbol_spec.rb +0 -0
  45. data/spec/savon/core_ext/uri_spec.rb +4 -0
  46. data/spec/savon/request_spec.rb +5 -4
  47. data/spec/savon/response_spec.rb +0 -0
  48. data/spec/savon/soap_spec.rb +124 -130
  49. data/spec/savon/wsdl_spec.rb +0 -0
  50. data/spec/savon/wsse_spec.rb +0 -0
  51. data/spec/spec_helper.rb +0 -0
  52. metadata +55 -37
  53. data/readme/client.rdoc +0 -18
  54. data/readme/errors.rdoc +0 -11
  55. data/readme/logging.rdoc +0 -11
  56. data/readme/participate.rdoc +0 -21
  57. data/readme/request.rdoc +0 -37
  58. data/readme/response.rdoc +0 -46
  59. data/readme/soap.rdoc +0 -71
  60. data/readme/value_mapping.rdoc +0 -49
  61. data/readme/wsdl.rdoc +0 -39
  62. data/readme/wsse.rdoc +0 -28
data/CHANGELOG CHANGED
@@ -1,7 +1,18 @@
1
+ == 0.7.6 (2010-03-21)
2
+ * Renamed
3
+ * Moved documentation from the Github Wiki to the actual class files and established a much nicer
4
+ documentation combining examples and implementation (using Hanna) at: http://savon.rubiii.com
5
+ * Added Savon::Client#call as a workaround for dispatching calls to SOAP actions named after
6
+ existing methods. Fix for issue #48.
7
+ * Add support for specifying attributes for duplicate tags (via Hash values as Arrays). Fix for issue #45.
8
+ * Fix for issue #41 (Escape special characters (e.g. &) for XML requests).
9
+ * Fix for issue #39 and #49. Added Savon::SOAP#xml which let's you specify completely custom SOAP request XML.
10
+
1
11
  == 0.7.5 (2010-02-19)
2
12
  * Fix for issue #34 (soap_actions returns empty for wsdl12).
3
13
  * Fix for issue #36 (Custom WSDL actions broken).
4
14
  * Added feature requested in issue #35 (Setting an attribute on an element?).
15
+ * Changed the key for specifying the order of tags from :@inorder to :order!
5
16
 
6
17
  == 0.7.4 (2010-02-02)
7
18
  * Fix for issue #33 (undefined method 'start_with?').
@@ -2,7 +2,7 @@
2
2
 
3
3
  ==== Heavy metal Ruby SOAP client library
4
4
 
5
- {RDoc}[http://rdoc.info/projects/rubiii/savon] | {Wiki}[http://wiki.github.com/rubiii/savon] | {Metrics}[http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/savon.git]
5
+ {Documentation}[http://savon.rubiii.com] | {Metrics}[http://getcaliper.com/caliper/project?repo=git://github.com/rubiii/savon.git]
6
6
 
7
7
  == Installation
8
8
 
@@ -16,6 +16,8 @@ Instantiate Savon::Client, passing in the WSDL of your service.
16
16
 
17
17
  client = Savon::Client.new "http://example.com/UserService?wsdl"
18
18
 
19
+ For production, it is highly recommended to not use Savon::WSDL. Information on {how to disable the WSDL}[http://savon.rubiii.com/docs/latest/classes/Savon/WSDL.html].
20
+
19
21
  == Calling a SOAP action
20
22
 
21
23
  Assuming your service applies to the defaults, you can now call any available SOAP action.
@@ -54,9 +56,9 @@ Savon::Response represents the HTTP and SOAP response. It contains and raises er
54
56
  == HTTP errors and SOAP faults
55
57
 
56
58
  Savon raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError in case of an HTTP error.
57
- More information: {Errors}[http://wiki.github.com/rubiii/savon/errors]
59
+ More information: {Errors}[http://savon.rubiii.com/docs/latest/classes/Savon/Response.html]
58
60
 
59
61
  == Logging
60
62
 
61
63
  Savon logs each request and response to STDOUT. But there are a couple of options to change the default behavior.
62
- More information: {Logging}[http://wiki.github.com/rubiii/savon/logging]
64
+ More information: {Logging}[http://savon.rubiii.com/docs/latest/classes/Savon/Request.html]
data/Rakefile CHANGED
@@ -36,6 +36,7 @@ Spec::Rake::SpecTask.new(:run_integration_spec) do |spec|
36
36
  end
37
37
 
38
38
  begin
39
+ $:.unshift File.join(File.dirname(__FILE__), "..", "hanna", "lib")
39
40
  require "hanna/rdoctask"
40
41
 
41
42
  Rake::RDocTask.new do |rdoc|
@@ -43,6 +44,7 @@ begin
43
44
  rdoc.rdoc_dir = "doc"
44
45
  rdoc.rdoc_files.include("**/*.rdoc").include("lib/**/*.rb")
45
46
  rdoc.options << "--line-numbers"
47
+ rdoc.options << "--webcvs=http://github.com/rubiii/savon/tree/master/"
46
48
  end
47
49
  rescue LoadError
48
50
  puts "'gem install hanna' for documentation"
@@ -23,6 +23,7 @@ require "crack/xml"
23
23
  require "savon/core_ext"
24
24
  require "savon/wsse"
25
25
  require "savon/soap"
26
+ require "savon/logger"
26
27
  require "savon/request"
27
28
  require "savon/response"
28
29
  require "savon/wsdl_stream"
@@ -1,13 +1,47 @@
1
1
  module Savon
2
2
 
3
- # == Savon::Client
3
+ # = Savon::Client
4
4
  #
5
- # Heavy metal Ruby SOAP client library. Minimizes the overhead of working
6
- # with SOAP services and XML.
5
+ # Savon::Client is the main object for connecting to a SOAP service. It includes methods to access
6
+ # both the Savon::WSDL and Savon::Request object.
7
+ #
8
+ # == Instantiation
9
+ #
10
+ # Depending on whether you aim to use Savon with or without Savon::WSDL, you need to instantiate
11
+ # Savon::Client by passing in the WSDL or SOAP endpoint.
12
+ #
13
+ # Client instance with a WSDL endpoint:
14
+ #
15
+ # client = Savon::Client.new "http://example.com/UserService?wsdl"
16
+ #
17
+ # Client instance with a SOAP endpoint (for using Savon without a WSDL):
18
+ #
19
+ # client = Savon::Client.new "http://example.com/UserService"
20
+ #
21
+ # It is recommended to not use Savon::WSDL for production. Please take a look at the Documentation
22
+ # for Savon::WSDL for more information about how to disable it.
23
+ #
24
+ # == Using a proxy server
25
+ #
26
+ # You can specify the URI to a proxy server via optional hash arguments.
27
+ #
28
+ # client = Savon::Client.new "http://example.com/UserService?wsdl", :proxy => "http://proxy.example.com"
29
+ #
30
+ # == Savon::WSDL
31
+ #
32
+ # You can access Savon::WSDL via:
33
+ #
34
+ # client.wsdl
35
+ #
36
+ # == Savon::Request
37
+ #
38
+ # You can also access Savon::Request via:
39
+ #
40
+ # client.request
7
41
  class Client
8
42
 
9
- # Expects a SOAP +endpoint+ String. Also accepts an optional Hash of
10
- # +options+ for specifying a proxy server and SSL client authentication.
43
+ # Expects a SOAP +endpoint+ string. Also accepts an optional hash of +options+ for specifying
44
+ # a +:proxy+ server to use.
11
45
  def initialize(endpoint, options = {})
12
46
  @request = Request.new endpoint, options
13
47
  @wsdl = WSDL.new @request
@@ -25,6 +59,12 @@ module Savon
25
59
  super
26
60
  end
27
61
 
62
+ # Same as method_missing. Workaround for SOAP actions that method_missing does not catch
63
+ # because the method does exist.
64
+ def call(method, *args, &block)
65
+ method_missing method, *args, &block
66
+ end
67
+
28
68
  private
29
69
 
30
70
  # Dispatches requests to SOAP actions matching a given +method+ name.
@@ -32,12 +72,12 @@ module Savon
32
72
  soap_action = soap_action_from method.to_s
33
73
  super unless @wsdl.respond_to? soap_action
34
74
 
35
- setup_objects @wsdl.operation_from(soap_action), &block
75
+ setup_objects *@wsdl.operation_from(soap_action), &block
36
76
  Response.new @request.soap(@soap)
37
77
  end
38
78
 
39
- # Sets whether to use Savon::WSDL by a given +method+ name and
40
- # removes exclamation marks from the given +method+ name.
79
+ # Sets whether to use Savon::WSDL by a given +method+ name and returns the original method name
80
+ # without exclamation marks.
41
81
  def soap_action_from(method)
42
82
  @wsdl.enabled = !method.ends_with?("!")
43
83
 
@@ -50,16 +90,17 @@ module Savon
50
90
  @wsdl.enabled? ? @wsdl.soap_endpoint : @request.endpoint
51
91
  end
52
92
 
53
- # Expects a SOAP operation Hash and sets up Savon::SOAP and Savon::WSSE.
54
- # Yields them to a given +block+ in case one was given.
55
- def setup_objects(operation, &block)
56
- @soap, @wsse = SOAP.new(operation, soap_endpoint), WSSE.new
93
+ # Expects a SOAP operation Hash and sets up Savon::SOAP and Savon::WSSE. Yields them to a given
94
+ # +block+ in case one was given.
95
+ def setup_objects(action, input, &block)
96
+ @soap, @wsse = SOAP.new(action, input, soap_endpoint), WSSE.new
57
97
  yield_objects &block if block
58
98
  @soap.namespaces["xmlns:wsdl"] ||= @wsdl.namespace_uri if @wsdl.enabled?
59
99
  @soap.wsse = @wsse
60
100
  end
61
101
 
62
- # Yields Savon::SOAP and Savon::WSSE to a given +block+.
102
+ # Yields either Savon::SOAP or Savon::SOAP and Savon::WSSE to a given +block+, depending on
103
+ # the number of arguments expected by the block.
63
104
  def yield_objects(&block)
64
105
  case block.arity
65
106
  when 1 then yield @soap
File without changes
@@ -1,17 +1,31 @@
1
1
  class Array
2
2
 
3
- # Translates the Array into SOAP request compatible XML. See: Hash#to_soap_xml.
4
- def to_soap_xml(key)
3
+ # Translates the Array into SOAP compatible XML. See: Hash.to_soap_xml.
4
+ def to_soap_xml(key, attributes = {})
5
5
  xml = Builder::XmlMarkup.new
6
6
 
7
- each do |item|
7
+ each_with_index do |item, index|
8
+ attrs = tag_attributes attributes, index
8
9
  case item
9
- when Array, Hash then xml.tag!(key) { xml << item.to_soap_xml }
10
- else xml.tag!(key) { xml << item.to_soap_value }
10
+ when Hash then xml.tag!(key, attrs) { xml << item.to_soap_xml }
11
+ else xml.tag!(key, attrs) { xml << item.to_soap_value }
11
12
  end
12
13
  end
13
14
 
14
15
  xml.target!
15
16
  end
16
17
 
17
- end
18
+ private
19
+
20
+ # Takes a Hash of +attributes+ and the +index+ for which to return attributes
21
+ # for duplicate tags.
22
+ def tag_attributes(attributes, index)
23
+ return {} if attributes.empty?
24
+
25
+ attributes.inject({}) do |hash, (key, value)|
26
+ value = value[index] if value.kind_of? Array
27
+ hash.merge key => value
28
+ end
29
+ end
30
+
31
+ end
File without changes
@@ -10,26 +10,47 @@ class Hash
10
10
 
11
11
  # Translates the Hash into SOAP request compatible XML.
12
12
  #
13
- # === Example:
14
- #
15
13
  # { :find_user => { :id => 123, "wsdl:Key" => "api" } }.to_soap_xml
16
14
  # # => "<findUser><id>123</id><wsdl:Key>api</wsdl:Key></findUser>"
17
15
  #
18
- # Comes with a way to control the order of XML tags in case you're foced to do so (parameterOrder).
19
- # Specify an optional Array under the :order! key reflecting the order of your keys.
20
- # An ArgumentError is raised unless the Array contains the exact same/all keys of your Hash.
16
+ # ==== Mapping
17
+ #
18
+ # * Hash keys specified as Symbols are converted to lowerCamelCase Strings
19
+ # * Hash keys specified as Strings are not converted and may contain namespaces
20
+ # * DateTime values are converted to xs:dateTime Strings
21
+ # * Objects responding to to_datetime (except Strings) are converted to xs:dateTime Strings
22
+ # * TrueClass and FalseClass objects are converted to "true" and "false" Strings
23
+ # * All other objects are expected to be converted to Strings using to_s
24
+ #
25
+ # An example:
26
+ #
27
+ # { :magic_request => {
28
+ # :perform_move => true,
29
+ # "perform_at" => DateTime.new(2010, 11, 22, 11, 22, 33)
30
+ # }
31
+ # }.to_soap_xml
32
+ #
33
+ # <magicRequest>
34
+ # <performMove>true</performMove>
35
+ # <perform_at>2012-06-11T10:42:21</perform_at>
36
+ # </magicRequest>
37
+ #
38
+ # ==== :order!
21
39
  #
22
- # === Example:
40
+ # In case your service requires the tags to be in a specific order (parameterOrder), you have two
41
+ # options. The first is to specify your body as an XML string. The second is to specify the order
42
+ # through an additional array stored under the +:order!+ key.
23
43
  #
24
- # { :find_user => { :name => "Eve", :id => 123, :order! => [:id, :name] } }.to_soap_xml
25
- # # => "<findUser><id>123</id><name>Eve</name></findUser>"
44
+ # { :name => "Eve", :id => 123, :order! => [:id, :name] }.to_soap_xml
45
+ # # => "<id>123</id><name>Eve</name>"
26
46
  #
27
- # You can also specify attributes for XML tags by via an optional Hash under the :attributes! key.
47
+ # ==== :attributes!
28
48
  #
29
- # === Example:
49
+ # If you need attributes, you could either go with an XML string or add another hash under the
50
+ # +:attributes!+ key.
30
51
  #
31
- # { :find_user => { :person => "Eve", :attributes! => { :person => { :id => 123 } } } }
32
- # # => "<findUser><person id="123">Eve</person></findUser>"
52
+ # { :person => "Eve", :attributes! => { :person => { :id => 666 } } }.to_soap_xml
53
+ # # => '<person id="666">Eve</person>'
33
54
  def to_soap_xml
34
55
  xml = Builder::XmlMarkup.new
35
56
  attributes = delete(:attributes!) || {}
@@ -40,7 +61,7 @@ class Hash
40
61
  key = key.to_soap_key
41
62
 
42
63
  case value
43
- when Array then xml << value.to_soap_xml(key)
64
+ when Array then xml << value.to_soap_xml(key, attrs)
44
65
  when Hash then xml.tag!(key, attrs) { xml << value.to_soap_xml }
45
66
  else xml.tag!(key, attrs) { xml << value.to_soap_value }
46
67
  end
@@ -54,7 +75,7 @@ class Hash
54
75
  inject({}) do |hash, (key, value)|
55
76
  value = case value
56
77
  when Hash then value["xsi:nil"] ? nil : value.map_soap_response
57
- when Array then value.map { |a_value| a_value.map_soap_response rescue a_value }
78
+ when Array then value.map { |val| val.map_soap_response rescue val }
58
79
  when String then value.map_soap_response
59
80
  end
60
81
 
@@ -78,4 +99,4 @@ private
78
99
  order
79
100
  end
80
101
 
81
- end
102
+ end
@@ -6,8 +6,7 @@ module Net
6
6
  @address, @port = address, port
7
7
  end
8
8
 
9
- # Convenience method for setting SSL client authentication
10
- # through a Hash of +options+.
9
+ # Convenience method for setting SSL client authentication through a Hash of +options+.
11
10
  def ssl_client_auth(options)
12
11
  self.use_ssl = true
13
12
  self.cert = options[:cert] if options[:cert]
@@ -1,8 +1,6 @@
1
1
  class Object
2
2
 
3
- # Returns +true+ if the Object is false, empty, or a whitespace string.
4
- # For example, "", false, nil, [], and {} are blank.
5
- # Implementation from ActiveSupport.
3
+ # Returns +true+ if the Object is nil, false or empty. Implementation from ActiveSupport.
6
4
  def blank?
7
5
  respond_to?(:empty?) ? empty? : !self
8
6
  end unless defined? blank?
@@ -35,7 +35,7 @@ class String
35
35
  # Returns whether the String ends with a given +suffix+.
36
36
  def ends_with?(suffix)
37
37
  suffix = suffix.to_s
38
- self[-suffix.length, suffix.length] == suffix
38
+ self[-suffix.length, suffix.length] == suffix
39
39
  end unless defined? ends_with?
40
40
 
41
41
  # Returns the String without namespace.
@@ -52,8 +52,15 @@ class String
52
52
  end
53
53
 
54
54
  # Returns the String as a SOAP request compliant value.
55
+ # Escapes special characters for XML.
55
56
  def to_soap_value
56
- to_s
57
+ str = dup
58
+ str.gsub! "&", "&amp;"
59
+ str.gsub! '"', "&quot;"
60
+ str.gsub! "'", "&apos;"
61
+ str.gsub! "<", "&lt;"
62
+ str.gsub! ">", "&gt;"
63
+ str
57
64
  end
58
65
 
59
66
  end
File without changes
@@ -3,7 +3,7 @@ module URI
3
3
 
4
4
  # Returns whether the URI hints to SSL.
5
5
  def ssl?
6
- @scheme.starts_with? "https"
6
+ !@scheme ? nil : @scheme.starts_with?("https")
7
7
  end
8
8
 
9
9
  end
@@ -0,0 +1,56 @@
1
+ module Savon
2
+
3
+ # = Savon::Logger
4
+ #
5
+ # Savon::Logger can be mixed into classes to provide logging behavior.
6
+ #
7
+ # By default, the Logger mixin uses {Ruby's Logger}[http://ruby-doc.org/stdlib/libdoc/logger/rdoc/]
8
+ # from the standard library, a log level of :debug and is pointing to STDOUT.
9
+ module Logger
10
+
11
+ module ClassMethods
12
+
13
+ # Sets whether to log.
14
+ def log=(log)
15
+ @log = log
16
+ end
17
+
18
+ # Returns whether to log. Defaults to +true+.
19
+ def log?
20
+ @log != false
21
+ end
22
+
23
+ # Sets the logger.
24
+ def logger=(logger)
25
+ @logger = logger
26
+ end
27
+
28
+ # Returns the logger. Defaults to an instance of +Logger+ writing to STDOUT.
29
+ def logger
30
+ @logger ||= ::Logger.new STDOUT
31
+ end
32
+
33
+ # Sets the log level.
34
+ def log_level=(log_level)
35
+ @log_level = log_level
36
+ end
37
+
38
+ # Returns the log level. Defaults to +debug+.
39
+ def log_level
40
+ @log_level ||= :debug
41
+ end
42
+
43
+ end
44
+
45
+ # Extends the class including this module with its ClassMethods.
46
+ def self.included(base)
47
+ base.extend ClassMethods
48
+ end
49
+
50
+ # Logs a given +message+.
51
+ def log(message)
52
+ self.class.logger.send self.class.log_level, message if self.class.log?
53
+ end
54
+
55
+ end
56
+ end
@@ -1,52 +1,51 @@
1
1
  module Savon
2
2
 
3
- # == Savon::Request
3
+ # = Savon::Request
4
4
  #
5
- # Handles both WSDL and SOAP HTTP requests.
5
+ # Savon::Request handles both WSDL and SOAP requests.
6
+ #
7
+ # == The Net::HTTP object
8
+ #
9
+ # You can access the Net::HTTP object used for both WSDL and SOAP requests via:
10
+ #
11
+ # client.request.http
12
+ #
13
+ # Here's an example of how to set open and read timeouts on the Net::HTTP object.
14
+ #
15
+ # client.request.http.open_timeout = 30
16
+ # client.request.http.read_timeout = 30
17
+ #
18
+ # Please refer to the {Net::HTTP documentation}[http://ruby-doc.org/stdlib/libdoc/net/http/rdoc/]
19
+ # for more information.
20
+ #
21
+ # == HTTP basic authentication
22
+ #
23
+ # Setting credentials for HTTP basic authentication:
24
+ #
25
+ # client.request.basic_auth "username", "password"
26
+ #
27
+ # == SSL client authentication
28
+ #
29
+ # You can use the methods provided by Net::HTTP to set SSL client authentication or use a shortcut:
30
+ #
31
+ # client.request.http.ssl_client_auth(
32
+ # :cert => OpenSSL::X509::Certificate.new(File.read("client_cert.pem")),
33
+ # :key => OpenSSL::PKey::RSA.new(File.read("client_key.pem"), "password if one exists"),
34
+ # :ca_file => "cacert.pem",
35
+ # :verify_mode => OpenSSL::SSL::VERIFY_PEER
36
+ # )
37
+ #
38
+ # == HTTP headers
39
+ #
40
+ # There's an accessor for the Hash of HTTP headers sent with any SOAP call:
41
+ #
42
+ # client.request.headers["custom"] = "header"
6
43
  class Request
44
+ include Logger
7
45
 
8
46
  # Content-Types by SOAP version.
9
47
  ContentType = { 1 => "text/xml;charset=UTF-8", 2 => "application/soap+xml;charset=UTF-8" }
10
48
 
11
- # Whether to log HTTP requests.
12
- @@log = true
13
-
14
- # The default logger.
15
- @@logger = Logger.new STDOUT
16
-
17
- # The default log level.
18
- @@log_level = :debug
19
-
20
- # Sets whether to log HTTP requests.
21
- def self.log=(log)
22
- @@log = log
23
- end
24
-
25
- # Returns whether to log HTTP requests.
26
- def self.log?
27
- @@log
28
- end
29
-
30
- # Sets the logger.
31
- def self.logger=(logger)
32
- @@logger = logger
33
- end
34
-
35
- # Returns the logger.
36
- def self.logger
37
- @@logger
38
- end
39
-
40
- # Sets the log level.
41
- def self.log_level=(log_level)
42
- @@log_level = log_level
43
- end
44
-
45
- # Returns the log level.
46
- def self.log_level
47
- @@log_level
48
- end
49
-
50
49
  # Expects a SOAP +endpoint+ String. Also accepts an optional Hash
51
50
  # of +options+ for specifying a proxy server.
52
51
  def initialize(endpoint, options = {})
@@ -83,8 +82,7 @@ module Savon
83
82
  http.start { |h| h.request request(:wsdl) }
84
83
  end
85
84
 
86
- # Executes a SOAP request using a given Savon::SOAP instance and
87
- # returns the Net::HTTP response.
85
+ # Executes a SOAP request using a given Savon::SOAP instance and returns the Net::HTTP response.
88
86
  def soap(soap)
89
87
  @soap = soap
90
88
  http.endpoint @soap.endpoint.host, @soap.endpoint.port
@@ -118,8 +116,7 @@ module Savon
118
116
  log @response.body
119
117
  end
120
118
 
121
- # Returns a Net::HTTP request for a given +type+. Yields the request
122
- # to an optional block.
119
+ # Returns a Net::HTTP request for a given +type+. Yields the request to an optional block.
123
120
  def request(type)
124
121
  request = case type
125
122
  when :wsdl then Net::HTTP::Get.new @endpoint.request_uri
@@ -136,10 +133,5 @@ module Savon
136
133
  { "Content-Type" => ContentType[@soap.version], "SOAPAction" => @soap.action }
137
134
  end
138
135
 
139
- # Logs a given +message+.
140
- def log(message)
141
- self.class.logger.send self.class.log_level, message if self.class.log?
142
- end
143
-
144
136
  end
145
137
  end