handsoap 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION.yml +2 -1
  2. data/lib/handsoap/service.rb +27 -3
  3. metadata +6 -3
data/VERSION.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
- :patch: 1
3
2
  :major: 1
4
3
  :minor: 1
4
+ :patch: 2
5
+ :build:
@@ -25,30 +25,54 @@ module Handsoap
25
25
  @xml_query_driver = Handsoap::XmlQueryFront.load_driver!(driver)
26
26
  end
27
27
 
28
+ # Wraps SOAP errors in a standard class.
28
29
  class Fault < StandardError
29
30
  attr_reader :code, :reason, :details
31
+
30
32
  def initialize(code, reason, details)
31
33
  @code = code
32
34
  @reason = reason
33
35
  @details = details
34
36
  end
37
+
35
38
  def to_s
36
39
  "Handsoap::Fault { :code => '#{@code}', :reason => '#{@reason}' }"
37
40
  end
41
+
38
42
  def self.from_xml(node, options = { :namespace => nil })
39
43
  if not options[:namespace]
40
44
  raise "Missing option :namespace"
41
45
  end
46
+
42
47
  ns = { 'env' => options[:namespace] }
43
- fault_code = node.xpath('./env:Code/env:Value', ns).to_s
48
+
49
+ # tries to find SOAP1.2 fault code
50
+ fault_code = node.xpath("./env:Code/env:Value", ns).to_s
51
+
52
+ # if no SOAP1.2 fault code was found, try the SOAP1.1 way
44
53
  unless fault_code
45
54
  fault_code = node.xpath('./faultcode', ns).to_s
55
+
56
+ # if fault_code is blank, add the namespace and try again
57
+ unless fault_code
58
+ fault_code = node.xpath("//env:faultcode", ns).to_s
59
+ end
46
60
  end
47
- reason = node.xpath('./env:Reason/env:Text[1]', ns).to_s
61
+
62
+ # tries to find SOAP1.2 reason
63
+ reason = node.xpath("./env:Reason/env:Text[1]", ns).to_s
64
+
65
+ # if no SOAP1.2 faultstring was found, try the SOAP1.1 way
48
66
  unless reason
49
67
  reason = node.xpath('./faultstring', ns).to_s
68
+
69
+ # if reason is blank, add the namespace and try again
70
+ unless reason
71
+ reason = node.xpath("//env:faultstring", ns).to_s
72
+ end
50
73
  end
51
- details = node.xpath('./detail/*', ns)
74
+
75
+ details = node.xpath('./detail/*', ns)
52
76
  self.new(fault_code, reason, details)
53
77
  end
54
78
  end
metadata CHANGED
@@ -1,20 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handsoap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Troels Knak-Nielsen
8
+ - Jimmi Westerberg
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-10-15 00:00:00 +02:00
13
+ date: 2009-10-22 00:00:00 +02:00
13
14
  default_executable:
14
15
  dependencies: []
15
16
 
16
17
  description: Handsoap is a library for creating SOAP clients in Ruby
17
- email: troelskn@gmail.com
18
+ email:
19
+ - troelskn@gmail.com
20
+ - frontend@unwire.dk
18
21
  executables: []
19
22
 
20
23
  extensions: []