1: <?php
2: 3: 4: 5: 6: 7:
8:
9: error_reporting(0);
10:
11:
12:
13: if (version_compare(PHP_VERSION, "5.0", ">=")) {
14: if (!class_exists("soap_server", false)) {
15: exit();
16: }
17: }
18: else {
19: if (!class_exists("soap_server")) {
20: exit();
21: }
22: }
23:
24: class ShadeSoap_NusoapServer extends soap_server
25: {
26: function invoke_method() {
27: $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
28:
29: if ($this->wsdl) {
30: if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
31: $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
32: $this->appendDebug('opData=' . $this->varDump($this->opData));
33: } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
34:
35: $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
36: $this->appendDebug('opData=' . $this->varDump($this->opData));
37: $this->methodname = $this->opData['name'];
38: } else {
39: $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
40: $this->fault('Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
41: return;
42: }
43: } else {
44: $this->debug('in invoke_method, no WSDL to validate method');
45: }
46:
47:
48:
49:
50: $class = '';
51: $method = '';
52: if (strpos($this->methodname, '..') > 0) {
53: $delim = '..';
54: } else if (strpos($this->methodname, '.') > 0) {
55: $delim = '.';
56: } else {
57: $delim = '';
58: }
59:
60: if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
61: XC_CLASS_EXISTS(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
62:
63: $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
64: $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
65: $this->debug("in invoke_method, class=$class method=$method delim=$delim");
66: }
67:
68:
69: if ($class == '') {
70: if (!function_exists($this->methodname)) {
71: $this->debug("in invoke_method, function '$this->methodname' not found!");
72: $this->result = 'fault: method not found';
73: $this->fault('Client',"method '$this->methodname' not defined in service");
74: return;
75: }
76: } else {
77: $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
78: if (!in_array($method_to_compare, get_class_methods($class))) {
79: $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
80: $this->result = 'fault: method not found';
81: $this->fault('Client',"method '$this->methodname' not defined in service");
82: return;
83: }
84: }
85:
86:
87:
88: if(! $this->verify_method($this->methodname,$this->methodparams)){
89:
90: $this->debug('ERROR: request not verified against method signature');
91: $this->result = 'fault: request failed validation against method signature';
92:
93: $this->fault('Client',"Operation '$this->methodname' not defined in service.");
94: return;
95: }
96:
97:
98: $this->debug('in invoke_method, params:');
99: $this->appendDebug($this->varDump($this->methodparams));
100: $this->debug("in invoke_method, calling '$this->methodname'");
101:
102: if ($class == '') {
103: $this->debug('in invoke_method, calling function using call_user_func_array()');
104: $call_arg = "$this->methodname";
105: } elseif ($delim == '..') {
106: $this->debug('in invoke_method, calling class method using call_user_func_array()');
107: $call_arg = array ($class, $method);
108: } else {
109: $this->debug('in invoke_method, calling instance method using call_user_func_array()');
110: $instance = new $class ();
111: $call_arg = array(&$instance, $method);
112: }
113:
114:
115:
116:
117: $root =& XCube_Root::getSingleton();
118:
119: $retValue = call_user_func_array($call_arg, array($root->mContext->mUser, $this->methodparams));
120:
121: if (is_array($retValue)) {
122: $retValue = $this->_encodeUTF8($retValue, $root->mLanguageManager);
123: }
124: else {
125: $retValue = $root->mLanguageManager->encodeUTF8($retValue);
126: }
127:
128: $this->methodreturn = $retValue;
129:
130: $this->debug('in invoke_method, methodreturn:');
131: $this->appendDebug($this->varDump($this->methodreturn));
132: $this->debug("in invoke_method, called method $this->methodname, received $this->methodreturn of type ".gettype($this->methodreturn));
133: }
134:
135: function _encodeUTF8($arr, &$languageManager)
136: {
137: foreach (array_keys($arr) as $key) {
138: if (is_array($arr[$key])) {
139: $arr[$key] = $this->_encodeUTF8($arr[$key], $languageManager);
140: }
141: else {
142: $arr[$key] = $languageManager->encodeUTF8($arr[$key]);
143: }
144: }
145:
146: return $arr;
147: }
148: }
149:
150:
151: ?>
152: