source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/wsdl/soap/clientSkeltonCreator.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 1.7 KB
Line 
1# WSDL4R - Creating client skelton code from WSDL.
2# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <[email protected]>.
3
4# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
5# redistribute it and/or modify it under the same terms of Ruby's license;
6# either the dual license version in 2003, or any later version.
7
8
9require 'wsdl/info'
10require 'wsdl/soap/classDefCreatorSupport'
11
12
13module WSDL
14module SOAP
15
16
17class ClientSkeltonCreator
18 include ClassDefCreatorSupport
19
20 attr_reader :definitions
21
22 def initialize(definitions)
23 @definitions = definitions
24 end
25
26 def dump(service_name)
27 result = ""
28 @definitions.service(service_name).ports.each do |port|
29 result << dump_porttype(port.porttype.name)
30 result << "\n"
31 end
32 result
33 end
34
35private
36
37 def dump_porttype(name)
38 drv_name = create_class_name(name)
39
40 result = ""
41 result << <<__EOD__
42endpoint_url = ARGV.shift
43obj = #{ drv_name }.new(endpoint_url)
44
45# run ruby with -d to see SOAP wiredumps.
46obj.wiredump_dev = STDERR if $DEBUG
47
48__EOD__
49 @definitions.porttype(name).operations.each do |operation|
50 result << dump_method_signature(operation)
51 result << dump_input_init(operation.input) << "\n"
52 result << dump_operation(operation) << "\n\n"
53 end
54 result
55 end
56
57 def dump_operation(operation)
58 name = operation.name
59 input = operation.input
60 "puts obj.#{ safemethodname(name.name) }#{ dump_inputparam(input) }"
61 end
62
63 def dump_input_init(input)
64 result = input.find_message.parts.collect { |part|
65 safevarname(part.name)
66 }.join(" = ")
67 if result.empty?
68 ""
69 else
70 result << " = nil"
71 end
72 result
73 end
74end
75
76
77end
78end
Note: See TracBrowser for help on using the repository browser.