-
Notifications
You must be signed in to change notification settings - Fork 2
/
CalemSoapService.php
78 lines (73 loc) · 3.01 KB
/
CalemSoapService.php
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
<?php
/*
* The contents of this file are subject to the CalemEAM Public License Version
* 1.0 ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.calemeam.com/license
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is: CalemEAM Open Source
*
* The Initial Developer of the Original Code is CalemEAM Inc.
* Portions created by CalemEAM are Copyright (C) 2007 CalemEAM Inc.;
* All Rights Reserved.
* Contributor(s):
*/
/**
* This is the SOAP service entry.
*/
if (!defined('_CALEM_DIR_')) {
define('_CALEM_DIR_', dirname(__FILE__) . '/');
define('LOG4PHP_CONFIGURATION', _CALEM_DIR_ . 'etc/log4php.properties');
}
require_once _CALEM_DIR_ . 'server/conf/calem.php'; //Configuration
require_once _CALEM_DIR_ . 'server/conf/soap_map.php'; //Soap mapping
require_once _CALEM_DIR_ . 'server/include/log4php/LoggerManager.php'; //Logger
require_once _CALEM_DIR_ . 'server/include/core/CalemSoapRequest.php';
require_once _CALEM_DIR_ . 'server/include/util/CalemHttpHelper.php';
//Must have PEAR SOAP on the path
require_once 'SOAP/Parser.php';
//Disable browser side cache
header('Cache-Control: no-cache');
//Start handling the request.
$logger=&LoggerManager::getLogger('CalemSoapService');
$postData=CalemHttpHelper::getPostData();
$calemSoapRequest=new CalemSoapRequest();
if ($logger->isInfoEnabled()) {
$logger->info("acceptedEncoding=" . $_SERVER['HTTP_ACCEPT_ENCODING'] . ", Received a post request=" . $postData);
}
if (!$postData) {
if ($logger->isDebugEnabled()) $logger->debug("Invalid post data.");
$calemSoapRequest->sendFault(CALEM_SF_NO_POSTDATA);
}
//Processing postData
$parser=&new SOAP_Parser($postData);
$request_headers = $parser->getHeaders();
if ($request_headers) {
if (!is_a($request_headers, 'SOAP_Value')) {
$calemSoapRequest->sendFault(CALEM_SF_INVALID_HEADER);
}
$request_headers=$request_headers->value;
}
$params=$parser->getResponse();
if ($params) {
if (!is_a($params, 'SOAP_Value')) {
$calemSoapRequest->sendFault(CALEM_SF_INVLIAD_PARAMS);
}
$params=$params->value;
}
$method=$parser->root_struct_name[0];
if (!$method || !isset($_CALEM_soap[$method])) {
$calemSoapRequest->sendFault(CALEM_SF_INVALID_METHOD);
}
if ($logger->isDebugEnabled()) $logger->debug("reqHeader=".count($request_headers) . ", params=".count($params));
//Now let's dispatch to the proper class for Soap service.
$service=$_CALEM_soap[$method];
require_once _CALEM_DIR_ . 'server/modules/' . $service[CALEM_SOAP_MODULE] . '/soap/' . $service[CALEM_SOAP_CLASS] . '.php';
$cls = new $service[CALEM_SOAP_CLASS];
$cls->service($request_headers, $method, $params);
//Code below will not be executed.
?>