Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezxmlrpcresponse.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezxmlrpcresponse.php 8714 2001-12-10 12:29:48Z bf $
5 //
6 // Definition of eZXMLRPCResponse class
7 //
8 // B�rd Farstad <bf@ez.no>
9 // Created on: <16-Dec-2000 15:57:06 bf>
10 //
11 // This source file is part of Exponential Basic, publishing software.
12 // Copyright (C) 1999-2000 eZ systems as
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
35 // datatypes
36 // include_once( "ezxmlrpc/classes/ezxmlrpcserver.php" );
37 // include_once( "ezxmlrpc/classes/ezxmlrpcstring.php" );
38 // include_once( "ezxmlrpc/classes/ezxmlrpcint.php" );
39 // include_once( "ezxmlrpc/classes/ezxmlrpcdouble.php" );
40 // include_once( "ezxmlrpc/classes/ezxmlrpcbool.php" );
41 // include_once( "ezxmlrpc/classes/ezxmlrpcbase64.php" );
42 // include_once( "ezxmlrpc/classes/ezxmlrpcdatetime.php" );
43 // include_once( "ezxmlrpc/classes/ezxmlrpcarray.php" );
44 // include_once( "ezxmlrpc/classes/ezxmlrpcstruct.php" );
45
46 // include_once( "ezxml/classes/ezxml.php" );
47
48
49 class eZXMLRPCResponse
50 {
54 function __construct( )
55 {
56 $this->Result = 0;
57 $this->Error = 0;
58 $this->IsFault = false;
59 }
60
66 function decodeStream( $stream )
67 {
68 // create a new decoder object
69 $decoder = new eZXMLRPCDataTypeDecoder( );
70
71 $stream = $this->stripHTTPHeader( $stream );
72
73 /*
74 // coose XML parser
75 if ( function_exists( "xmltree" ) )
76 {
77 $domTree =& xmltree( $stream );
78 }
79 else if ( function_exists( "qdom_tree" ) )
80 {
81 $domTree =& qdom_tree( $stream );
82 }
83 else
84 {
85 $domTree->children = array();
86 $this->setError( EZXMLRPC_NO_DOM_PARSER,
87 "DOM XML parser not found. Server not properly configured.\n" .
88 "Please install either libxml or QDom.\n");
89 }
90 */
91
92 $domTree =& eZXML::domTree( $stream, array( "TrimWhiteSpace" => true ) );
93
94 foreach ( $domTree->children as $response )
95 {
96 if ( $response->name == "methodResponse" )
97 {
98 foreach ( $response->children as $params )
99 {
100 if ( $params->name == "params" )
101 {
102
103 foreach ( $params->children as $param )
104 {
105 if ( $param->name == "param" )
106 {
107
108 foreach ( $param->children as $value )
109 {
110 if ( $value->name == "value" )
111 {
112 $this->Result =& $decoder->decodeDataTypes( $value );
113 }
114 }
115 }
116 }
117 }
118
119 if ( $params->name == "fault" )
120 {
121 foreach ( $params->children as $param )
122 {
123 if ( $param->name == "value" )
124 {
125 $this->IsFault = true;
126 $this->Error =& $decoder->decodeDataTypes( $param );
127 }
128 }
129 }
130 }
131 }
132 }
133
134 // could not decode the stream
135 if ( $this->Result == 0 and $this->Error == 0 )
136 {
137 $this->setError( 3, "Could not decode stream. Server error." );
138 }
139 }
140
147 function setResult( $result )
148 {
149 $this->Result = $result;
150 }
151
157 function setVersion( $version, $release )
158 {
159 $this->Version = $version;
160 $this->Release = $release;
161 }
162
163
167 function setError( $faultCode, $faultString, $faultSubCode = false )
168 {
169 $this->IsFault = true;
170 $error = array( "faultCode" => new eZXMLRPCInt( $faultCode ),
171 "faultString" => new eZXMLRPCString( $faultString ),
172 "version" => new eZXMLRPCDouble( $this->Version ),
173 "release" => new eZXMLRPCInt( $this->Release ) );
174 if ( !is_bool( $faultSubCode ) )
175 $error["faultSubCode"] = $faultSubCode;
176 $this->Error = new eZXMLRPCStruct( $error );
177 }
178
187 function result( )
188 {
189 return $this->Result;
190 }
191
196 function &payload( )
197 {
198 $payload = "<?xml version=\"1.0\"?>";
199
200 if ( $this->Error == "" )
201 {
202 $payload .= "<methodResponse><params><param>";
203 $payload .= $this->Result->serialize();
204 $payload .= "</param></params></methodResponse>";
205 }
206 else
207 {
208 $payload .= "<methodResponse><fault>";
209 $payload .= $this->Error->serialize();
210 $payload .= "</fault></methodResponse>";
211 }
212
213 return $payload;
214 }
215
221 function &stripHTTPHeader( $data )
222 {
223 $start = strpos( $data, "<?xml version=\"1.0\"?>" );
224 $data = substr( $data, $start, strlen( $data ) - $start );
225
226 return $data;
227 }
228
232 function isFault()
233 {
234 return $this->IsFault;
235 }
236
240 function faultCode()
241 {
242 $ret = false;
243
244 if ( $this->IsFault and ( is_a( $this->Error, "eZXMLRPCStruct" ) ) )
245 {
246
247 // $error = $this->Result->value();
248 $error = $this->Error->value();
249
250
251 $ret = $error["faultCode"]->value();
252 }
253
254 return $ret;
255 }
256
260 function faultString()
261 {
262 $ret = false;
263
264 if ( $this->IsFault and ( is_a( $this->Error, "eZXMLRPCStruct" ) ) )
265 {
266 // $error = $this->Result->value();
267 $error = $this->Error->value();
268
269 $ret = $error["faultString"]->value();
270 }
271
272 return $ret;
273 }
274
275
277 var $Result;
278
280 var $Error;
281
283 var $IsFault;
284
286 var $Version;
287 var $Release;
288 }
289
290 ?>
eZXMLRPCDataTypeDecoder
Definition: ezxmlrpcdatatypedecoder.php:37
eZXMLRPCDouble
Definition: ezxmlrpcdouble.php:37
eZXMLRPCInt
Definition: ezxmlrpcint.php:37
eZXMLRPCResponse
Definition: ezxmlrpcresponse.php:50
eZXMLRPCResponse\payload
& payload()
Definition: ezxmlrpcresponse.php:196
eZXMLRPCResponse\result
result()
Definition: ezxmlrpcresponse.php:187
eZXMLRPCResponse\faultCode
faultCode()
Definition: ezxmlrpcresponse.php:240
eZXMLRPCResponse\__construct
__construct()
Definition: ezxmlrpcresponse.php:54
eZXMLRPCResponse\faultString
faultString()
Definition: ezxmlrpcresponse.php:260
eZXMLRPCResponse\decodeStream
decodeStream( $stream)
Definition: ezxmlrpcresponse.php:66
eZXMLRPCResponse\setError
setError( $faultCode, $faultString, $faultSubCode=false)
Definition: ezxmlrpcresponse.php:167
eZXMLRPCResponse\setResult
setResult( $result)
Definition: ezxmlrpcresponse.php:147
eZXMLRPCResponse\$Error
$Error
Contains the error struct.
Definition: ezxmlrpcresponse.php:280
eZXMLRPCResponse\$Release
$Release
Definition: ezxmlrpcresponse.php:287
eZXMLRPCResponse\isFault
isFault()
Definition: ezxmlrpcresponse.php:232
eZXMLRPCResponse\$Version
$Version
The version and release number, is sent on error responses.
Definition: ezxmlrpcresponse.php:286
eZXMLRPCResponse\setVersion
setVersion( $version, $release)
Definition: ezxmlrpcresponse.php:157
eZXMLRPCResponse\$Result
$Result
Contains the result.
Definition: ezxmlrpcresponse.php:277
eZXMLRPCResponse\stripHTTPHeader
& stripHTTPHeader( $data)
Definition: ezxmlrpcresponse.php:221
eZXMLRPCResponse\$IsFault
$IsFault
Is true if the response is a fault.
Definition: ezxmlrpcresponse.php:283
eZXMLRPCString
Definition: ezxmlrpcstring.php:37
eZXMLRPCStruct
Definition: ezxmlrpcstruct.php:37
eZXML\domTree
static domTree( $xmlDoc, $params=array())
Definition: ezxml.php:60
$result
$result
Definition: companysearch.php:94
$version
$version
Definition: ezabout/user/datasupplier.php:29
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
$response
while(!feof($socket)) $response
Definition: paypalnotify.php:196
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.