1 | # WSDL4R - Creating servant skelton code from WSDL.
|
---|
2 | # Copyright (C) 2002, 2003, 2005 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 |
|
---|
9 | require 'wsdl/info'
|
---|
10 | require 'wsdl/soap/classDefCreatorSupport'
|
---|
11 | require 'xsd/codegen'
|
---|
12 |
|
---|
13 |
|
---|
14 | module WSDL
|
---|
15 | module SOAP
|
---|
16 |
|
---|
17 |
|
---|
18 | class ServantSkeltonCreator
|
---|
19 | include ClassDefCreatorSupport
|
---|
20 | include XSD::CodeGen::GenSupport
|
---|
21 |
|
---|
22 | attr_reader :definitions
|
---|
23 |
|
---|
24 | def initialize(definitions)
|
---|
25 | @definitions = definitions
|
---|
26 | end
|
---|
27 |
|
---|
28 | def dump(porttype = nil)
|
---|
29 | if porttype.nil?
|
---|
30 | result = ""
|
---|
31 | @definitions.porttypes.each do |type|
|
---|
32 | result << dump_porttype(type.name)
|
---|
33 | result << "\n"
|
---|
34 | end
|
---|
35 | else
|
---|
36 | result = dump_porttype(porttype)
|
---|
37 | end
|
---|
38 | result
|
---|
39 | end
|
---|
40 |
|
---|
41 | private
|
---|
42 |
|
---|
43 | def dump_porttype(name)
|
---|
44 | class_name = create_class_name(name)
|
---|
45 | c = XSD::CodeGen::ClassDef.new(class_name)
|
---|
46 | operations = @definitions.porttype(name).operations
|
---|
47 | operations.each do |operation|
|
---|
48 | name = safemethodname(operation.name.name)
|
---|
49 | input = operation.input
|
---|
50 | params = input.find_message.parts.collect { |part|
|
---|
51 | safevarname(part.name)
|
---|
52 | }
|
---|
53 | m = XSD::CodeGen::MethodDef.new(name, params) do <<-EOD
|
---|
54 | p [#{params.join(", ")}]
|
---|
55 | raise NotImplementedError.new
|
---|
56 | EOD
|
---|
57 | end
|
---|
58 | m.comment = dump_method_signature(operation)
|
---|
59 | c.add_method(m)
|
---|
60 | end
|
---|
61 | c.dump
|
---|
62 | end
|
---|
63 | end
|
---|
64 |
|
---|
65 |
|
---|
66 | end
|
---|
67 | end
|
---|