Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

root/tags/RELEASE_1_5_8/bin/wsdl2ruby.rb

Revision 1928, 3.6 kB (checked in by nahi, 1 year ago)
  • added servletStubCreator. wsdl2ruby.rb with --servlet_stub creates servlet stub for WEBrick. closes #290.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to author date id revision
Line 
1 #!/usr/bin/env ruby
2
3 require 'getoptlong'
4 require 'logger'
5 require 'wsdl/soap/wsdl2ruby'
6
7
8 class WSDL2RubyApp < Logger::Application
9 private
10
11   OptSet = [
12     ['--wsdl','-w', GetoptLong::REQUIRED_ARGUMENT],
13     ['--module_path','-m', GetoptLong::REQUIRED_ARGUMENT],
14     ['--type','-t', GetoptLong::REQUIRED_ARGUMENT],
15     ['--classdef','-e', GetoptLong::OPTIONAL_ARGUMENT],
16     ['--mapping_registry','-r', GetoptLong::NO_ARGUMENT],
17     ['--client_skelton','-c', GetoptLong::OPTIONAL_ARGUMENT],
18     ['--servant_skelton','-s', GetoptLong::OPTIONAL_ARGUMENT],
19     ['--cgi_stub','-g', GetoptLong::OPTIONAL_ARGUMENT],
20     ['--servlet_stub','-l', GetoptLong::OPTIONAL_ARGUMENT],
21     ['--standalone_server_stub','-a', GetoptLong::OPTIONAL_ARGUMENT],
22     ['--driver','-d', GetoptLong::OPTIONAL_ARGUMENT],
23     ['--drivername_postfix','-n', GetoptLong::REQUIRED_ARGUMENT],
24     ['--force','-f', GetoptLong::NO_ARGUMENT],
25     ['--quiet','-q', GetoptLong::NO_ARGUMENT],
26   ]
27
28   def initialize
29     super('app')
30     STDERR.sync = true
31     self.level = Logger::FATAL
32   end
33
34   def run
35     @worker = WSDL::SOAP::WSDL2Ruby.new
36     @worker.logger = @log
37     location, opt = parse_opt(GetoptLong.new(*OptSet))
38     usage_exit unless location
39     @worker.location = location
40     if opt['quiet']
41       self.level = Logger::FATAL
42     else
43       self.level = Logger::INFO
44     end
45     @worker.opt.update(opt)
46     @worker.run
47     0
48   end
49
50   def usage_exit
51     puts <<__EOU__
52 Usage: #{ $0 } --wsdl wsdl_location [options]
53   wsdl_location: filename or URL
54
55 Example:
56   For server side:
57     #{ $0 } --wsdl myapp.wsdl --type server
58   For client side:
59     #{ $0 } --wsdl myapp.wsdl --type client
60
61 Options:
62   --wsdl wsdl_location
63   --type server|client
64     --type server implies;
65         --classdef --mapping_registry --servant_skelton --standalone_server_stub
66     --type client implies;
67         --classdef --mapping_registry --client_skelton --driver
68   --classdef [filenameprefix]
69   --mapping_registry
70   --client_skelton [servicename]
71   --servant_skelton [porttypename]
72   --cgi_stub [servicename]
73   --servlet_stub [servicename]
74   --standalone_server_stub [servicename]
75   --driver [porttypename]
76   --drivername_postfix driver_classname_postfix
77   --module_path Module::Path::Name
78   --force
79   --quiet
80
81 Terminology:
82   Client <-> Driver <-(SOAP)-> Stub <-> Servant
83
84   Driver and Stub: Automatically generated
85   Client and Servant: Skelton generated (you should change)
86 __EOU__
87     exit 1
88   end
89
90   def parse_opt(getoptlong)
91     opt = {}
92     wsdl = nil
93     begin
94       getoptlong.each do |name, arg|
95         case name
96         when "--wsdl"
97           wsdl = arg
98         when "--module_path"
99           opt['module_path'] = arg
100         when "--type"
101           case arg
102           when "server"
103             opt['classdef'] ||= nil
104             opt['mapping_registry'] ||= nil
105             opt['servant_skelton'] ||= nil
106             opt['standalone_server_stub'] ||= nil
107           when "client"
108             opt['classdef'] ||= nil
109             opt['mapping_registry'] ||= nil
110             opt['driver'] ||= nil
111             opt['client_skelton'] ||= nil
112           else
113             raise ArgumentError.new("Unknown type #{ arg }")
114           end
115         when "--classdef", "--mapping_registry",
116             "--client_skelton", "--servant_skelton",
117             "--cgi_stub", "--servlet_stub", "--standalone_server_stub",
118             "--driver"
119           opt[name.sub(/^--/, '')] = arg.empty? ? nil : arg
120         when "--drivername_postfix"
121           opt['drivername_postfix'] = arg
122         when "--force"
123           opt['force'] = true
124         when "--quiet"
125           opt['quiet'] = true
126         else
127           raise ArgumentError.new("Unknown type #{ arg }")
128         end
129       end
130     rescue
131       usage_exit
132     end
133     return wsdl, opt
134   end
135 end
136
137 WSDL2RubyApp.new.start
Note: See TracBrowser for help on using the browser.