| 1 |
# SOAP4R - Compatibility definitions. |
|---|
| 2 |
# Copyright (C) 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. |
|---|
| 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 |
STDERR.puts "Loading compatibility library..." |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
require 'xsd/qname' |
|---|
| 13 |
require 'xsd/ns' |
|---|
| 14 |
require 'xsd/charset' |
|---|
| 15 |
require 'soap/mapping' |
|---|
| 16 |
require 'soap/rpc/rpc' |
|---|
| 17 |
require 'soap/rpc/element' |
|---|
| 18 |
require 'soap/rpc/driver' |
|---|
| 19 |
require 'soap/rpc/cgistub' |
|---|
| 20 |
require 'soap/rpc/router' |
|---|
| 21 |
require 'soap/rpc/standaloneServer' |
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
module SOAP |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
module RPC |
|---|
| 28 |
RubyTypeNamespace = Mapping::RubyTypeNamespace |
|---|
| 29 |
RubyTypeInstanceNamespace = Mapping::RubyTypeInstanceNamespace |
|---|
| 30 |
RubyCustomTypeNamespace = Mapping::RubyCustomTypeNamespace |
|---|
| 31 |
ApacheSOAPTypeNamespace = Mapping::ApacheSOAPTypeNamespace |
|---|
| 32 |
|
|---|
| 33 |
DefaultMappingRegistry = Mapping::DefaultRegistry |
|---|
| 34 |
|
|---|
| 35 |
def self.obj2soap(*arg); Mapping.obj2soap(*arg); end |
|---|
| 36 |
def self.soap2obj(*arg); Mapping.soap2obj(*arg); end |
|---|
| 37 |
def self.ary2soap(*arg); Mapping.ary2soap(*arg); end |
|---|
| 38 |
def self.ary2md(*arg); Mapping.ary2md(*arg); end |
|---|
| 39 |
def self.fault2exception(*arg); Mapping.fault2exception(*arg); end |
|---|
| 40 |
|
|---|
| 41 |
def self.defined_methods(obj) |
|---|
| 42 |
if obj.is_a?(Module) |
|---|
| 43 |
obj.methods - Module.methods |
|---|
| 44 |
else |
|---|
| 45 |
obj.methods - Kernel.instance_methods(true) |
|---|
| 46 |
end |
|---|
| 47 |
end |
|---|
| 48 |
end |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
NS = XSD::NS |
|---|
| 52 |
Charset = XSD::Charset |
|---|
| 53 |
RPCUtils = RPC |
|---|
| 54 |
RPCServerException = RPC::ServerException |
|---|
| 55 |
RPCRouter = RPC::Router |
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
class StandaloneServer < RPC::StandaloneServer |
|---|
| 59 |
def initialize(*arg) |
|---|
| 60 |
super |
|---|
| 61 |
@router = @soaplet.app_scope_router |
|---|
| 62 |
methodDef if respond_to?('methodDef') |
|---|
| 63 |
end |
|---|
| 64 |
|
|---|
| 65 |
alias addServant add_servant |
|---|
| 66 |
alias addMethod add_method |
|---|
| 67 |
alias addMethodAs add_method_as |
|---|
| 68 |
end |
|---|
| 69 |
|
|---|
| 70 |
|
|---|
| 71 |
class CGIStub < RPC::CGIStub |
|---|
| 72 |
def initialize(*arg) |
|---|
| 73 |
super |
|---|
| 74 |
methodDef if respond_to?('methodDef') |
|---|
| 75 |
end |
|---|
| 76 |
|
|---|
| 77 |
alias addServant add_servant |
|---|
| 78 |
|
|---|
| 79 |
def addMethod(receiver, methodName, *paramArg) |
|---|
| 80 |
addMethodWithNSAs(@default_namespace, receiver, methodName, methodName, *paramArg) |
|---|
| 81 |
end |
|---|
| 82 |
|
|---|
| 83 |
def addMethodAs(receiver, methodName, methodNameAs, *paramArg) |
|---|
| 84 |
addMethodWithNSAs(@default_namespace, receiver, methodName, methodNameAs, *paramArg) |
|---|
| 85 |
end |
|---|
| 86 |
|
|---|
| 87 |
def addMethodWithNS(namespace, receiver, methodName, *paramArg) |
|---|
| 88 |
addMethodWithNSAs(namespace, receiver, methodName, methodName, *paramArg) |
|---|
| 89 |
end |
|---|
| 90 |
|
|---|
| 91 |
def addMethodWithNSAs(namespace, receiver, methodName, methodNameAs, *paramArg) |
|---|
| 92 |
add_method_with_namespace_as(namespace, receiver, methodName, methodNameAs, *paramArg) |
|---|
| 93 |
end |
|---|
| 94 |
end |
|---|
| 95 |
|
|---|
| 96 |
|
|---|
| 97 |
class Driver < RPC::Driver |
|---|
| 98 |
include Logger::Severity |
|---|
| 99 |
|
|---|
| 100 |
attr_accessor :logdev |
|---|
| 101 |
alias logDev= logdev= |
|---|
| 102 |
alias logDev logdev |
|---|
| 103 |
alias setWireDumpDev wiredump_dev= |
|---|
| 104 |
alias setDefaultEncodingStyle default_encodingstyle= |
|---|
| 105 |
alias mappingRegistry= mapping_registry= |
|---|
| 106 |
alias mappingRegistry mapping_registry |
|---|
| 107 |
|
|---|
| 108 |
def initialize(log, logid, namespace, endpoint_url, httpproxy = nil, soapaction = nil) |
|---|
| 109 |
super(endpoint_url, namespace, soapaction) |
|---|
| 110 |
@logdev = log |
|---|
| 111 |
@logid = logid |
|---|
| 112 |
@logid_prefix = "<#{ @logid }> " |
|---|
| 113 |
self.httpproxy = httpproxy if httpproxy |
|---|
| 114 |
log(INFO) { 'initialize: initializing SOAP driver...' } |
|---|
| 115 |
end |
|---|
| 116 |
|
|---|
| 117 |
def invoke(headers, body) |
|---|
| 118 |
log(INFO) { "invoke: invoking message '#{ body.type }'." } |
|---|
| 119 |
super |
|---|
| 120 |
end |
|---|
| 121 |
|
|---|
| 122 |
def call(name, *params) |
|---|
| 123 |
log(INFO) { "call: calling method '#{ name }'." } |
|---|
| 124 |
log(DEBUG) { "call: parameters '#{ params.inspect }'." } |
|---|
| 125 |
log(DEBUG) { |
|---|
| 126 |
params = Mapping.obj2soap(params, @mapping_registry).to_a |
|---|
| 127 |
"call: parameters '#{ params.inspect }'." |
|---|
| 128 |
} |
|---|
| 129 |
super |
|---|
| 130 |
end |
|---|
| 131 |
|
|---|
| 132 |
def addMethod(name, *params) |
|---|
| 133 |
addMethodWithSOAPActionAs(name, name, nil, *params) |
|---|
| 134 |
end |
|---|
| 135 |
|
|---|
| 136 |
def addMethodAs(name_as, name, *params) |
|---|
| 137 |
addMethodWithSOAPActionAs(name_as, name, nil, *params) |
|---|
| 138 |
end |
|---|
| 139 |
|
|---|
| 140 |
def addMethodWithSOAPAction(name, soapaction, *params) |
|---|
| 141 |
addMethodWithSOAPActionAs(name, name, soapaction, *params) |
|---|
| 142 |
end |
|---|
| 143 |
|
|---|
| 144 |
def addMethodWithSOAPActionAs(name_as, name, soapaction, *params) |
|---|
| 145 |
add_method_with_soapaction_as(name, name_as, soapaction, *params) |
|---|
| 146 |
end |
|---|
| 147 |
|
|---|
| 148 |
def setLogDev(logdev) |
|---|
| 149 |
self.logdev = logdev |
|---|
| 150 |
end |
|---|
| 151 |
|
|---|
| 152 |
private |
|---|
| 153 |
|
|---|
| 154 |
def log(sev) |
|---|
| 155 |
@logdev.add(sev, nil, self.class) { @logid_prefix + yield } if @logdev |
|---|
| 156 |
end |
|---|
| 157 |
end |
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
module RPC |
|---|
| 161 |
class MappingRegistry < SOAP::Mapping::Registry |
|---|
| 162 |
def initialize(*arg) |
|---|
| 163 |
super |
|---|
| 164 |
end |
|---|
| 165 |
|
|---|
| 166 |
def add(obj_class, soap_class, factory, info = nil) |
|---|
| 167 |
if (info.size > 1) |
|---|
| 168 |
raise RuntimeError.new("Parameter signature changed. [namespace, name] should be { :type => XSD::QName.new(namespace, name) } from 1.5.0.") |
|---|
| 169 |
end |
|---|
| 170 |
@map.add(obj_class, soap_class, factory, { :type => info[0] }) |
|---|
| 171 |
end |
|---|
| 172 |
alias set add |
|---|
| 173 |
end |
|---|
| 174 |
|
|---|
| 175 |
class Router |
|---|
| 176 |
alias mappingRegistry mapping_registry |
|---|
| 177 |
alias mappingRegistry= mapping_registry= |
|---|
| 178 |
end |
|---|
| 179 |
end |
|---|
| 180 |
|
|---|
| 181 |
|
|---|
| 182 |
end |
|---|