File: driver.rb

package info (click to toggle)
ruby-soap4r 2.0.5-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,032 kB
  • sloc: ruby: 52,729; xml: 266; sh: 42; javascript: 20; makefile: 13; perl: 10
file content (183 lines) | stat: -rw-r--r-- 8,090 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
require 'classDef'
require 'soap/proxy'
require 'soap/rpcUtils'
require 'soap/streamHandler'

class Sm11PortType
  MappingRegistry = SOAP::RPCUtils::MappingRegistry.new
  
  MappingRegistry.set(
    C_struct,
    ::SOAP::SOAPStruct,
    ::SOAP::RPCUtils::MappingRegistry::TypedStructFactory,
    [ "http://dopg.gr.jp/sm11.xsd", "C_struct" ]
  )
  MappingRegistry.set(
    ArrayOfboolean,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "boolean" ]
  )
  MappingRegistry.set(
    ArrayOfshort,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "short" ]
  )
  MappingRegistry.set(
    ArrayOfint,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "int" ]
  )
  MappingRegistry.set(
    ArrayOflong,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "long" ]
  )
  MappingRegistry.set(
    ArrayOffloat,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "float" ]
  )
  MappingRegistry.set(
    ArrayOfdouble,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "double" ]
  )
  MappingRegistry.set(
    ArrayOfstring,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://www.w3.org/2001/XMLSchema", "string" ]
  )
  MappingRegistry.set(
    F_struct,
    ::SOAP::SOAPStruct,
    ::SOAP::RPCUtils::MappingRegistry::TypedStructFactory,
    [ "http://dopg.gr.jp/sm11.xsd", "F_struct" ]
  )
  MappingRegistry.set(
    ArrayOfC_struct,
    ::SOAP::SOAPArray,
    ::SOAP::RPCUtils::MappingRegistry::TypedArrayFactory,
    [ "http://dopg.gr.jp/sm11.xsd", "C_struct" ]
  )
  
  Methods = [
    [ "op0", "op0", [  ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op1", "op1", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op4", "op4", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op5", "op5", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op6", "op6", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op7", "op7", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op8", "op8", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op9", "op9", [ [ :in, "arg0" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op11", "op11", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op14", "op14", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op15", "op15", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op16", "op16", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op17", "op17", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op18", "op18", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op19", "op19", [ [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op21", "op21", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op24", "op24", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op25", "op25", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op26", "op26", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op27", "op27", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op28", "op28", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op29", "op29", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op30", "op30", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op31", "op31", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op34", "op34", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op35", "op35", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op36", "op36", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op37", "op37", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op38", "op38", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op39", "op39", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op40", "op40", [ [ :in, "arg0" ], [ :in, "arg1" ], [ :in, "arg2" ], [ :in, "arg3" ], [ :in, "arg4" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op41", "op41", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op42", "op42", [ [ :in, "arg0" ], [ :retval, "result" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "op43", "op43", [ [ :in, "arg0" ], [ :in, "arg1" ] ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "excop1", "excop1", [  ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "excop2", "excop2", [  ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "excop3", "excop3", [  ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ],
    [ "excop4", "excop4", [  ], "http://dopg.gr.jp/sm11", "http://dopg.gr.jp/sm11" ]
  ]

  attr_reader :endpointUrl
  attr_reader :proxyUrl

  def initialize( endpointUrl, proxyUrl = nil )
    @endpointUrl = endpointUrl
    @proxyUrl = proxyUrl
    @httpStreamHandler = SOAP::HTTPPostStreamHandler.new( @endpointUrl,
      @proxyUrl )
    @proxy = SOAP::SOAPProxy.new( nil, @httpStreamHandler, nil )
    @proxy.allowUnqualifiedElement = true
    @mappingRegistry = MappingRegistry
    addMethod
  end

  def setWireDumpDev( dumpDev )
    @httpStreamHandler.dumpDev = dumpDev
  end

  def setDefaultEncodingStyle( encodingStyle )
    @proxy.defaultEncodingStyle = encodingStyle
  end

  def getDefaultEncodingStyle
    @proxy.defaultEncodingStyle
  end

  def call( methodName, *params )
    # Convert parameters
    params.collect! { | param |
      SOAP::RPCUtils.obj2soap( param, @mappingRegistry )
    }

    # Then, call @proxy.call like the following.
    header, body = @proxy.call( nil, methodName, *params )

    # Check Fault.
    begin
      @proxy.checkFault( body )
    rescue SOAP::FaultError => e
      SOAP::RPCUtils.fault2exception( e, @mappingRegistry )
    end

    ret = body.response ?
      SOAP::RPCUtils.soap2obj( body.response, @mappingRegistry ) : nil
    if body.outParams
      outParams = body.outParams.collect { | outParam |
	SOAP::RPCUtils.soap2obj( outParam )
      }
      return [ ret ].concat( outParams )
    else
      return ret
    end
  end

private 

  def addMethod
    Methods.each do | methodNameAs, methodName, params, soapAction, namespace |
      @proxy.addMethodAs( methodNameAs, methodName, params, soapAction,
	namespace )
      addMethodInterface( methodNameAs, params )
    end
  end

  def addMethodInterface( name, params )
    self.instance_eval <<-EOD
      def #{ name }( *params )
	call( "#{ name }", *params )
      end
    EOD
  end
end