savon 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,25 +1,25 @@
1
- h1. Savon
1
+ h2. Savon
2
2
 
3
3
  p. Savon can be installed as a gem via:
4
4
 
5
5
  bc. $ gem install savon
6
6
 
7
- h3. Dependencies
7
+ h4. Dependencies
8
8
 
9
9
  bc. builder >= 2.1.2
10
10
  crack >= 0.1.4
11
11
 
12
12
  h2. Warning
13
13
 
14
- p. To use a heavy metal library like this, you have to be familiar with SOAP, WSDL and tools like soapUI.
14
+ p. To use this heavy metal library, you should be familiar with SOAP, WSDL and tools like soapUI.
15
15
 
16
- h2. First step
16
+ h2. Instantiate Savon::Client
17
17
 
18
18
  p. Instantiate a new instance of Savon::Client, passing in the WSDL of your service.
19
19
 
20
20
  bc. proxy = Savon::Client.new "http://example.com/UserService?wsdl"
21
21
 
22
- h3. The WSDL
22
+ h2. The WSDL
23
23
 
24
24
  p. You can find out about the SOAP actions available on the webservice by using the WSDL object.
25
25
 
@@ -28,7 +28,7 @@ bc. proxy.wsdl.soap_actions
28
28
 
29
29
  p. Find out more about the "WSDL":http://wiki.github.com/rubiii/savon/wsdl object.
30
30
 
31
- h3. Calling a SOAP action
31
+ h2. Calling a SOAP action
32
32
 
33
33
  p. Now, assuming your service applies to the default "Options":http://wiki.github.com/rubiii/savon/options, you can just call any available SOAP action.
34
34
 
@@ -36,7 +36,7 @@ bc. response = proxy.get_all_users
36
36
 
37
37
  p. Savon lets you call SOAP actions using snake_case, because even though they will propably be written in lowerCamelCase or CamelCase, it just feels much more natural.
38
38
 
39
- h3. Parameters
39
+ h2. Parameters
40
40
 
41
41
  p. Specifying parameters for the SOAP service, can be done by simply passing a Hash to the SOAP action.
42
42
 
@@ -44,18 +44,18 @@ bc. response = proxy.get_user_by_id :id => 666
44
44
 
45
45
  p. Learn more about [[Parameters]].
46
46
 
47
- h3. The response
47
+ h2. The response
48
48
 
49
49
  p. By default, the SOAP response is translated into a Hash. Take a look at the "Options":http://wiki.github.com/rubiii/savon/options for more information.
50
50
 
51
51
  bc. proxy.get_user_by_id :id => 666
52
52
  => { :user_response => { :id => "666", :username => "gorilla" } }
53
53
 
54
- h3. HTTP errors and SOAP faults
54
+ h2. HTTP errors and SOAP faults
55
55
 
56
56
  p. Savon raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError in case of an HTTP error. More information about "Errors":http://wiki.github.com/rubiii/savon/errors.
57
57
 
58
- h3. Logging
58
+ h2. Logging
59
59
 
60
60
  p. By default Savon logs each request and response to STDOUT. Specifying your own logger is as easy as it gets:
61
61
 
@@ -63,6 +63,6 @@ bc. Savon::Request.logger = RAILS_DEFAULT_LOGGER
63
63
 
64
64
  Read more about "Logging":http://wiki.github.com/rubiii/savon/logging.
65
65
 
66
- h3. RDoc and Wiki
66
+ h2. RDoc and Wiki
67
67
 
68
68
  p. Further information: "Wiki":http://wiki.github.com/rubiii/savon and "RDoc":http://rdoc.info/projects/rubiii/savon
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.5.2
@@ -6,6 +6,7 @@ class String
6
6
  str.gsub! /::/, '/'
7
7
  str.gsub! /([A-Z]+)([A-Z][a-z])/, '\1_\2'
8
8
  str.gsub! /([a-z\d])([A-Z])/, '\1_\2'
9
+ str.tr! ".", "_"
9
10
  str.tr! "-", "_"
10
11
  str.downcase!
11
12
  str
@@ -1,7 +1,7 @@
1
1
  class UserFixture
2
2
 
3
3
  @namespace_uri = "http://v1_0.ws.user.example.com"
4
- @soap_actions = { :find_user => "findUser" }
4
+ @soap_actions = { :user_find_by_id => "User.FindById", :find_user => "findUser" }
5
5
 
6
6
  @datetime_string = "2010-11-22T11:22:33"
7
7
  @datetime_object = DateTime.parse @datetime_string
@@ -15,11 +15,13 @@
15
15
  xmlns:tns="http://v1_0.ws.user.example.com"
16
16
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
17
17
  <xs:element name="findUser" type="tns:findUser" />
18
+ <xs:element name="User.FindById" type="tns:findUser" />
18
19
  <xs:element name="findUserRequest" type="tns:findUserRequest" />
19
20
  <xs:element name="baseFindUserRequest" type="tns:baseFindUserRequest" />
20
21
  <xs:element name="idCredential" type="tns:idCredential" />
21
22
  <xs:element name="emailCredential" type="tns:emailCredential" />
22
23
  <xs:element name="findUserResponse" type="tns:findUserResponse" />
24
+ <xs:element name="User.FindByIdResponse" type="tns:findUserResponse" />
23
25
  <xs:element name="userResponse" type="tns:userResponse" />
24
26
 
25
27
  <xs:complexType name="findUser">
@@ -78,6 +80,13 @@
78
80
  <wsdl:part element="tns:findUserResponse" name="parameters"></wsdl:part>
79
81
  </wsdl:message>
80
82
 
83
+ <wsdl:message name="User.FindById">
84
+ <wsdl:part element="tns:findUser" name="parameters"></wsdl:part>
85
+ </wsdl:message>
86
+ <wsdl:message name="User.FindByIdResponse">
87
+ <wsdl:part element="tns:findUserResponse" name="parameters"></wsdl:part>
88
+ </wsdl:message>
89
+
81
90
  <wsdl:portType name="UserWebService">
82
91
  <wsdl:operation name="findUser">
83
92
  <wsdl:input message="tns:findUser" name="findUser"></wsdl:input>
@@ -95,6 +104,15 @@
95
104
  <wsdl:output name="findUserResponse">
96
105
  <soap:body use="literal" />
97
106
  </wsdl:output>
107
+ </wsdl:operation>
108
+ <wsdl:operation name="User.FindById">
109
+ <soap:operation soapAction="" style="document" />
110
+ <wsdl:input name="User.FindById">
111
+ <soap:body use="literal" />
112
+ </wsdl:input>
113
+ <wsdl:output name="User.FindByIdResponse">
114
+ <soap:body use="literal" />
115
+ </wsdl:output>
98
116
  </wsdl:operation>
99
117
  </wsdl:binding>
100
118
 
@@ -28,6 +28,42 @@ describe Savon::Client do
28
28
  end
29
29
  end
30
30
 
31
+ describe "@error_handling" do
32
+ before { @error_handling = Savon::Client.error_handling }
33
+
34
+ it "raises a Savon::SOAPFault in case it finds a SOAP fault" do
35
+ body = { "soapenv:Fault" => {
36
+ "faultcode" => "soap:Server",
37
+ "faultstring" => "Fault occurred while processing."
38
+ } }
39
+
40
+ lambda { @error_handling.call(http_response_mock, body) }.
41
+ should raise_error Savon::SOAPFault
42
+ end
43
+
44
+ it "raises a Savon::SOAPFault in case it finds both HTTPError and SOAP fault" do
45
+ body = { "soapenv:Fault" => {
46
+ "faultcode" => "soap:Server",
47
+ "faultstring" => "Fault occurred while processing."
48
+ } }
49
+
50
+ lambda { @error_handling.call(http_response_mock(500), body) }.
51
+ should raise_error Savon::SOAPFault
52
+ end
53
+
54
+ it "raises a Savon::HTTPError in case it finds an HTTP error" do
55
+ body = { "someResponse" => "whatever" }
56
+
57
+ lambda { @error_handling.call(http_response_mock(404), body) }.
58
+ should raise_error Savon::HTTPError
59
+ end
60
+
61
+ it "passes without raising anything otherwise" do
62
+ body = { "someResponse" => "whatever" }
63
+ @error_handling.call(http_response_mock, body).should be_nil
64
+ end
65
+ end
66
+
31
67
  describe "initialize" do
32
68
  it "expects a SOAP endpoint String" do
33
69
  new_client_instance
@@ -132,13 +168,11 @@ describe Savon::Client do
132
168
  end
133
169
  end
134
170
 
135
- def http_response_mock
136
- unless @http_response_mock
137
- @http_response_mock = mock "Net::HTTPResponse"
138
- @http_response_mock.stubs :code => "200", :message => "OK",
171
+ def http_response_mock(code = 200)
172
+ http_response_mock = mock "Net::HTTPResponse"
173
+ http_response_mock.stubs :code => code.to_s, :message => "OK",
139
174
  :content_type => "text/html", :body => UserFixture.user_response
140
- end
141
- @http_response_mock
175
+ http_response_mock
142
176
  end
143
177
 
144
178
  end
@@ -6,6 +6,10 @@ describe String do
6
6
  it "converts a lowerCamelCase String to snakecase" do
7
7
  "lowerCamelCase".snakecase.should == "lower_camel_case"
8
8
  end
9
+
10
+ it "converts period characters to underscores" do
11
+ "User.GetEmail".snakecase.should == "user_get_email"
12
+ end
9
13
  end
10
14
 
11
15
  describe "lower_camelcase" do
@@ -22,7 +22,7 @@ describe Savon::WSDL do
22
22
  end
23
23
 
24
24
  describe "mapped_soap_actions" do
25
- it "returns a Hash containing all available SOAP actions and their original names" do
25
+ it "returns a Hash containing all available SOAP actions and their original names" do
26
26
  @wsdl.mapped_soap_actions.should == UserFixture.soap_actions
27
27
  end
28
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: savon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Harrington
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-29 00:00:00 +01:00
12
+ date: 2009-11-30 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency