troelskn-handsoap 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +14 -8
- data/VERSION.yml +1 -1
- data/lib/handsoap/service.rb +18 -7
- data/lib/handsoap/xml_query_front.rb +1 -0
- metadata +2 -2
data/README.markdown
CHANGED
@@ -149,7 +149,7 @@ Put your service in a file under `app/models`. You should extend `Handsoap::Serv
|
|
149
149
|
|
150
150
|
You need to provide the endpoint and the SOAP version (1.1 or 1.2). If in doubt, use version 2.
|
151
151
|
|
152
|
-
A service usually has a namespace for describing the message-body ([RPC/Litteral style](http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/#N1011F)). You should set this in the `on_create_document` handler.
|
152
|
+
A service usually has a namespace for describing the message-body ([RPC/Litteral style](http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/#N1011F)). You should set this in the `on_create_document` handler. Likewise, the response returned *from* the server will contain elements that typically are defined in a single namespace relevant to the service. You can register this in the handler `on_response_document`.
|
153
153
|
|
154
154
|
A typical service looks like the following:
|
155
155
|
|
@@ -158,9 +158,15 @@ A typical service looks like the following:
|
|
158
158
|
|
159
159
|
class Example::FooService < Handsoap::Service
|
160
160
|
endpoint EXAMPLE_SERVICE_ENDPOINT
|
161
|
-
on_create_document
|
162
|
-
|
161
|
+
def on_create_document(doc)
|
162
|
+
# register namespaces for the request
|
163
|
+
doc.alias 'tns', "http://example.org/ws/spec"
|
163
164
|
end
|
165
|
+
def on_response_document(doc)
|
166
|
+
# register namespaces for the response
|
167
|
+
doc.add_namespace 'ns', 'http://example.org/ws/spec'
|
168
|
+
end
|
169
|
+
|
164
170
|
# public methods
|
165
171
|
# todo
|
166
172
|
|
@@ -198,10 +204,10 @@ You should use Ruby naming-conventions for methods names. If the method has side
|
|
198
204
|
Repeat code inside the invoke-block, should be refactored out to *builders*, and the response should be parsed with a *parser*.
|
199
205
|
|
200
206
|
def update_icon!(icon)
|
201
|
-
response = invoke("
|
207
|
+
response = invoke("tns:UpdateIcon") do |message|
|
202
208
|
build_icon!(message, icon)
|
203
209
|
end
|
204
|
-
parse_icon(response
|
210
|
+
parse_icon(response/"//icon").first)
|
205
211
|
end
|
206
212
|
|
207
213
|
|
@@ -220,7 +226,7 @@ It's recommended that you stick to the following style/naming scheme:
|
|
220
226
|
|
221
227
|
# xml -> icon
|
222
228
|
def parse_icon(node)
|
223
|
-
{ :href => node
|
229
|
+
{ :href => (node/"@href").to_s, :type => (node/"@type").to_s }
|
224
230
|
end
|
225
231
|
|
226
232
|
or, if you prefer, you can use a class to represent entities:
|
@@ -235,8 +241,8 @@ or, if you prefer, you can use a class to represent entities:
|
|
235
241
|
|
236
242
|
# xml -> icon
|
237
243
|
def parse_icon(node)
|
238
|
-
Icon.new :href => node
|
239
|
-
:type => node
|
244
|
+
Icon.new :href => (node/"@href").to_s,
|
245
|
+
:type => (node/"@type").to_s
|
240
246
|
end
|
241
247
|
|
242
248
|
License
|
data/VERSION.yml
CHANGED
data/lib/handsoap/service.rb
CHANGED
@@ -39,13 +39,13 @@ module Handsoap
|
|
39
39
|
raise "Missing option :namespace"
|
40
40
|
end
|
41
41
|
ns = { 'env' => options[:namespace] }
|
42
|
-
fault_code = node.xpath('./env:Code/env:Value
|
43
|
-
|
44
|
-
fault_code = node.xpath('./faultcode
|
42
|
+
fault_code = node.xpath('./env:Code/env:Value', ns).to_s
|
43
|
+
unless fault_code
|
44
|
+
fault_code = node.xpath('./faultcode', ns).to_s
|
45
45
|
end
|
46
|
-
reason = node.xpath('./env:Reason/env:Text[1]
|
47
|
-
|
48
|
-
reason = node.xpath('./faultstring
|
46
|
+
reason = node.xpath('./env:Reason/env:Text[1]', ns).to_s
|
47
|
+
unless reason
|
48
|
+
reason = node.xpath('./faultstring', ns).to_s
|
49
49
|
end
|
50
50
|
details = node.xpath('./detail/*', ns)
|
51
51
|
self.new(fault_code, reason, details)
|
@@ -410,7 +410,18 @@ module Handsoap
|
|
410
410
|
""
|
411
411
|
end
|
412
412
|
|
413
|
-
|
413
|
+
body.rewind
|
414
|
+
parts << {:head => head, :body => body.read(body.size)}
|
415
|
+
|
416
|
+
# if body.kind_of? ::StringIO
|
417
|
+
# parts << {:head => head, :body => body.string}
|
418
|
+
# elsif body.kind_of? ::Tempfile
|
419
|
+
# body.rewind
|
420
|
+
# parts << {:head => head, :body => body.read(body.size)}
|
421
|
+
# else
|
422
|
+
# raise "body must be StringIO or Tempfile"
|
423
|
+
# end
|
424
|
+
|
414
425
|
break if buf.size == 0
|
415
426
|
break if content_length == -1
|
416
427
|
end
|
@@ -28,6 +28,7 @@ module Handsoap
|
|
28
28
|
require 'rexml/document'
|
29
29
|
elsif driver == :nokogiri
|
30
30
|
require 'nokogiri'
|
31
|
+
gem('nokogiri') # work around bug in rubygems for Ruby 1.9
|
31
32
|
if Gem.loaded_specs['nokogiri'].version < Gem::Version.new('1.3.0')
|
32
33
|
raise "Incompatible version of Nokogiri. Please upgrade gem."
|
33
34
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: troelskn-handsoap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Troels Knak-Nielsen
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|