XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
ServiceServer.class.php
1<?php
9
11{
12 public $_mService;
13
14 public $_mServer;
15
16 public function __construct(&$service)
17 {
18 $this->_mService =& $service;
19 $this->_mServer =new ShadeSoap_NusoapServer();
20
21 $this->_mServer->configureWSDL($this->_mService->mServiceName, $this->_mService->mNameSpace);
22 $this->_mServer->wsdl->schemaTargetNamespace = $this->_mService->mNameSpace;
23 }
24
25 public function prepare()
26 {
27 $this->_parseType();
28 $this->_parseFunction();
29 }
30
31 public function _parseType()
32 {
33 //
34 // FIXME
35 //
36 foreach ($this->_mService->_mTypes as $className) {
37 if (XC_CLASS_EXISTS($className)) {
38 if (true == call_user_func([$className, 'isArray'])) {
39 $targetClassName = call_user_func([$className, 'getClassName']);
40
41 if (XCube_ServiceUtils::isXSD($targetClassName)) {
42 $targetClassName = 'xsd:' . $targetClassName;
43 } else {
44 $targetClassName = 'tns:' . $targetClassName;
45 }
46
47 $this->_mServer->wsdl->addComplexType(
48 $className,
49 'complexType',
50 'array',
51 '',
52 'SOAP-ENC:Array',
53 [],
54 [
55 ['ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => $targetClassName . '[]']
56 ],
57 $targetClassName
58 );
59 } else {
60 $t_fieldArr = call_user_func([$className, 'getPropertyDefinition']);
61 $t_arr = [];
62 foreach ($t_fieldArr as $t_field) {
63 $name = $t_field['name'];
64 $type = $t_field['type'];
65
66 if (XCube_ServiceUtils::isXSD($t_field['type'])) {
67 $type = 'xsd:' . $type;
68 } else {
69 $type = 'tns:' . $type;
70 }
71
72 $t_arr[$name] = ['name' => $name, 'type' => $type];
73 }
74
75 $this->_mServer->wsdl->addComplexType(
76 $className,
77 'complexType',
78 'struct',
79 'all',
80 '',
81 $t_arr
82 );
83 }
84 }
85 }
86 }
87
88 public function _parseFunction()
89 {
90 //
91 // FIXME
92 //
93 foreach ($this->_mService->_mFunctions as $func) {
94 if (XCube_ServiceUtils::isXSD($func['out'])) {
95 $t_out = 'xsd:' . $func['out'];
96 } else {
97 $t_out = 'tns:' . $func['out'];
98 }
99
100 $out['return'] = $t_out;
101
102 //
103 // Parse IN
104 //
105 $in = [];
106 foreach ($func['in'] as $name => $type) {
107 if (XCube_ServiceUtils::isXSD($type)) {
108 $t_type = 'xsd:' . $type;
109 } else {
110 $t_type = 'tns:' . $type;
111 }
112 $in[$name] = $t_type;
113 }
114
115 $this->_mServer->register($this->_mService->mClassName . '.' . $func['name'], $in, $out, $this->_mService->mNameSpace);
116 }
117 }
118
119 public function executeService()
120 {
121 $postdata = file_get_contents('php://input');
122 //$HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : null;
123 $this->_mServer->service($postdata);
124 //Instead php://input should be used.
125 //PHP Code:
126 //file_get_contents("php://input");
127 }
128}