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 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
|
#!/usr/bin/env ruby
$:.unshift(".")
#$KCODE = "UTF8" # Set $KCODE before loading 'soap/xmlparser'.
#$KCODE = "EUC"
$KCODE = "SJIS"
require 'soap/rpc/standaloneServer'
require 'base'
require 'xsd/xmlparser/rexmlparser'
class InteropApp < SOAP::RPC::StandaloneServer
include SOAP
def initialize(*arg)
super(*arg)
self.mapping_registry = SOAPBuildersInterop::MappingRegistry
self.level = Logger::Severity::ERROR
end
def on_init
(SOAPBuildersInterop::MethodsBase + SOAPBuildersInterop::MethodsGroupB + SOAPBuildersInterop::MethodsPolyMorph).each do |name, *params|
add_method(self, name, params)
end
end
# In echoVoid, 'retval' is not defined. So nothing will be returned.
def echoVoid
return SOAP::RPC::SOAPVoid.new
end
def echoBoolean(inputBoolean)
inputBoolean
end
def echoString(inputString)
clone(inputString)
end
def echoStringArray(inputStringArray)
clone(inputStringArray)
end
def echoInteger(inputInteger)
SOAP::SOAPInt.new(clone(inputInteger))
end
def echoIntegerArray(inputIntegerArray)
clone(inputIntegerArray)
end
# Float is mapped to SOAPDouble by default.
def echoFloat(inputFloat)
SOAP::SOAPFloat.new(inputFloat)
end
def echoDecimal(inputDecimal)
SOAP::SOAPDecimal.new(clone(inputDecimal))
end
def echoFloatArray(inputFloatArray)
outArray = SOAPBuildersInterop::FloatArray.new
inputFloatArray.each do |f|
outArray << SOAPFloat.new(f)
end
outArray
end
def echoStruct(inputStruct)
clone_Struct(inputStruct)
end
def echoStructArray(inputStructArray)
clone_StructArray(inputStructArray)
end
def echoDate(inputDate)
clone(inputDate)
end
def echoBase64(inputBase64)
o = SOAP::SOAPBase64.new(clone(inputBase64))
o.as_xsd
o
end
def echoHexBinary(inputHexBinary)
SOAP::SOAPHexBinary.new(clone(inputHexBinary))
end
def echoDouble(inputDouble)
SOAP::SOAPDouble.new(inputDouble)
end
# for Round 2 group B
def echoStructAsSimpleTypes(inputStruct)
outputString = inputStruct.varString
outputInteger = inputStruct.varInt
outputFloat = inputStruct.varFloat ? SOAPFloat.new(inputStruct.varFloat) : nil
# retVal is not returned to SOAP client because retVal of this method is
# not defined in method definition.
# retVal, out, out, out
return nil, outputString, outputInteger, outputFloat
end
def echoSimpleTypesAsStruct(inputString, inputInt, inputFloat)
SOAPBuildersInterop::SOAPStruct.new(inputInt, inputFloat, inputString)
end
def echo2DStringArray(ary)
# In Ruby, M-D Array is converted to Array of Array now.
mdary = SOAP::Mapping.ary2md(ary, 2, XSD::Namespace, XSD::StringLiteral)
if mdary.include?(nil)
mdary.sparse = true
end
mdary
end
def echoNestedStruct(inputStruct)
clone_StructStruct(inputStruct)
end
def echoNestedArray(inputStruct)
clone_Struct(inputStruct)
end
def echoMap(inputMap)
clone(inputMap)
end
def echoMapArray(inputMapArray)
clone(inputMapArray)
end
def echoPolyMorph(anObject)
clone(anObject)
end
alias echoPolyMorphStruct echoPolyMorph
alias echoPolyMorphArray echoPolyMorph
def echoXSDBoolean(inputBoolean)
inputBoolean
end
def echoXSDString(inputString)
clone(inputString)
end
def echoXSDDecimal(inputDecimal)
SOAP::SOAPDecimal.new(clone(inputDecimal))
end
def echoXSDFloat(inputFloat)
SOAPFloat.new(inputFloat)
end
def echoXSDDouble(inputDouble)
SOAP::SOAPDouble.new(clone(inputDouble))
end
def echoXSDDuration(inputDuration)
SOAP::SOAPDuration.new(clone(inputDuration))
end
def echoXSDDateTime(inputXSDDateTime)
clone(inputXSDDateTime)
end
def echoXSDTime(inputXSDTime)
SOAP::SOAPTime.new(clone(inputXSDTime))
end
def echoXSDDate(inputXSDDate)
SOAP::SOAPDate.new(clone(inputXSDDate))
end
def echoXSDgYearMonth(inputGYearMonth)
SOAP::SOAPgYearMonth.new(clone(inputGYearMonth))
end
def echoXSDgYear(inputGYear)
SOAP::SOAPgYear.new(clone(inputGYear))
end
def echoXSDgMonthDay(inputGMonthDay)
SOAP::SOAPgMonthDay.new(clone(inputGMonthDay))
end
def echoXSDgDay(inputGDay)
SOAP::SOAPgDay.new(clone(inputGDay))
end
def echoXSDgMonth(inputGMonth)
SOAP::SOAPgMonth.new(clone(inputGMonth))
end
def echoXSDHexBinary(inputHexBinary)
SOAP::SOAPHexBinary.new(clone(inputHexBinary))
end
def echoXSDBase64(inputBase64)
o = SOAP::SOAPBase64.new(clone(inputBase64))
o.as_xsd
o
end
def echoXSDanyURI(inputAnyURI)
clone(inputAnyURI)
end
def echoXSDQName(inputQName)
SOAP::SOAPQName.new(clone(inputQName))
end
def echoXSDInteger(inputXSDInteger)
clone(inputXSDInteger)
end
def echoXSDLong(inputLong)
SOAP::SOAPLong.new(clone(inputLong))
end
def echoXSDInt(inputInt)
SOAP::SOAPInt.new(clone(inputInteger))
end
def echoPolyMorph(anObject)
clone(anObject)
end
alias echoPolyMorphStruct echoPolyMorph
alias echoPolyMorphArray echoPolyMorph
private
def clone(obj)
begin
return Marshal.load(Marshal.dump(obj))
rescue TypeError
return obj
end
end
def clone_Struct(struct)
result = clone(struct)
result.varFloat = SOAPFloat.new(struct.varFloat) if struct.varFloat
result
end
def clone_StructArray(structArray)
result = clone(structArray)
result.map { |ele|
ele.varFloat = SOAPFloat.new(ele.varFloat) if ele.varFloat
}
result
end
def clone_StructStruct(structStruct)
result = clone(structStruct)
result.varFloat = SOAPFloat.new(structStruct.varFloat) if structStruct.varFloat
if struct = result.varStruct
struct.varFloat = SOAPFloat.new(struct.varFloat) if struct.varFloat
end
result
end
end
if __FILE__ == $0
svr = InteropApp.new('InteropApp', InterfaceNS, '0.0.0.0', 10080)
trap("INT") { svr.shutdown }
svr.start
end
|