1: <?php
2: 3: 4: 5: 6: 7: 8:
9:
10: class ShadePlus_ServiceServer
11: {
12: var $_mService;
13:
14: var $_mServer;
15:
16: function ShadePlus_ServiceServer(&$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: function prepare()
26: {
27: $this->_parseType();
28: $this->_parseFunction();
29: }
30:
31: function _parseType()
32: {
33:
34:
35:
36: foreach ($this->_mService->_mTypes as $className) {
37: if (XC_CLASS_EXISTS($className)) {
38: if (call_user_func(array($className, 'isArray')) == true) {
39: $targetClassName = call_user_func(array($className, 'getClassName'));
40:
41: if (XCube_ServiceUtils::isXSD($targetClassName)) {
42: $targetClassName = 'xsd:' . $targetClassName;
43: }
44: else {
45: $targetClassName = 'tns:' . $targetClassName;
46: }
47:
48: $this->_mServer->wsdl->addComplexType(
49: $className,
50: 'complexType',
51: 'array',
52: '',
53: 'SOAP-ENC:Array',
54: array(),
55: array(
56: array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => $targetClassName . '[]')
57: ),
58: $targetClassName
59: );
60: }
61: else {
62: $t_fieldArr = call_user_func(array($className, 'getPropertyDefinition'));
63: $t_arr = array();
64: foreach ($t_fieldArr as $t_field) {
65: $name = $t_field['name'];
66: $type = $t_field['type'];
67:
68: if (XCube_ServiceUtils::isXSD($t_field['type'])) {
69: $type = 'xsd:' . $type;
70: }
71: else {
72: $type = 'tns:' . $type;
73: }
74:
75: $t_arr[$name] = array('name' => $name, 'type' => $type);
76: }
77:
78: $this->_mServer->wsdl->addComplexType(
79: $className,
80: 'complexType',
81: 'struct',
82: 'all',
83: '',
84: $t_arr
85: );
86: }
87: }
88: }
89: }
90:
91: function _parseFunction()
92: {
93:
94:
95:
96: foreach ($this->_mService->_mFunctions as $func) {
97: if (XCube_ServiceUtils::isXSD($func['out'])) {
98: $t_out = 'xsd:' . $func['out'];
99: }
100: else {
101: $t_out = 'tns:' . $func['out'];
102: }
103:
104: $out['return'] = $t_out;
105:
106:
107:
108:
109: $in = array();
110: foreach ($func['in'] as $name => $type) {
111: if (XCube_ServiceUtils::isXSD($type)) {
112: $t_type = 'xsd:' . $type;
113: }
114: else {
115: $t_type = 'tns:' . $type;
116: }
117: $in[$name] = $t_type;
118: }
119:
120: $this->_mServer->register($this->_mService->mClassName . "." . $func['name'], $in, $out, $this->_mService->mNameSpace);
121: }
122: }
123:
124: function executeService()
125: {
126: $HTTP_RAW_POST_DATA = isset($GLOBALS['HTTP_RAW_POST_DATA'])? $GLOBALS['HTTP_RAW_POST_DATA'] : null;
127: $this->_mServer->service($HTTP_RAW_POST_DATA);
128: }
129: }
130:
131: ?>
132: