savon-xaop 0.7.2.6 → 0.7.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/savon/request.rb +16 -3
  2. data/lib/savon/wsdl.rb +14 -3
  3. metadata +7 -6
@@ -81,11 +81,24 @@ module Savon
81
81
  end
82
82
 
83
83
  # Retrieves WSDL document and returns the Net::HTTP response.
84
- def wsdl
84
+ def wsdl(retries = 0)
85
85
  log "Retrieving WSDL from: #{@endpoint}"
86
86
  http.endpoint @endpoint.host, @endpoint.port
87
87
  http.use_ssl = @endpoint.ssl?
88
- http.start { |h| h.request request(:wsdl) }
88
+ response = http.start { |h| h.request request(:wsdl) }
89
+ case response
90
+ when Net::HTTPFound, Net::HTTPMovedPermanently
91
+ puts "REDIRECT: #{@endpoint} -> #{response["location"]}"
92
+ @endpoint = URI response["location"]
93
+ if retries == 10
94
+ raise Savon::HTTPError.new("Redirect too long", {})
95
+ end
96
+ wsdl(retries + 1)
97
+ when Net::HTTPSuccess
98
+ response
99
+ else
100
+ raise Savon::HTTPError.new(response.body.to_s, response.to_hash)
101
+ end
89
102
  end
90
103
 
91
104
  # Executes a SOAP request using a given Savon::SOAP instance and
@@ -133,7 +146,7 @@ module Savon
133
146
  if @basic_auth
134
147
  request.basic_auth *@basic_auth
135
148
  elsif @ntlm_auth
136
- log "Using NTLM authentication"
149
+ require 'kconv'
137
150
  require 'net/ntlm_http'
138
151
  request.ntlm_auth *@ntlm_auth
139
152
  end
@@ -59,7 +59,11 @@ module Savon
59
59
  @stream = WSDLStream.new
60
60
  REXML::Document.parse_stream to_s, @stream
61
61
  end
62
- @stream
62
+ if @stream.sections.include? :service
63
+ @stream
64
+ else
65
+ raise Savon::HTTPError.new("Not a WSDL", {})
66
+ end
63
67
  end
64
68
 
65
69
  end
@@ -74,6 +78,7 @@ module Savon
74
78
 
75
79
  def initialize
76
80
  @depth, @operations = 0, {}
81
+ @sections = []
77
82
  end
78
83
 
79
84
  # Returns the namespace URI.
@@ -84,13 +89,19 @@ module Savon
84
89
 
85
90
  # Returns the SOAP endpoint.
86
91
  attr_reader :soap_endpoint
92
+
93
+ # Visited sections (used to check validaty of the WSDL)
94
+ attr_reader :sections
87
95
 
88
96
  # Hook method called when the stream parser encounters a starting tag.
89
97
  def tag_start(tag, attrs)
90
98
  @depth += 1
91
99
  tag = tag.strip_namespace
92
-
93
- @section = tag.to_sym if @depth <= 2 && Sections.include?(tag)
100
+
101
+ if @depth <= 2 && Sections.include?(tag)
102
+ @section = tag.to_sym
103
+ @sections << @section
104
+ end
94
105
  @namespace_uri ||= attrs["targetNamespace"] if @section == :definitions
95
106
  @soap_endpoint ||= URI(URI.escape(attrs["location"])) if @section == :service && tag == "address"
96
107
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon-xaop
3
3
  version: !ruby/object:Gem::Version
4
- hash: 115
4
+ hash: 113
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
9
  - 2
10
- - 6
11
- version: 0.7.2.6
10
+ - 7
11
+ version: 0.7.2.7
12
12
  platform: ruby
13
13
  authors:
14
14
  - Daniel Harrington
@@ -52,19 +52,20 @@ dependencies:
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
55
- name: ntlm-http
55
+ name: xaop-ntlm-http
56
56
  prerelease: false
57
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- hash: 25
62
+ hash: 71
63
63
  segments:
64
64
  - 0
65
65
  - 1
66
66
  - 1
67
- version: 0.1.1
67
+ - 2
68
+ version: 0.1.1.2
68
69
  type: :runtime
69
70
  version_requirements: *id003
70
71
  - !ruby/object:Gem::Dependency