Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezsoapserver.php
Go to the documentation of this file.
1 <?php
49 class eZSOAPServer
50 {
51 public function __construct()
52 {
53 $this->RawPostData = file_get_contents( "php://input" );
54 }
55
56
57 function showResponse( $functionName, $namespaceURI, $value )
58 {
59 // Convert input data to XML
60 $response = new eZSOAPResponse( $functionName, $namespaceURI );
61 $response->setValue( $value );
62
63 $payload = $response->payload();
64
65 header( "SOAPServer: eZ soap" );
66 header( "Content-Type: text/xml; charset=\"UTF-8\"" );
67 Header( "Content-Length: " . strlen( $payload ) );
68
69 if ( ob_get_length() )
70 ob_end_clean();
71
72 print( $payload );
73 }
74
80 function registerObject( $objectName, $includeFile = null )
81 {
82 if ( file_exists( $includeFile ) )
83 include_once( $includeFile );
84
85 if ( class_exists( $objectName ) )
86 {
87 $methods = get_class_methods( $objectName );
88 foreach ( $methods as $method)
89 {
90 if ( strcasecmp ( $objectName, $method ) )
91 $this->registerFunction( $objectName."::".$method );
92 }
93 return true;
94 }
95 else
96 {
97 return false;
98 }
99 }
100
105 function processRequest()
106 {
107 if ( $_SERVER["REQUEST_METHOD"] != "POST" )
108 {
109 print( "Error: this web page does only understand POST methods" );
110 exit();
111 }
112
113 $xmlData = $this->stripHTTPHeader( $this->RawPostData );
114
115 $dom = new DOMDocument( '1.0', 'utf-8' );
116 $dom->preserveWhiteSpace = false;
117 $success = $dom->loadXML( $xmlData );
118
119 // Check for non-parsing XML, to avoid call to non-object error.
120 if ( !$success )
121 {
122 $this->showResponse( 'unknown_function_name', 'unknown_namespace_uri',
123 new eZSOAPFault( 'Server Error',
124 'Bad XML' ) );
125 return;
126 }
127
128 // add namespace fetching on body
129 // get the SOAP body
130 $body = $dom->getElementsByTagName( "Body" );
131
132 $children = $body->item( 0 )->childNodes;
133
134 if ( $children->length == 1 )
135 {
136 $requestNode = $children->item( 0 );
137 // get target namespace for request
138 $functionName = $requestNode->localName;
139 $namespaceURI = $requestNode->namespaceURI;
140
141 $params = array();
142 // check parameters
143 foreach ( $requestNode->childNodes as $parameterNode )
144 {
145 $params[] = eZSOAPResponse::decodeDataTypes( $parameterNode );
146 }
147
148 list( $objectName, $objectFunctionName ) = preg_split('/::/', $functionName, 2, PREG_SPLIT_NO_EMPTY);
149 if ( !$objectFunctionName and in_array( $functionName, $this->FunctionList ) &&
150 function_exists( $functionName ) )
151 {
152 $this->showResponse( $functionName, $namespaceURI,
153 call_user_func_array( $functionName, $params ) );
154 }
155 else if ( $objectName and $objectFunctionName )
156 {
157 if ( !class_exists( $objectName ) )
158 {
159 $this->showResponse( $functionName, $namespaceURI,
160 new eZSOAPFault( 'Server Error',
161 'Object not found' ) );
162 }
163 else
164 {
165 $object = new $objectName();
166 if ( !method_exists( $object, $objectFunctionName ) )
167 {
168 $this->showResponse( $functionName, $namespaceURI,
169 new eZSOAPFault( 'Server Error',
170 'Objectmethod not found' ) );
171 }
172 else
173 {
174 $this->showResponse( $functionName, $namespaceURI,
175 call_user_func_array( array( $object, $objectFunctionName ), $params ) );
176 }
177 }
178 }
179 else
180 {
181 $this->showResponse( $functionName, $namespaceURI,
182 new eZSOAPFault( 'Server Error',
183 'Method not found' ) );
184 }
185 }
186 else
187 {
188 // error
189 $this->showResponse( $functionName, $namespaceURI,
190 new eZSOAPFault( 'Server Error',
191 '"Body" element in the request '.
192 'has wrong number of children' ) );
193
194 }
195 }
196
202 function registerFunction( $name, $params=array() )
203 {
204 $this->FunctionList[] = $name;
205 }
206
207
213 function stripHTTPHeader( $data )
214 {
215 $start = strpos( $data, "<?xml version=\"1.0\"?>" );
216 return substr( $data, $start, strlen( $data ) - $start );
217 }
218
220 public $FunctionList;
222 public $RawPostData;
223 }
224
225 ?>
eZSOAPFault
eZSOAPFault handles SOAP fault messages
Definition: ezsoapfault.php:19
eZSOAPResponse
eZSOAPResponse handles SOAP response packages
Definition: ezsoapresponse.php:19
eZSOAPResponse\decodeDataTypes
static decodeDataTypes( $node, $type="")
Definition: ezsoapresponse.php:117
eZSOAPServer
The class eZSOAPServer handles SOAP server requensts.
Definition: ezsoapserver.php:50
eZSOAPServer\registerFunction
registerFunction( $name, $params=array())
Definition: ezsoapserver.php:202
eZSOAPServer\processRequest
processRequest()
Definition: ezsoapserver.php:105
eZSOAPServer\__construct
__construct()
Definition: ezsoapserver.php:51
eZSOAPServer\stripHTTPHeader
stripHTTPHeader( $data)
Definition: ezsoapserver.php:213
eZSOAPServer\$FunctionList
$FunctionList
Contains a list over registered functions.
Definition: ezsoapserver.php:220
eZSOAPServer\showResponse
showResponse( $functionName, $namespaceURI, $value)
Definition: ezsoapserver.php:57
eZSOAPServer\$RawPostData
$RawPostData
Contains the RAW HTTP post data information.
Definition: ezsoapserver.php:222
eZSOAPServer\registerObject
registerObject( $objectName, $includeFile=null)
Definition: ezsoapserver.php:80
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.