Completed
Branch develop (d4f61d)
by
unknown
16:11
created
htdocs/includes/nusoap/lib/nusoapmime.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * @access public
87 87
 	 */
88 88
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
89
+		if (!$cid) {
90 90
 			$cid = md5(uniqid(time()));
91 91
 		}
92 92
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @access   private
222 222
 	 */
223 223
 	function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
224
+		$this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
225 225
 		$this->responseAttachments = array();
226 226
 		if (strstr($headers['content-type'], 'multipart/related')) {
227 227
 			$this->debug('Decode multipart/related');
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			foreach ($headers as $k => $v) {
230 230
 				$input .= "$k: $v\r\n";
231 231
 			}
232
-			$params['input'] = $input . "\r\n" . $data;
232
+			$params['input'] = $input."\r\n".$data;
233 233
 			$params['include_bodies'] = true;
234 234
 			$params['decode_bodies'] = true;
235 235
 			$params['decode_headers'] = true;
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
 			foreach ($structure->parts as $part) {
240 240
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
241
+					$this->debug('Have root part of type '.$part->headers['content-type']);
242 242
 					$root = $part->body;
243 243
 					$return = parent::parseResponse($part->headers, $part->body);
244 244
 				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
245
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
246 246
 					$info['data'] = $part->body;
247 247
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248 248
 					$info['contenttype'] = $part->headers['content-type'];
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	 * @access public
317 317
 	 */
318 318
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
319
+		if (!$cid) {
320 320
 			$cid = md5(uniqid(time()));
321 321
 		}
322 322
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	 * @access   private
452 452
 	 */
453 453
 	function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
454
+		$this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
455 455
 		$this->requestAttachments = array();
456 456
 		if (strstr($headers['content-type'], 'multipart/related')) {
457 457
 			$this->debug('Decode multipart/related');
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 			foreach ($headers as $k => $v) {
460 460
 				$input .= "$k: $v\r\n";
461 461
 			}
462
-			$params['input'] = $input . "\r\n" . $data;
462
+			$params['input'] = $input."\r\n".$data;
463 463
 			$params['include_bodies'] = true;
464 464
 			$params['decode_bodies'] = true;
465 465
 			$params['decode_headers'] = true;
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 
469 469
 			foreach ($structure->parts as $part) {
470 470
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
471
+					$this->debug('Have root part of type '.$part->headers['content-type']);
472 472
 					$return = parent::parseRequest($part->headers, $part->body);
473 473
 				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
474
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
475 475
 					$info['data'] = $part->body;
476 476
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477 477
 					$info['contenttype'] = $part->headers['content-type'];
Please login to merge, or discard this patch.
htdocs/includes/nusoap/lib/nusoap.php 4 patches
Indentation   +8413 added lines, -8413 removed lines patch added patch discarded remove patch
@@ -85,844 +85,844 @@  discard block
 block discarded – undo
85 85
  */
86 86
 class nusoap_base
87 87
 {
88
-    /**
89
-     * Identification for HTTP headers.
90
-     *
91
-     * @var string
92
-     * @access private
93
-     */
94
-    var $title = 'NuSOAP';
95
-    /**
96
-     * Version for HTTP headers.
97
-     *
98
-     * @var string
99
-     * @access private
100
-     */
101
-    var $version = '0.9.11';
102
-    /**
103
-     * CVS revision for HTTP headers.
104
-     *
105
-     * @var string
106
-     * @access private
107
-     */
108
-    var $revision = '$Revision: 1.123 $';
109
-    /**
110
-     * Current error string (manipulated by getError/setError)
111
-     *
112
-     * @var string
113
-     * @access private
114
-     */
115
-    var $error_str = '';
116
-    /**
117
-     * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
118
-     *
119
-     * @var string
120
-     * @access private
121
-     */
122
-    var $debug_str = '';
123
-    /**
124
-     * toggles automatic encoding of special characters as entities
125
-     * (should always be true, I think)
126
-     *
127
-     * @var boolean
128
-     * @access private
129
-     */
130
-    var $charencoding = true;
131
-    /**
132
-     * the debug level for this instance
133
-     *
134
-     * @var    integer
135
-     * @access private
136
-     */
137
-    var $debugLevel;
138
-
139
-    /**
140
-     * set schema version
141
-     *
142
-     * @var      string
143
-     * @access   public
144
-     */
145
-    var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
146
-
147
-    /**
148
-     * charset encoding for outgoing messages
149
-     *
150
-     * @var      string
151
-     * @access   public
152
-     */
153
-    var $soap_defencoding = 'ISO-8859-1';
154
-    //var $soap_defencoding = 'UTF-8';
155
-
156
-    /**
157
-     * namespaces in an array of prefix => uri
158
-     *
159
-     * this is "seeded" by a set of constants, but it may be altered by code
160
-     *
161
-     * @var      array
162
-     * @access   public
163
-     */
164
-    var $namespaces = array(
165
-        'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
166
-        'xsd' => 'http://www.w3.org/2001/XMLSchema',
167
-        'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
168
-        'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
169
-    );
170
-
171
-    /**
172
-     * namespaces used in the current context, e.g. during serialization
173
-     *
174
-     * @var      array
175
-     * @access   private
176
-     */
177
-    var $usedNamespaces = array();
178
-
179
-    /**
180
-     * XML Schema types in an array of uri => (array of xml type => php type)
181
-     * is this legacy yet?
182
-     * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
183
-     *
184
-     * @var      array
185
-     * @access   public
186
-     */
187
-    var $typemap = array(
188
-        'http://www.w3.org/2001/XMLSchema' => array(
189
-            'string' => 'string', 'boolean' => 'boolean', 'float' => 'double', 'double' => 'double', 'decimal' => 'double',
190
-            'duration' => '', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => '',
191
-            'gYear' => '', 'gMonthDay' => '', 'gDay' => '', 'gMonth' => '', 'hexBinary' => 'string', 'base64Binary' => 'string',
192
-            // abstract "any" types
193
-            'anyType' => 'string', 'anySimpleType' => 'string',
194
-            // derived datatypes
195
-            'normalizedString' => 'string', 'token' => 'string', 'language' => '', 'NMTOKEN' => '', 'NMTOKENS' => '', 'Name' => '', 'NCName' => '', 'ID' => '',
196
-            'IDREF' => '', 'IDREFS' => '', 'ENTITY' => '', 'ENTITIES' => '', 'integer' => 'integer', 'nonPositiveInteger' => 'integer',
197
-            'negativeInteger' => 'integer', 'long' => 'integer', 'int' => 'integer', 'short' => 'integer', 'byte' => 'integer', 'nonNegativeInteger' => 'integer',
198
-            'unsignedLong' => '', 'unsignedInt' => '', 'unsignedShort' => '', 'unsignedByte' => '', 'positiveInteger' => ''),
199
-        'http://www.w3.org/2000/10/XMLSchema' => array(
200
-            'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double',
201
-            'float' => 'double', 'dateTime' => 'string',
202
-            'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'),
203
-        'http://www.w3.org/1999/XMLSchema' => array(
204
-            'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double',
205
-            'float' => 'double', 'dateTime' => 'string',
206
-            'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'),
207
-        'http://soapinterop.org/xsd' => array('SOAPStruct' => 'struct'),
208
-        'http://schemas.xmlsoap.org/soap/encoding/' => array('base64' => 'string', 'array' => 'array', 'Array' => 'array'),
209
-        'http://xml.apache.org/xml-soap' => array('Map')
210
-    );
211
-
212
-    /**
213
-     * XML entities to convert
214
-     *
215
-     * @var      array
216
-     * @access   public
217
-     * @deprecated
218
-     * @see    expandEntities
219
-     */
220
-    var $xmlEntities = array('quot' => '"', 'amp' => '&',
221
-        'lt' => '<', 'gt' => '>', 'apos' => "'");
222
-
223
-    /**
224
-     * HTTP Content-type to be used for SOAP calls and responses
225
-     *
226
-     * @var string
227
-     */
228
-    var $contentType = "text/xml";
229
-
230
-
231
-    /**
232
-     * constructor
233
-     *
234
-     * @access    public
235
-     */
236
-    function __construct()
237
-    {
238
-        $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
239
-    }
240
-
241
-    /**
242
-     * gets the global debug level, which applies to future instances
243
-     *
244
-     * @return    integer    Debug level 0-9, where 0 turns off
245
-     * @access    public
246
-     */
247
-    function getGlobalDebugLevel()
248
-    {
249
-        return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
250
-    }
251
-
252
-    /**
253
-     * sets the global debug level, which applies to future instances
254
-     *
255
-     * @param    int $level Debug level 0-9, where 0 turns off
256
-     * @access    public
257
-     */
258
-    function setGlobalDebugLevel($level)
259
-    {
260
-        $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
261
-    }
262
-
263
-    /**
264
-     * gets the debug level for this instance
265
-     *
266
-     * @return    int    Debug level 0-9, where 0 turns off
267
-     * @access    public
268
-     */
269
-    function getDebugLevel()
270
-    {
271
-        return $this->debugLevel;
272
-    }
273
-
274
-    /**
275
-     * sets the debug level for this instance
276
-     *
277
-     * @param    int $level Debug level 0-9, where 0 turns off
278
-     * @access    public
279
-     */
280
-    function setDebugLevel($level)
281
-    {
282
-        $this->debugLevel = $level;
283
-    }
284
-
285
-    /**
286
-     * adds debug data to the instance debug string with formatting
287
-     *
288
-     * @param    string $string debug data
289
-     * @access   private
290
-     */
291
-    function debug($string)
292
-    {
293
-        if ($this->debugLevel > 0) {
294
-            $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n");
295
-        }
296
-    }
297
-
298
-    /**
299
-     * adds debug data to the instance debug string without formatting
300
-     *
301
-     * @param    string $string debug data
302
-     * @access   public
303
-     */
304
-    function appendDebug($string)
305
-    {
306
-        if ($this->debugLevel > 0) {
307
-            // it would be nice to use a memory stream here to use
308
-            // memory more efficiently
309
-            $this->debug_str .= $string;
310
-        }
311
-    }
312
-
313
-    /**
314
-     * clears the current debug data for this instance
315
-     *
316
-     * @access   public
317
-     */
318
-    function clearDebug()
319
-    {
320
-        // it would be nice to use a memory stream here to use
321
-        // memory more efficiently
322
-        $this->debug_str = '';
323
-    }
324
-
325
-    /**
326
-     * gets the current debug data for this instance
327
-     *
328
-     * @return   string data
329
-     * @access   public
330
-     */
331
-    function &getDebug()
332
-    {
333
-        // it would be nice to use a memory stream here to use
334
-        // memory more efficiently
335
-        return $this->debug_str;
336
-    }
337
-
338
-    /**
339
-     * gets the current debug data for this instance as an XML comment
340
-     * this may change the contents of the debug data
341
-     *
342
-     * @return   string data as an XML comment
343
-     * @access   public
344
-     */
345
-    function &getDebugAsXMLComment()
346
-    {
347
-        // it would be nice to use a memory stream here to use
348
-        // memory more efficiently
349
-        while (strpos($this->debug_str, '--')) {
350
-            $this->debug_str = str_replace('--', '- -', $this->debug_str);
351
-        }
352
-        $ret = "<!--\n" . $this->debug_str . "\n-->";
353
-        return $ret;
354
-    }
355
-
356
-    /**
357
-     * expands entities, e.g. changes '<' to '&lt;'.
358
-     *
359
-     * @param    string $val The string in which to expand entities.
360
-     * @access    private
361
-     */
362
-    function expandEntities($val)
363
-    {
364
-        if ($this->charencoding) {
365
-            $val = str_replace('&', '&amp;', $val);
366
-            $val = str_replace("'", '&apos;', $val);
367
-            $val = str_replace('"', '&quot;', $val);
368
-            $val = str_replace('<', '&lt;', $val);
369
-            $val = str_replace('>', '&gt;', $val);
370
-        }
371
-        return $val;
372
-    }
373
-
374
-    /**
375
-     * returns error string if present
376
-     *
377
-     * @return   false|string error string or false
378
-     * @access   public
379
-     */
380
-    function getError()
381
-    {
382
-        if ($this->error_str != '') {
383
-            return $this->error_str;
384
-        }
385
-        return false;
386
-    }
387
-
388
-    /**
389
-     * sets error string
390
-     *
391
-     * @return   void
392
-     * @access   private
393
-     */
394
-    function setError($str)
395
-    {
396
-        $this->error_str = $str;
397
-    }
398
-
399
-    /**
400
-     * detect if array is a simple array or a struct (associative array)
401
-     *
402
-     * @param    mixed $val The PHP array
403
-     * @return    string    (arraySimple|arrayStruct)
404
-     * @access    private
405
-     */
406
-    function isArraySimpleOrStruct($val)
407
-    {
408
-        $keyList = array_keys($val);
409
-        foreach ($keyList as $keyListValue) {
410
-            if (!is_int($keyListValue)) {
411
-                return 'arrayStruct';
412
-            }
413
-        }
414
-        return 'arraySimple';
415
-    }
416
-
417
-    /**
418
-     * serializes PHP values in accordance w/ section 5. Type information is
419
-     * not serialized if $use == 'literal'.
420
-     *
421
-     * @param    mixed $val The value to serialize
422
-     * @param    string $name The name (local part) of the XML element
423
-     * @param    string $type The XML schema type (local part) for the element
424
-     * @param    string $name_ns The namespace for the name of the XML element
425
-     * @param    string $type_ns The namespace for the type of the element
426
-     * @param    array $attributes The attributes to serialize as name=>value pairs
427
-     * @param    string $use The WSDL "use" (encoded|literal)
428
-     * @param    boolean $soapval Whether this is called from soapval.
429
-     * @return    string    The serialized element, possibly with child elements
430
-     * @access    public
431
-     */
432
-    function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false)
433
-    {
434
-        $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
435
-        $this->appendDebug('value=' . $this->varDump($val));
436
-        $this->appendDebug('attributes=' . $this->varDump($attributes));
437
-
438
-        if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
439
-            $this->debug("serialize_val: serialize soapval");
440
-            $xml = $val->serialize($use);
441
-            $this->appendDebug($val->getDebug());
442
-            $val->clearDebug();
443
-            $this->debug("serialize_val of soapval returning $xml");
444
-            return $xml;
445
-        }
446
-        // force valid name if necessary
447
-        if (is_numeric($name)) {
448
-            $name = '__numeric_' . $name;
449
-        } elseif (!$name) {
450
-            $name = 'noname';
451
-        }
452
-        // if name has ns, add ns prefix to name
453
-        $xmlns = '';
454
-        if ($name_ns) {
455
-            $prefix = 'nu' . rand(1000, 9999);
456
-            $name = $prefix . ':' . $name;
457
-            $xmlns .= " xmlns:$prefix=\"$name_ns\"";
458
-        }
459
-        // if type is prefixed, create type prefix
460
-        if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
461
-            // need to fix this. shouldn't default to xsd if no ns specified
462
-            // w/o checking against typemap
463
-            $type_prefix = 'xsd';
464
-        } elseif ($type_ns) {
465
-            $type_prefix = 'ns' . rand(1000, 9999);
466
-            $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
467
-        }
468
-        // serialize attributes if present
469
-        $atts = '';
470
-        if ($attributes) {
471
-            foreach ($attributes as $k => $v) {
472
-                $atts .= " $k=\"" . $this->expandEntities($v) . '"';
473
-            }
474
-        }
475
-        // serialize null value
476
-        if (is_null($val)) {
477
-            $this->debug("serialize_val: serialize null");
478
-            if ($use == 'literal') {
479
-                // TODO: depends on minOccurs
480
-                $xml = "<$name$xmlns$atts/>";
481
-            } else {
482
-                if (isset($type) && isset($type_prefix)) {
483
-                    $type_str = " xsi:type=\"$type_prefix:$type\"";
484
-                } else {
485
-                    $type_str = '';
486
-                }
487
-                $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
488
-            }
489
-            $this->debug("serialize_val returning $xml");
490
-            return $xml;
491
-        }
492
-        // serialize if an xsd built-in primitive type
493
-        if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
494
-            $this->debug("serialize_val: serialize xsd built-in primitive type");
495
-            if (is_bool($val)) {
496
-                if ($type == 'boolean') {
497
-                    $val = $val ? 'true' : 'false';
498
-                } elseif (!$val) {
499
-                    $val = 0;
500
-                }
501
-            } elseif (is_string($val)) {
502
-                $val = $this->expandEntities($val);
503
-            }
504
-            if ($use == 'literal') {
505
-                $xml = "<$name$xmlns$atts>$val</$name>";
506
-            } else {
507
-                $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
508
-            }
509
-            $this->debug("serialize_val returning $xml");
510
-            return $xml;
511
-        }
512
-        // detect type and serialize
513
-        $xml = '';
514
-        switch (true) {
515
-            case (is_bool($val) || $type == 'boolean'):
516
-                $this->debug("serialize_val: serialize boolean");
517
-                if ($type == 'boolean') {
518
-                    $val = $val ? 'true' : 'false';
519
-                } elseif (!$val) {
520
-                    $val = 0;
521
-                }
522
-                if ($use == 'literal') {
523
-                    $xml .= "<$name$xmlns$atts>$val</$name>";
524
-                } else {
525
-                    $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
526
-                }
527
-                break;
528
-            case (is_int($val) || is_long($val) || $type == 'int'):
529
-                $this->debug("serialize_val: serialize int");
530
-                if ($use == 'literal') {
531
-                    $xml .= "<$name$xmlns$atts>$val</$name>";
532
-                } else {
533
-                    $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
534
-                }
535
-                break;
536
-            case (is_float($val) || is_double($val) || $type == 'float'):
537
-                $this->debug("serialize_val: serialize float");
538
-                if ($use == 'literal') {
539
-                    $xml .= "<$name$xmlns$atts>$val</$name>";
540
-                } else {
541
-                    $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
542
-                }
543
-                break;
544
-            case (is_string($val) || $type == 'string'):
545
-                $this->debug("serialize_val: serialize string");
546
-                $val = $this->expandEntities($val);
547
-                if ($use == 'literal') {
548
-                    $xml .= "<$name$xmlns$atts>$val</$name>";
549
-                } else {
550
-                    $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
551
-                }
552
-                break;
553
-            case is_object($val):
554
-                $this->debug("serialize_val: serialize object");
555
-                $pXml = "";
556
-                if (get_class($val) == 'soapval') {
557
-                    $this->debug("serialize_val: serialize soapval object");
558
-                    $pXml = $val->serialize($use);
559
-                    $this->appendDebug($val->getDebug());
560
-                    $val->clearDebug();
561
-                } else {
562
-                    if (!$name) {
563
-                        $name = get_class($val);
564
-                        $this->debug("In serialize_val, used class name $name as element name");
565
-                    } else {
566
-                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
567
-                    }
568
-                    foreach (get_object_vars($val) as $k => $v) {
569
-                        $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
570
-                    }
571
-                }
572
-                if (isset($type) && isset($type_prefix)) {
573
-                    $type_str = " xsi:type=\"$type_prefix:$type\"";
574
-                } else {
575
-                    $type_str = '';
576
-                }
577
-                if ($use == 'literal') {
578
-                    $xml .= "<$name$xmlns$atts>$pXml</$name>";
579
-                } else {
580
-                    $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
581
-                }
582
-                break;
583
-            case (is_array($val) || $type):
584
-                // detect if struct or array
585
-                $valueType = $this->isArraySimpleOrStruct($val);
586
-                if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
587
-                    $this->debug("serialize_val: serialize array");
588
-                    $i = 0;
589
-                    if (is_array($val) && count($val) > 0) {
590
-                        $array_types = array ();
591
-                        $tt_ns = "";
592
-                        $tt = "";
593
-                        foreach ($val as $v) {
594
-                            if (is_object($v) && get_class($v) == 'soapval') {
595
-                                $tt_ns = $v->type_ns;
596
-                                $tt = $v->type;
597
-                            } elseif (is_array($v)) {
598
-                                $tt = $this->isArraySimpleOrStruct($v);
599
-                            } else {
600
-                                $tt = gettype($v);
601
-                            }
602
-                            $array_types[$tt] = 1;
603
-                            // TODO: for literal, the name should be $name
604
-                            $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use);
605
-                            ++$i;
606
-                        }
607
-                        if (count($array_types) > 1) {
608
-                            $array_typename = 'xsd:anyType';
609
-                        } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
610
-                            if ($tt == 'integer') {
611
-                                $tt = 'int';
612
-                            }
613
-                            $array_typename = 'xsd:' . $tt;
614
-                        } elseif (isset($tt) && $tt == 'arraySimple') {
615
-                            $array_typename = 'SOAP-ENC:Array';
616
-                        } elseif (isset($tt) && $tt == 'arrayStruct') {
617
-                            $array_typename = 'unnamed_struct_use_soapval';
618
-                        } else {
619
-                            // if type is prefixed, create type prefix
620
-                            if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
621
-                                $array_typename = 'xsd:' . $tt;
622
-                            } elseif ($tt_ns) {
623
-                                $tt_prefix = 'ns' . rand(1000, 9999);
624
-                                $array_typename = "$tt_prefix:$tt";
625
-                                $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
626
-                            } else {
627
-                                $array_typename = $tt;
628
-                            }
629
-                        }
630
-                        $array_type = $i;
631
-                        if ($use == 'literal') {
632
-                            $type_str = '';
633
-                        } elseif (isset($type) && isset($type_prefix)) {
634
-                            $type_str = " xsi:type=\"$type_prefix:$type\"";
635
-                        } else {
636
-                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
637
-                        }
638
-                        // empty array
639
-                    } else {
640
-                        if ($use == 'literal') {
641
-                            $type_str = '';
642
-                        } elseif (isset($type) && isset($type_prefix)) {
643
-                            $type_str = " xsi:type=\"$type_prefix:$type\"";
644
-                        } else {
645
-                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
646
-                        }
647
-                    }
648
-                    // TODO: for array in literal, there is no wrapper here
649
-                    $xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
650
-                } else {
651
-                    // got a struct
652
-                    $this->debug("serialize_val: serialize struct");
653
-                    if (isset($type) && isset($type_prefix)) {
654
-                        $type_str = " xsi:type=\"$type_prefix:$type\"";
655
-                    } else {
656
-                        $type_str = '';
657
-                    }
658
-                    if ($use == 'literal') {
659
-                        $xml .= "<$name$xmlns$atts>";
660
-                    } else {
661
-                        $xml .= "<$name$xmlns$type_str$atts>";
662
-                    }
663
-                    foreach ($val as $k => $v) {
664
-                        // Apache Map
665
-                        if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
666
-                            $xml .= '<item>';
667
-                            $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use);
668
-                            $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use);
669
-                            $xml .= '</item>';
670
-                        } else {
671
-                            $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
672
-                        }
673
-                    }
674
-                    $xml .= "</$name>";
675
-                }
676
-                break;
677
-            default:
678
-                $this->debug("serialize_val: serialize unknown");
679
-                $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
680
-                break;
681
-        }
682
-        $this->debug("serialize_val returning $xml");
683
-        return $xml;
684
-    }
685
-
686
-    /**
687
-     * serializes a message
688
-     *
689
-     * @param string $body the XML of the SOAP body
690
-     * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
691
-     * @param array $namespaces optional the namespaces used in generating the body and headers
692
-     * @param string $style optional (rpc|document)
693
-     * @param string $use optional (encoded|literal)
694
-     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
695
-     * @return string the message
696
-     * @access public
697
-     */
698
-    function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/')
699
-    {
700
-        // TODO: add an option to automatically run utf8_encode on $body and $headers
701
-        // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
702
-        // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
703
-
704
-        $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
705
-        $this->debug("headers:");
706
-        $this->appendDebug($this->varDump($headers));
707
-        $this->debug("namespaces:");
708
-        $this->appendDebug($this->varDump($namespaces));
709
-
710
-        // serialize namespaces
711
-        $ns_string = '';
712
-        foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
713
-            $ns_string .= " xmlns:$k=\"$v\"";
714
-        }
715
-        if ($encodingStyle) {
716
-            $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
717
-        }
718
-
719
-        // serialize headers
720
-        if ($headers) {
721
-            if (is_array($headers)) {
722
-                $xml = '';
723
-                foreach ($headers as $k => $v) {
724
-                    if (is_object($v) && get_class($v) == 'soapval') {
725
-                        $xml .= $this->serialize_val($v, false, false, false, false, false, $use);
726
-                    } else {
727
-                        $xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
728
-                    }
729
-                }
730
-                $headers = $xml;
731
-                $this->debug("In serializeEnvelope, serialized array of headers to $headers");
732
-            }
733
-            $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
734
-        }
735
-        // serialize envelope
736
-        return
737
-            '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
738
-            '<SOAP-ENV:Envelope' . $ns_string . ">" .
739
-            $headers .
740
-            "<SOAP-ENV:Body>" .
741
-            $body .
742
-            "</SOAP-ENV:Body>" .
743
-            "</SOAP-ENV:Envelope>";
744
-    }
745
-
746
-    /**
747
-     * formats a string to be inserted into an HTML stream
748
-     *
749
-     * @param string $str The string to format
750
-     * @return string The formatted string
751
-     * @access public
752
-     * @deprecated
753
-     */
754
-    function formatDump($str)
755
-    {
756
-        $str = htmlspecialchars($str);
757
-        return nl2br($str);
758
-    }
759
-
760
-    /**
761
-     * contracts (changes namespace to prefix) a qualified name
762
-     *
763
-     * @param    string $qname qname
764
-     * @return    string contracted qname
765
-     * @access   private
766
-     */
767
-    function contractQname($qname)
768
-    {
769
-        // get element namespace
770
-        //$this->xdebug("Contract $qname");
771
-        if (strrpos($qname, ':')) {
772
-            // get unqualified name
773
-            $name = substr($qname, strrpos($qname, ':') + 1);
774
-            // get ns
775
-            $ns = substr($qname, 0, strrpos($qname, ':'));
776
-            $p = $this->getPrefixFromNamespace($ns);
777
-            if ($p) {
778
-                return $p . ':' . $name;
779
-            }
780
-        }
781
-        return $qname;
782
-    }
783
-
784
-    /**
785
-     * expands (changes prefix to namespace) a qualified name
786
-     *
787
-     * @param    string $qname qname
788
-     * @return    string expanded qname
789
-     * @access   private
790
-     */
791
-    function expandQname($qname)
792
-    {
793
-        // get element prefix
794
-        if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
795
-            // get unqualified name
796
-            $name = substr(strstr($qname, ':'), 1);
797
-            // get ns prefix
798
-            $prefix = substr($qname, 0, strpos($qname, ':'));
799
-            if (isset($this->namespaces[$prefix])) {
800
-                return $this->namespaces[$prefix] . ':' . $name;
801
-            } else {
802
-                return $qname;
803
-            }
804
-        } else {
805
-            return $qname;
806
-        }
807
-    }
808
-
809
-    /**
810
-     * returns the local part of a prefixed string
811
-     * returns the original string, if not prefixed
812
-     *
813
-     * @param string $str The prefixed string
814
-     * @return string The local part
815
-     * @access public
816
-     */
817
-    function getLocalPart($str)
818
-    {
819
-        if ($sstr = strrchr($str, ':')) {
820
-            // get unqualified name
821
-            return substr($sstr, 1);
822
-        } else {
823
-            return $str;
824
-        }
825
-    }
826
-
827
-    /**
828
-     * returns the prefix part of a prefixed string
829
-     * returns false, if not prefixed
830
-     *
831
-     * @param string $str The prefixed string
832
-     * @return false|string The prefix or false if there is no prefix
833
-     * @access public
834
-     */
835
-    function getPrefix($str)
836
-    {
837
-        if ($pos = strrpos($str, ':')) {
838
-            // get prefix
839
-            return substr($str, 0, $pos);
840
-        }
841
-        return false;
842
-    }
843
-
844
-    /**
845
-     * pass it a prefix, it returns a namespace
846
-     *
847
-     * @param string $prefix The prefix
848
-     * @return mixed The namespace, false if no namespace has the specified prefix
849
-     * @access public
850
-     */
851
-    function getNamespaceFromPrefix($prefix)
852
-    {
853
-        if (isset($this->namespaces[$prefix])) {
854
-            return $this->namespaces[$prefix];
855
-        }
856
-        //$this->setError("No namespace registered for prefix '$prefix'");
857
-        return false;
858
-    }
859
-
860
-    /**
861
-     * returns the prefix for a given namespace (or prefix)
862
-     * or false if no prefixes registered for the given namespace
863
-     *
864
-     * @param string $ns The namespace
865
-     * @return false|string The prefix, false if the namespace has no prefixes
866
-     * @access public
867
-     */
868
-    function getPrefixFromNamespace($ns)
869
-    {
870
-        foreach ($this->namespaces as $p => $n) {
871
-            if ($ns == $n || $ns == $p) {
872
-                $this->usedNamespaces[$p] = $n;
873
-                return $p;
874
-            }
875
-        }
876
-        return false;
877
-    }
878
-
879
-    /**
880
-     * returns the time in ODBC canonical form with microseconds
881
-     *
882
-     * @return string The time in ODBC canonical form with microseconds
883
-     * @access public
884
-     */
885
-    function getmicrotime()
886
-    {
887
-        if (function_exists('gettimeofday')) {
888
-            $tod = gettimeofday();
889
-            $sec = $tod['sec'];
890
-            $usec = $tod['usec'];
891
-        } else {
892
-            $sec = time();
893
-            $usec = 0;
894
-        }
895
-        $dtx = new DateTime("@$sec");
88
+	/**
89
+	 * Identification for HTTP headers.
90
+	 *
91
+	 * @var string
92
+	 * @access private
93
+	 */
94
+	var $title = 'NuSOAP';
95
+	/**
96
+	 * Version for HTTP headers.
97
+	 *
98
+	 * @var string
99
+	 * @access private
100
+	 */
101
+	var $version = '0.9.11';
102
+	/**
103
+	 * CVS revision for HTTP headers.
104
+	 *
105
+	 * @var string
106
+	 * @access private
107
+	 */
108
+	var $revision = '$Revision: 1.123 $';
109
+	/**
110
+	 * Current error string (manipulated by getError/setError)
111
+	 *
112
+	 * @var string
113
+	 * @access private
114
+	 */
115
+	var $error_str = '';
116
+	/**
117
+	 * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment)
118
+	 *
119
+	 * @var string
120
+	 * @access private
121
+	 */
122
+	var $debug_str = '';
123
+	/**
124
+	 * toggles automatic encoding of special characters as entities
125
+	 * (should always be true, I think)
126
+	 *
127
+	 * @var boolean
128
+	 * @access private
129
+	 */
130
+	var $charencoding = true;
131
+	/**
132
+	 * the debug level for this instance
133
+	 *
134
+	 * @var    integer
135
+	 * @access private
136
+	 */
137
+	var $debugLevel;
138
+
139
+	/**
140
+	 * set schema version
141
+	 *
142
+	 * @var      string
143
+	 * @access   public
144
+	 */
145
+	var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
146
+
147
+	/**
148
+	 * charset encoding for outgoing messages
149
+	 *
150
+	 * @var      string
151
+	 * @access   public
152
+	 */
153
+	var $soap_defencoding = 'ISO-8859-1';
154
+	//var $soap_defencoding = 'UTF-8';
155
+
156
+	/**
157
+	 * namespaces in an array of prefix => uri
158
+	 *
159
+	 * this is "seeded" by a set of constants, but it may be altered by code
160
+	 *
161
+	 * @var      array
162
+	 * @access   public
163
+	 */
164
+	var $namespaces = array(
165
+		'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
166
+		'xsd' => 'http://www.w3.org/2001/XMLSchema',
167
+		'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
168
+		'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/'
169
+	);
170
+
171
+	/**
172
+	 * namespaces used in the current context, e.g. during serialization
173
+	 *
174
+	 * @var      array
175
+	 * @access   private
176
+	 */
177
+	var $usedNamespaces = array();
178
+
179
+	/**
180
+	 * XML Schema types in an array of uri => (array of xml type => php type)
181
+	 * is this legacy yet?
182
+	 * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings.
183
+	 *
184
+	 * @var      array
185
+	 * @access   public
186
+	 */
187
+	var $typemap = array(
188
+		'http://www.w3.org/2001/XMLSchema' => array(
189
+			'string' => 'string', 'boolean' => 'boolean', 'float' => 'double', 'double' => 'double', 'decimal' => 'double',
190
+			'duration' => '', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => '',
191
+			'gYear' => '', 'gMonthDay' => '', 'gDay' => '', 'gMonth' => '', 'hexBinary' => 'string', 'base64Binary' => 'string',
192
+			// abstract "any" types
193
+			'anyType' => 'string', 'anySimpleType' => 'string',
194
+			// derived datatypes
195
+			'normalizedString' => 'string', 'token' => 'string', 'language' => '', 'NMTOKEN' => '', 'NMTOKENS' => '', 'Name' => '', 'NCName' => '', 'ID' => '',
196
+			'IDREF' => '', 'IDREFS' => '', 'ENTITY' => '', 'ENTITIES' => '', 'integer' => 'integer', 'nonPositiveInteger' => 'integer',
197
+			'negativeInteger' => 'integer', 'long' => 'integer', 'int' => 'integer', 'short' => 'integer', 'byte' => 'integer', 'nonNegativeInteger' => 'integer',
198
+			'unsignedLong' => '', 'unsignedInt' => '', 'unsignedShort' => '', 'unsignedByte' => '', 'positiveInteger' => ''),
199
+		'http://www.w3.org/2000/10/XMLSchema' => array(
200
+			'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double',
201
+			'float' => 'double', 'dateTime' => 'string',
202
+			'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'),
203
+		'http://www.w3.org/1999/XMLSchema' => array(
204
+			'i4' => '', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => 'double',
205
+			'float' => 'double', 'dateTime' => 'string',
206
+			'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'array'),
207
+		'http://soapinterop.org/xsd' => array('SOAPStruct' => 'struct'),
208
+		'http://schemas.xmlsoap.org/soap/encoding/' => array('base64' => 'string', 'array' => 'array', 'Array' => 'array'),
209
+		'http://xml.apache.org/xml-soap' => array('Map')
210
+	);
211
+
212
+	/**
213
+	 * XML entities to convert
214
+	 *
215
+	 * @var      array
216
+	 * @access   public
217
+	 * @deprecated
218
+	 * @see    expandEntities
219
+	 */
220
+	var $xmlEntities = array('quot' => '"', 'amp' => '&',
221
+		'lt' => '<', 'gt' => '>', 'apos' => "'");
222
+
223
+	/**
224
+	 * HTTP Content-type to be used for SOAP calls and responses
225
+	 *
226
+	 * @var string
227
+	 */
228
+	var $contentType = "text/xml";
229
+
230
+
231
+	/**
232
+	 * constructor
233
+	 *
234
+	 * @access    public
235
+	 */
236
+	function __construct()
237
+	{
238
+		$this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
239
+	}
240
+
241
+	/**
242
+	 * gets the global debug level, which applies to future instances
243
+	 *
244
+	 * @return    integer    Debug level 0-9, where 0 turns off
245
+	 * @access    public
246
+	 */
247
+	function getGlobalDebugLevel()
248
+	{
249
+		return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
250
+	}
251
+
252
+	/**
253
+	 * sets the global debug level, which applies to future instances
254
+	 *
255
+	 * @param    int $level Debug level 0-9, where 0 turns off
256
+	 * @access    public
257
+	 */
258
+	function setGlobalDebugLevel($level)
259
+	{
260
+		$GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
261
+	}
262
+
263
+	/**
264
+	 * gets the debug level for this instance
265
+	 *
266
+	 * @return    int    Debug level 0-9, where 0 turns off
267
+	 * @access    public
268
+	 */
269
+	function getDebugLevel()
270
+	{
271
+		return $this->debugLevel;
272
+	}
273
+
274
+	/**
275
+	 * sets the debug level for this instance
276
+	 *
277
+	 * @param    int $level Debug level 0-9, where 0 turns off
278
+	 * @access    public
279
+	 */
280
+	function setDebugLevel($level)
281
+	{
282
+		$this->debugLevel = $level;
283
+	}
284
+
285
+	/**
286
+	 * adds debug data to the instance debug string with formatting
287
+	 *
288
+	 * @param    string $string debug data
289
+	 * @access   private
290
+	 */
291
+	function debug($string)
292
+	{
293
+		if ($this->debugLevel > 0) {
294
+			$this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n");
295
+		}
296
+	}
297
+
298
+	/**
299
+	 * adds debug data to the instance debug string without formatting
300
+	 *
301
+	 * @param    string $string debug data
302
+	 * @access   public
303
+	 */
304
+	function appendDebug($string)
305
+	{
306
+		if ($this->debugLevel > 0) {
307
+			// it would be nice to use a memory stream here to use
308
+			// memory more efficiently
309
+			$this->debug_str .= $string;
310
+		}
311
+	}
312
+
313
+	/**
314
+	 * clears the current debug data for this instance
315
+	 *
316
+	 * @access   public
317
+	 */
318
+	function clearDebug()
319
+	{
320
+		// it would be nice to use a memory stream here to use
321
+		// memory more efficiently
322
+		$this->debug_str = '';
323
+	}
324
+
325
+	/**
326
+	 * gets the current debug data for this instance
327
+	 *
328
+	 * @return   string data
329
+	 * @access   public
330
+	 */
331
+	function &getDebug()
332
+	{
333
+		// it would be nice to use a memory stream here to use
334
+		// memory more efficiently
335
+		return $this->debug_str;
336
+	}
337
+
338
+	/**
339
+	 * gets the current debug data for this instance as an XML comment
340
+	 * this may change the contents of the debug data
341
+	 *
342
+	 * @return   string data as an XML comment
343
+	 * @access   public
344
+	 */
345
+	function &getDebugAsXMLComment()
346
+	{
347
+		// it would be nice to use a memory stream here to use
348
+		// memory more efficiently
349
+		while (strpos($this->debug_str, '--')) {
350
+			$this->debug_str = str_replace('--', '- -', $this->debug_str);
351
+		}
352
+		$ret = "<!--\n" . $this->debug_str . "\n-->";
353
+		return $ret;
354
+	}
355
+
356
+	/**
357
+	 * expands entities, e.g. changes '<' to '&lt;'.
358
+	 *
359
+	 * @param    string $val The string in which to expand entities.
360
+	 * @access    private
361
+	 */
362
+	function expandEntities($val)
363
+	{
364
+		if ($this->charencoding) {
365
+			$val = str_replace('&', '&amp;', $val);
366
+			$val = str_replace("'", '&apos;', $val);
367
+			$val = str_replace('"', '&quot;', $val);
368
+			$val = str_replace('<', '&lt;', $val);
369
+			$val = str_replace('>', '&gt;', $val);
370
+		}
371
+		return $val;
372
+	}
373
+
374
+	/**
375
+	 * returns error string if present
376
+	 *
377
+	 * @return   false|string error string or false
378
+	 * @access   public
379
+	 */
380
+	function getError()
381
+	{
382
+		if ($this->error_str != '') {
383
+			return $this->error_str;
384
+		}
385
+		return false;
386
+	}
387
+
388
+	/**
389
+	 * sets error string
390
+	 *
391
+	 * @return   void
392
+	 * @access   private
393
+	 */
394
+	function setError($str)
395
+	{
396
+		$this->error_str = $str;
397
+	}
398
+
399
+	/**
400
+	 * detect if array is a simple array or a struct (associative array)
401
+	 *
402
+	 * @param    mixed $val The PHP array
403
+	 * @return    string    (arraySimple|arrayStruct)
404
+	 * @access    private
405
+	 */
406
+	function isArraySimpleOrStruct($val)
407
+	{
408
+		$keyList = array_keys($val);
409
+		foreach ($keyList as $keyListValue) {
410
+			if (!is_int($keyListValue)) {
411
+				return 'arrayStruct';
412
+			}
413
+		}
414
+		return 'arraySimple';
415
+	}
416
+
417
+	/**
418
+	 * serializes PHP values in accordance w/ section 5. Type information is
419
+	 * not serialized if $use == 'literal'.
420
+	 *
421
+	 * @param    mixed $val The value to serialize
422
+	 * @param    string $name The name (local part) of the XML element
423
+	 * @param    string $type The XML schema type (local part) for the element
424
+	 * @param    string $name_ns The namespace for the name of the XML element
425
+	 * @param    string $type_ns The namespace for the type of the element
426
+	 * @param    array $attributes The attributes to serialize as name=>value pairs
427
+	 * @param    string $use The WSDL "use" (encoded|literal)
428
+	 * @param    boolean $soapval Whether this is called from soapval.
429
+	 * @return    string    The serialized element, possibly with child elements
430
+	 * @access    public
431
+	 */
432
+	function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false)
433
+	{
434
+		$this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
435
+		$this->appendDebug('value=' . $this->varDump($val));
436
+		$this->appendDebug('attributes=' . $this->varDump($attributes));
437
+
438
+		if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
439
+			$this->debug("serialize_val: serialize soapval");
440
+			$xml = $val->serialize($use);
441
+			$this->appendDebug($val->getDebug());
442
+			$val->clearDebug();
443
+			$this->debug("serialize_val of soapval returning $xml");
444
+			return $xml;
445
+		}
446
+		// force valid name if necessary
447
+		if (is_numeric($name)) {
448
+			$name = '__numeric_' . $name;
449
+		} elseif (!$name) {
450
+			$name = 'noname';
451
+		}
452
+		// if name has ns, add ns prefix to name
453
+		$xmlns = '';
454
+		if ($name_ns) {
455
+			$prefix = 'nu' . rand(1000, 9999);
456
+			$name = $prefix . ':' . $name;
457
+			$xmlns .= " xmlns:$prefix=\"$name_ns\"";
458
+		}
459
+		// if type is prefixed, create type prefix
460
+		if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
461
+			// need to fix this. shouldn't default to xsd if no ns specified
462
+			// w/o checking against typemap
463
+			$type_prefix = 'xsd';
464
+		} elseif ($type_ns) {
465
+			$type_prefix = 'ns' . rand(1000, 9999);
466
+			$xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
467
+		}
468
+		// serialize attributes if present
469
+		$atts = '';
470
+		if ($attributes) {
471
+			foreach ($attributes as $k => $v) {
472
+				$atts .= " $k=\"" . $this->expandEntities($v) . '"';
473
+			}
474
+		}
475
+		// serialize null value
476
+		if (is_null($val)) {
477
+			$this->debug("serialize_val: serialize null");
478
+			if ($use == 'literal') {
479
+				// TODO: depends on minOccurs
480
+				$xml = "<$name$xmlns$atts/>";
481
+			} else {
482
+				if (isset($type) && isset($type_prefix)) {
483
+					$type_str = " xsi:type=\"$type_prefix:$type\"";
484
+				} else {
485
+					$type_str = '';
486
+				}
487
+				$xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>";
488
+			}
489
+			$this->debug("serialize_val returning $xml");
490
+			return $xml;
491
+		}
492
+		// serialize if an xsd built-in primitive type
493
+		if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
494
+			$this->debug("serialize_val: serialize xsd built-in primitive type");
495
+			if (is_bool($val)) {
496
+				if ($type == 'boolean') {
497
+					$val = $val ? 'true' : 'false';
498
+				} elseif (!$val) {
499
+					$val = 0;
500
+				}
501
+			} elseif (is_string($val)) {
502
+				$val = $this->expandEntities($val);
503
+			}
504
+			if ($use == 'literal') {
505
+				$xml = "<$name$xmlns$atts>$val</$name>";
506
+			} else {
507
+				$xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>";
508
+			}
509
+			$this->debug("serialize_val returning $xml");
510
+			return $xml;
511
+		}
512
+		// detect type and serialize
513
+		$xml = '';
514
+		switch (true) {
515
+			case (is_bool($val) || $type == 'boolean'):
516
+				$this->debug("serialize_val: serialize boolean");
517
+				if ($type == 'boolean') {
518
+					$val = $val ? 'true' : 'false';
519
+				} elseif (!$val) {
520
+					$val = 0;
521
+				}
522
+				if ($use == 'literal') {
523
+					$xml .= "<$name$xmlns$atts>$val</$name>";
524
+				} else {
525
+					$xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>";
526
+				}
527
+				break;
528
+			case (is_int($val) || is_long($val) || $type == 'int'):
529
+				$this->debug("serialize_val: serialize int");
530
+				if ($use == 'literal') {
531
+					$xml .= "<$name$xmlns$atts>$val</$name>";
532
+				} else {
533
+					$xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>";
534
+				}
535
+				break;
536
+			case (is_float($val) || is_double($val) || $type == 'float'):
537
+				$this->debug("serialize_val: serialize float");
538
+				if ($use == 'literal') {
539
+					$xml .= "<$name$xmlns$atts>$val</$name>";
540
+				} else {
541
+					$xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>";
542
+				}
543
+				break;
544
+			case (is_string($val) || $type == 'string'):
545
+				$this->debug("serialize_val: serialize string");
546
+				$val = $this->expandEntities($val);
547
+				if ($use == 'literal') {
548
+					$xml .= "<$name$xmlns$atts>$val</$name>";
549
+				} else {
550
+					$xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>";
551
+				}
552
+				break;
553
+			case is_object($val):
554
+				$this->debug("serialize_val: serialize object");
555
+				$pXml = "";
556
+				if (get_class($val) == 'soapval') {
557
+					$this->debug("serialize_val: serialize soapval object");
558
+					$pXml = $val->serialize($use);
559
+					$this->appendDebug($val->getDebug());
560
+					$val->clearDebug();
561
+				} else {
562
+					if (!$name) {
563
+						$name = get_class($val);
564
+						$this->debug("In serialize_val, used class name $name as element name");
565
+					} else {
566
+						$this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
567
+					}
568
+					foreach (get_object_vars($val) as $k => $v) {
569
+						$pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
570
+					}
571
+				}
572
+				if (isset($type) && isset($type_prefix)) {
573
+					$type_str = " xsi:type=\"$type_prefix:$type\"";
574
+				} else {
575
+					$type_str = '';
576
+				}
577
+				if ($use == 'literal') {
578
+					$xml .= "<$name$xmlns$atts>$pXml</$name>";
579
+				} else {
580
+					$xml .= "<$name$xmlns$type_str$atts>$pXml</$name>";
581
+				}
582
+				break;
583
+			case (is_array($val) || $type):
584
+				// detect if struct or array
585
+				$valueType = $this->isArraySimpleOrStruct($val);
586
+				if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
587
+					$this->debug("serialize_val: serialize array");
588
+					$i = 0;
589
+					if (is_array($val) && count($val) > 0) {
590
+						$array_types = array ();
591
+						$tt_ns = "";
592
+						$tt = "";
593
+						foreach ($val as $v) {
594
+							if (is_object($v) && get_class($v) == 'soapval') {
595
+								$tt_ns = $v->type_ns;
596
+								$tt = $v->type;
597
+							} elseif (is_array($v)) {
598
+								$tt = $this->isArraySimpleOrStruct($v);
599
+							} else {
600
+								$tt = gettype($v);
601
+							}
602
+							$array_types[$tt] = 1;
603
+							// TODO: for literal, the name should be $name
604
+							$xml .= $this->serialize_val($v, 'item', false, false, false, false, $use);
605
+							++$i;
606
+						}
607
+						if (count($array_types) > 1) {
608
+							$array_typename = 'xsd:anyType';
609
+						} elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
610
+							if ($tt == 'integer') {
611
+								$tt = 'int';
612
+							}
613
+							$array_typename = 'xsd:' . $tt;
614
+						} elseif (isset($tt) && $tt == 'arraySimple') {
615
+							$array_typename = 'SOAP-ENC:Array';
616
+						} elseif (isset($tt) && $tt == 'arrayStruct') {
617
+							$array_typename = 'unnamed_struct_use_soapval';
618
+						} else {
619
+							// if type is prefixed, create type prefix
620
+							if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
621
+								$array_typename = 'xsd:' . $tt;
622
+							} elseif ($tt_ns) {
623
+								$tt_prefix = 'ns' . rand(1000, 9999);
624
+								$array_typename = "$tt_prefix:$tt";
625
+								$xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
626
+							} else {
627
+								$array_typename = $tt;
628
+							}
629
+						}
630
+						$array_type = $i;
631
+						if ($use == 'literal') {
632
+							$type_str = '';
633
+						} elseif (isset($type) && isset($type_prefix)) {
634
+							$type_str = " xsi:type=\"$type_prefix:$type\"";
635
+						} else {
636
+							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
637
+						}
638
+						// empty array
639
+					} else {
640
+						if ($use == 'literal') {
641
+							$type_str = '';
642
+						} elseif (isset($type) && isset($type_prefix)) {
643
+							$type_str = " xsi:type=\"$type_prefix:$type\"";
644
+						} else {
645
+							$type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\"";
646
+						}
647
+					}
648
+					// TODO: for array in literal, there is no wrapper here
649
+					$xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
650
+				} else {
651
+					// got a struct
652
+					$this->debug("serialize_val: serialize struct");
653
+					if (isset($type) && isset($type_prefix)) {
654
+						$type_str = " xsi:type=\"$type_prefix:$type\"";
655
+					} else {
656
+						$type_str = '';
657
+					}
658
+					if ($use == 'literal') {
659
+						$xml .= "<$name$xmlns$atts>";
660
+					} else {
661
+						$xml .= "<$name$xmlns$type_str$atts>";
662
+					}
663
+					foreach ($val as $k => $v) {
664
+						// Apache Map
665
+						if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
666
+							$xml .= '<item>';
667
+							$xml .= $this->serialize_val($k, 'key', false, false, false, false, $use);
668
+							$xml .= $this->serialize_val($v, 'value', false, false, false, false, $use);
669
+							$xml .= '</item>';
670
+						} else {
671
+							$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
672
+						}
673
+					}
674
+					$xml .= "</$name>";
675
+				}
676
+				break;
677
+			default:
678
+				$this->debug("serialize_val: serialize unknown");
679
+				$xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
680
+				break;
681
+		}
682
+		$this->debug("serialize_val returning $xml");
683
+		return $xml;
684
+	}
685
+
686
+	/**
687
+	 * serializes a message
688
+	 *
689
+	 * @param string $body the XML of the SOAP body
690
+	 * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
691
+	 * @param array $namespaces optional the namespaces used in generating the body and headers
692
+	 * @param string $style optional (rpc|document)
693
+	 * @param string $use optional (encoded|literal)
694
+	 * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
695
+	 * @return string the message
696
+	 * @access public
697
+	 */
698
+	function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/')
699
+	{
700
+		// TODO: add an option to automatically run utf8_encode on $body and $headers
701
+		// if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
702
+		// one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
703
+
704
+		$this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
705
+		$this->debug("headers:");
706
+		$this->appendDebug($this->varDump($headers));
707
+		$this->debug("namespaces:");
708
+		$this->appendDebug($this->varDump($namespaces));
709
+
710
+		// serialize namespaces
711
+		$ns_string = '';
712
+		foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
713
+			$ns_string .= " xmlns:$k=\"$v\"";
714
+		}
715
+		if ($encodingStyle) {
716
+			$ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string";
717
+		}
718
+
719
+		// serialize headers
720
+		if ($headers) {
721
+			if (is_array($headers)) {
722
+				$xml = '';
723
+				foreach ($headers as $k => $v) {
724
+					if (is_object($v) && get_class($v) == 'soapval') {
725
+						$xml .= $this->serialize_val($v, false, false, false, false, false, $use);
726
+					} else {
727
+						$xml .= $this->serialize_val($v, $k, false, false, false, false, $use);
728
+					}
729
+				}
730
+				$headers = $xml;
731
+				$this->debug("In serializeEnvelope, serialized array of headers to $headers");
732
+			}
733
+			$headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
734
+		}
735
+		// serialize envelope
736
+		return
737
+			'<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
738
+			'<SOAP-ENV:Envelope' . $ns_string . ">" .
739
+			$headers .
740
+			"<SOAP-ENV:Body>" .
741
+			$body .
742
+			"</SOAP-ENV:Body>" .
743
+			"</SOAP-ENV:Envelope>";
744
+	}
745
+
746
+	/**
747
+	 * formats a string to be inserted into an HTML stream
748
+	 *
749
+	 * @param string $str The string to format
750
+	 * @return string The formatted string
751
+	 * @access public
752
+	 * @deprecated
753
+	 */
754
+	function formatDump($str)
755
+	{
756
+		$str = htmlspecialchars($str);
757
+		return nl2br($str);
758
+	}
759
+
760
+	/**
761
+	 * contracts (changes namespace to prefix) a qualified name
762
+	 *
763
+	 * @param    string $qname qname
764
+	 * @return    string contracted qname
765
+	 * @access   private
766
+	 */
767
+	function contractQname($qname)
768
+	{
769
+		// get element namespace
770
+		//$this->xdebug("Contract $qname");
771
+		if (strrpos($qname, ':')) {
772
+			// get unqualified name
773
+			$name = substr($qname, strrpos($qname, ':') + 1);
774
+			// get ns
775
+			$ns = substr($qname, 0, strrpos($qname, ':'));
776
+			$p = $this->getPrefixFromNamespace($ns);
777
+			if ($p) {
778
+				return $p . ':' . $name;
779
+			}
780
+		}
781
+		return $qname;
782
+	}
783
+
784
+	/**
785
+	 * expands (changes prefix to namespace) a qualified name
786
+	 *
787
+	 * @param    string $qname qname
788
+	 * @return    string expanded qname
789
+	 * @access   private
790
+	 */
791
+	function expandQname($qname)
792
+	{
793
+		// get element prefix
794
+		if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
795
+			// get unqualified name
796
+			$name = substr(strstr($qname, ':'), 1);
797
+			// get ns prefix
798
+			$prefix = substr($qname, 0, strpos($qname, ':'));
799
+			if (isset($this->namespaces[$prefix])) {
800
+				return $this->namespaces[$prefix] . ':' . $name;
801
+			} else {
802
+				return $qname;
803
+			}
804
+		} else {
805
+			return $qname;
806
+		}
807
+	}
808
+
809
+	/**
810
+	 * returns the local part of a prefixed string
811
+	 * returns the original string, if not prefixed
812
+	 *
813
+	 * @param string $str The prefixed string
814
+	 * @return string The local part
815
+	 * @access public
816
+	 */
817
+	function getLocalPart($str)
818
+	{
819
+		if ($sstr = strrchr($str, ':')) {
820
+			// get unqualified name
821
+			return substr($sstr, 1);
822
+		} else {
823
+			return $str;
824
+		}
825
+	}
826
+
827
+	/**
828
+	 * returns the prefix part of a prefixed string
829
+	 * returns false, if not prefixed
830
+	 *
831
+	 * @param string $str The prefixed string
832
+	 * @return false|string The prefix or false if there is no prefix
833
+	 * @access public
834
+	 */
835
+	function getPrefix($str)
836
+	{
837
+		if ($pos = strrpos($str, ':')) {
838
+			// get prefix
839
+			return substr($str, 0, $pos);
840
+		}
841
+		return false;
842
+	}
843
+
844
+	/**
845
+	 * pass it a prefix, it returns a namespace
846
+	 *
847
+	 * @param string $prefix The prefix
848
+	 * @return mixed The namespace, false if no namespace has the specified prefix
849
+	 * @access public
850
+	 */
851
+	function getNamespaceFromPrefix($prefix)
852
+	{
853
+		if (isset($this->namespaces[$prefix])) {
854
+			return $this->namespaces[$prefix];
855
+		}
856
+		//$this->setError("No namespace registered for prefix '$prefix'");
857
+		return false;
858
+	}
859
+
860
+	/**
861
+	 * returns the prefix for a given namespace (or prefix)
862
+	 * or false if no prefixes registered for the given namespace
863
+	 *
864
+	 * @param string $ns The namespace
865
+	 * @return false|string The prefix, false if the namespace has no prefixes
866
+	 * @access public
867
+	 */
868
+	function getPrefixFromNamespace($ns)
869
+	{
870
+		foreach ($this->namespaces as $p => $n) {
871
+			if ($ns == $n || $ns == $p) {
872
+				$this->usedNamespaces[$p] = $n;
873
+				return $p;
874
+			}
875
+		}
876
+		return false;
877
+	}
878
+
879
+	/**
880
+	 * returns the time in ODBC canonical form with microseconds
881
+	 *
882
+	 * @return string The time in ODBC canonical form with microseconds
883
+	 * @access public
884
+	 */
885
+	function getmicrotime()
886
+	{
887
+		if (function_exists('gettimeofday')) {
888
+			$tod = gettimeofday();
889
+			$sec = $tod['sec'];
890
+			$usec = $tod['usec'];
891
+		} else {
892
+			$sec = time();
893
+			$usec = 0;
894
+		}
895
+		$dtx = new DateTime("@$sec");
896 896
 	return
897
-          date_format($dtx, 'Y-m-d H:i:s') . '.' . sprintf('%06d', $usec);
898
-    }
899
-
900
-    /**
901
-     * Returns a string with the output of var_dump
902
-     *
903
-     * @param mixed $data The variable to var_dump
904
-     * @return string The output of var_dump
905
-     * @access public
906
-     */
907
-    function varDump($data)
908
-    {
909
-        ob_start();
910
-        var_dump($data);
911
-        $ret_val = ob_get_contents();
912
-        ob_end_clean();
913
-        return $ret_val;
914
-    }
915
-
916
-    /**
917
-     * represents the object as a string
918
-     *
919
-     * @return    string
920
-     * @access   public
921
-     */
922
-    function __toString()
923
-    {
924
-        return $this->varDump($this);
925
-    }
897
+		  date_format($dtx, 'Y-m-d H:i:s') . '.' . sprintf('%06d', $usec);
898
+	}
899
+
900
+	/**
901
+	 * Returns a string with the output of var_dump
902
+	 *
903
+	 * @param mixed $data The variable to var_dump
904
+	 * @return string The output of var_dump
905
+	 * @access public
906
+	 */
907
+	function varDump($data)
908
+	{
909
+		ob_start();
910
+		var_dump($data);
911
+		$ret_val = ob_get_contents();
912
+		ob_end_clean();
913
+		return $ret_val;
914
+	}
915
+
916
+	/**
917
+	 * represents the object as a string
918
+	 *
919
+	 * @return    string
920
+	 * @access   public
921
+	 */
922
+	function __toString()
923
+	{
924
+		return $this->varDump($this);
925
+	}
926 926
 }
927 927
 
928 928
 // XML Schema Datatype Helper Functions
@@ -939,35 +939,35 @@  discard block
 block discarded – undo
939 939
  */
940 940
 function timestamp_to_iso8601($timestamp, $utc = true)
941 941
 {
942
-    $datestr = date('Y-m-d\TH:i:sO', $timestamp);
943
-    $pos = strrpos($datestr, "+");
944
-    if ($pos === false) {
945
-        $pos = strrpos($datestr, "-");
946
-    }
947
-    if ($pos !== false) {
948
-        if (strlen($datestr) == $pos + 5) {
949
-            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
950
-        }
951
-    }
952
-    if ($utc) {
953
-        $pattern = '/' .
954
-            '([0-9]{4})-' .    // centuries & years CCYY-
955
-            '([0-9]{2})-' .    // months MM-
956
-            '([0-9]{2})' .    // days DD
957
-            'T' .            // separator T
958
-            '([0-9]{2}):' .    // hours hh:
959
-            '([0-9]{2}):' .    // minutes mm:
960
-            '([0-9]{2})(\.[0-9]*)?' . // seconds ss.ss...
961
-            '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
962
-            '/';
963
-
964
-        if (preg_match($pattern, $datestr, $regs)) {
965
-            return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
966
-        }
967
-        return false;
968
-    } else {
969
-        return $datestr;
970
-    }
942
+	$datestr = date('Y-m-d\TH:i:sO', $timestamp);
943
+	$pos = strrpos($datestr, "+");
944
+	if ($pos === false) {
945
+		$pos = strrpos($datestr, "-");
946
+	}
947
+	if ($pos !== false) {
948
+		if (strlen($datestr) == $pos + 5) {
949
+			$datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
950
+		}
951
+	}
952
+	if ($utc) {
953
+		$pattern = '/' .
954
+			'([0-9]{4})-' .    // centuries & years CCYY-
955
+			'([0-9]{2})-' .    // months MM-
956
+			'([0-9]{2})' .    // days DD
957
+			'T' .            // separator T
958
+			'([0-9]{2}):' .    // hours hh:
959
+			'([0-9]{2}):' .    // minutes mm:
960
+			'([0-9]{2})(\.[0-9]*)?' . // seconds ss.ss...
961
+			'(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
962
+			'/';
963
+
964
+		if (preg_match($pattern, $datestr, $regs)) {
965
+			return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
966
+		}
967
+		return false;
968
+	} else {
969
+		return $datestr;
970
+	}
971 971
 }
972 972
 
973 973
 /**
@@ -979,35 +979,35 @@  discard block
 block discarded – undo
979 979
  */
980 980
 function iso8601_to_timestamp($datestr)
981 981
 {
982
-    $pattern = '/' .
983
-        '([0-9]{4})-' .    // centuries & years CCYY-
984
-        '([0-9]{2})-' .    // months MM-
985
-        '([0-9]{2})' .    // days DD
986
-        'T' .            // separator T
987
-        '([0-9]{2}):' .    // hours hh:
988
-        '([0-9]{2}):' .    // minutes mm:
989
-        '([0-9]{2})(\.[0-9]+)?' . // seconds ss.ss...
990
-        '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
991
-        '/';
992
-    if (preg_match($pattern, $datestr, $regs)) {
993
-        // not utc
994
-        if ($regs[8] != 'Z') {
995
-            $op = substr($regs[8], 0, 1);
996
-            $h = substr($regs[8], 1, 2);
997
-            $m = substr($regs[8], strlen($regs[8]) - 2, 2);
998
-            if ($op == '-') {
999
-                $regs[4] = intval ($regs[4]) + intval ($h);
1000
-                $regs[5] = intval ($regs[5]) + intval ($m);
1001
-            } elseif ($op == '+') {
1002
-                $regs[4] = intval ($regs[4]) - intval ($h);
1003
-                $regs[5] = intval ($regs[5]) - intval ($m);
1004
-            }
1005
-        }
1006
-        return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
982
+	$pattern = '/' .
983
+		'([0-9]{4})-' .    // centuries & years CCYY-
984
+		'([0-9]{2})-' .    // months MM-
985
+		'([0-9]{2})' .    // days DD
986
+		'T' .            // separator T
987
+		'([0-9]{2}):' .    // hours hh:
988
+		'([0-9]{2}):' .    // minutes mm:
989
+		'([0-9]{2})(\.[0-9]+)?' . // seconds ss.ss...
990
+		'(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
991
+		'/';
992
+	if (preg_match($pattern, $datestr, $regs)) {
993
+		// not utc
994
+		if ($regs[8] != 'Z') {
995
+			$op = substr($regs[8], 0, 1);
996
+			$h = substr($regs[8], 1, 2);
997
+			$m = substr($regs[8], strlen($regs[8]) - 2, 2);
998
+			if ($op == '-') {
999
+				$regs[4] = intval ($regs[4]) + intval ($h);
1000
+				$regs[5] = intval ($regs[5]) + intval ($m);
1001
+			} elseif ($op == '+') {
1002
+				$regs[4] = intval ($regs[4]) - intval ($h);
1003
+				$regs[5] = intval ($regs[5]) - intval ($m);
1004
+			}
1005
+		}
1006
+		return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
1007 1007
 //		return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
1008
-    } else {
1009
-        return false;
1010
-    }
1008
+	} else {
1009
+		return false;
1010
+	}
1011 1011
 }
1012 1012
 
1013 1013
 /**
@@ -1019,13 +1019,13 @@  discard block
 block discarded – undo
1019 1019
  */
1020 1020
 function usleepWindows($usec)
1021 1021
 {
1022
-    $start = gettimeofday();
1022
+	$start = gettimeofday();
1023 1023
 
1024
-    do {
1025
-        $stop = gettimeofday();
1026
-        $timePassed = 1000000 * ($stop['sec'] - $start['sec'])
1027
-            + $stop['usec'] - $start['usec'];
1028
-    } while ($timePassed < $usec);
1024
+	do {
1025
+		$stop = gettimeofday();
1026
+		$timePassed = 1000000 * ($stop['sec'] - $start['sec'])
1027
+			+ $stop['usec'] - $start['usec'];
1028
+	} while ($timePassed < $usec);
1029 1029
 }
1030 1030
 
1031 1031
 
@@ -1040,77 +1040,77 @@  discard block
 block discarded – undo
1040 1040
  */
1041 1041
 class nusoap_fault extends nusoap_base
1042 1042
 {
1043
-    /**
1044
-     * The fault code (client|server)
1045
-     *
1046
-     * @var string
1047
-     * @access private
1048
-     */
1049
-    var $faultcode;
1050
-    /**
1051
-     * The fault actor
1052
-     *
1053
-     * @var string
1054
-     * @access private
1055
-     */
1056
-    var $faultactor;
1057
-    /**
1058
-     * The fault string, a description of the fault
1059
-     *
1060
-     * @var string
1061
-     * @access private
1062
-     */
1063
-    var $faultstring;
1064
-    /**
1065
-     * The fault detail, typically a string or array of string
1066
-     *
1067
-     * @var mixed
1068
-     * @access private
1069
-     */
1070
-    var $faultdetail;
1071
-
1072
-    /**
1073
-     * constructor
1074
-     *
1075
-     * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
1076
-     * @param string $faultactor only used when msg routed between multiple actors
1077
-     * @param string $faultstring human readable error message
1078
-     * @param mixed $faultdetail detail, typically a string or array of string
1079
-     */
1080
-    function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '')
1081
-    {
1082
-        parent::__construct();
1083
-        $this->faultcode = $faultcode;
1084
-        $this->faultactor = $faultactor;
1085
-        $this->faultstring = $faultstring;
1086
-        $this->faultdetail = $faultdetail;
1087
-    }
1088
-
1089
-    /**
1090
-     * serialize a fault
1091
-     *
1092
-     * @return    string    The serialization of the fault instance.
1093
-     * @access   public
1094
-     */
1095
-    function serialize()
1096
-    {
1097
-        $ns_string = '';
1098
-        foreach ($this->namespaces as $k => $v) {
1099
-            $ns_string .= "\n  xmlns:$k=\"$v\"";
1100
-        }
1101
-
1102
-      return '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' .
1103
-       '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" .
1104
-       '<SOAP-ENV:Body>' .
1105
-       '<SOAP-ENV:Fault>' .
1106
-       $this->serialize_val($this->faultcode, 'faultcode') .
1107
-       $this->serialize_val($this->faultstring, 'faultstring') .
1108
-       $this->serialize_val($this->faultactor, 'faultactor') .
1109
-       $this->serialize_val($this->faultdetail, 'detail') .
1110
-       '</SOAP-ENV:Fault>' .
1111
-       '</SOAP-ENV:Body>' .
1112
-       '</SOAP-ENV:Envelope>';
1113
-    }
1043
+	/**
1044
+	 * The fault code (client|server)
1045
+	 *
1046
+	 * @var string
1047
+	 * @access private
1048
+	 */
1049
+	var $faultcode;
1050
+	/**
1051
+	 * The fault actor
1052
+	 *
1053
+	 * @var string
1054
+	 * @access private
1055
+	 */
1056
+	var $faultactor;
1057
+	/**
1058
+	 * The fault string, a description of the fault
1059
+	 *
1060
+	 * @var string
1061
+	 * @access private
1062
+	 */
1063
+	var $faultstring;
1064
+	/**
1065
+	 * The fault detail, typically a string or array of string
1066
+	 *
1067
+	 * @var mixed
1068
+	 * @access private
1069
+	 */
1070
+	var $faultdetail;
1071
+
1072
+	/**
1073
+	 * constructor
1074
+	 *
1075
+	 * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server)
1076
+	 * @param string $faultactor only used when msg routed between multiple actors
1077
+	 * @param string $faultstring human readable error message
1078
+	 * @param mixed $faultdetail detail, typically a string or array of string
1079
+	 */
1080
+	function __construct($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '')
1081
+	{
1082
+		parent::__construct();
1083
+		$this->faultcode = $faultcode;
1084
+		$this->faultactor = $faultactor;
1085
+		$this->faultstring = $faultstring;
1086
+		$this->faultdetail = $faultdetail;
1087
+	}
1088
+
1089
+	/**
1090
+	 * serialize a fault
1091
+	 *
1092
+	 * @return    string    The serialization of the fault instance.
1093
+	 * @access   public
1094
+	 */
1095
+	function serialize()
1096
+	{
1097
+		$ns_string = '';
1098
+		foreach ($this->namespaces as $k => $v) {
1099
+			$ns_string .= "\n  xmlns:$k=\"$v\"";
1100
+		}
1101
+
1102
+	  return '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' .
1103
+	   '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" .
1104
+	   '<SOAP-ENV:Body>' .
1105
+	   '<SOAP-ENV:Fault>' .
1106
+	   $this->serialize_val($this->faultcode, 'faultcode') .
1107
+	   $this->serialize_val($this->faultstring, 'faultstring') .
1108
+	   $this->serialize_val($this->faultactor, 'faultactor') .
1109
+	   $this->serialize_val($this->faultdetail, 'detail') .
1110
+	   '</SOAP-ENV:Fault>' .
1111
+	   '</SOAP-ENV:Body>' .
1112
+	   '</SOAP-ENV:Envelope>';
1113
+	}
1114 1114
 }
1115 1115
 
1116 1116
 
@@ -1134,5575 +1134,5575 @@  discard block
 block discarded – undo
1134 1134
 class nusoap_xmlschema extends nusoap_base
1135 1135
 {
1136 1136
 
1137
-    // files
1138
-    var $schema = '';
1139
-    var $xml = '';
1140
-    // namespaces
1141
-    var $enclosingNamespaces;
1142
-    // schema info
1143
-    var $schemaInfo = array();
1144
-    var $schemaTargetNamespace = '';
1145
-    // types, elements, attributes defined by the schema
1146
-    var $attributes = array();
1147
-    var $complexTypes = array();
1148
-    var $complexTypeStack = array();
1149
-    var $currentComplexType = null;
1150
-    var $elements = array();
1151
-    var $elementStack = array();
1152
-    var $currentElement = null;
1153
-    var $simpleTypes = array();
1154
-    var $simpleTypeStack = array();
1155
-    var $currentSimpleType = null;
1156
-    // imports
1157
-    var $imports = array();
1158
-    // parser vars
1159
-    var $parser;
1160
-    var $position = 0;
1161
-    var $depth = 0;
1162
-    var $depth_array = array();
1163
-    var $message = array();
1164
-    var $defaultNamespace = array();
1165
-
1166
-    /**
1167
-     * constructor
1168
-     *
1169
-     * @param    string $schema schema document URI
1170
-     * @param    string $xml xml document URI
1171
-     * @param    string $namespaces namespaces defined in enclosing XML
1172
-     * @access   public
1173
-     */
1174
-    function __construct($schema = '', $xml = '', $namespaces = array())
1175
-    {
1176
-        parent::__construct();
1177
-        $this->debug('nusoap_xmlschema class instantiated, inside constructor');
1178
-        // files
1179
-        $this->schema = $schema;
1180
-        $this->xml = $xml;
1181
-
1182
-        // namespaces
1183
-        $this->enclosingNamespaces = $namespaces;
1184
-        $this->namespaces = array_merge($this->namespaces, $namespaces);
1185
-
1186
-        // parse schema file
1187
-        if ($schema != '') {
1188
-            $this->debug('initial schema file: ' . $schema);
1189
-            $this->parseFile($schema, 'schema');
1190
-        }
1191
-
1192
-        // parse xml file
1193
-        if ($xml != '') {
1194
-            $this->debug('initial xml file: ' . $xml);
1195
-            $this->parseFile($xml, 'xml');
1196
-        }
1197
-
1198
-    }
1199
-
1200
-    /**
1201
-     * parse an XML file
1202
-     *
1203
-     * @param string $xml path/URL to XML file
1204
-     * @param string $type (schema | xml)
1205
-     * @return boolean
1206
-     * @access public
1207
-     */
1208
-    function parseFile($xml, $type)
1209
-    {
1210
-        // parse xml file
1211
-        if ($xml != "") {
1212
-            $xmlStr = @join("", @file($xml));
1213
-            if ($xmlStr == "") {
1214
-                $msg = 'Error reading XML from ' . $xml;
1215
-                $this->setError($msg);
1216
-                $this->debug($msg);
1217
-                return false;
1218
-            } else {
1219
-                $this->debug("parsing $xml");
1220
-                $this->parseString($xmlStr, $type);
1221
-                $this->debug("done parsing $xml");
1222
-                return true;
1223
-            }
1224
-        }
1225
-        return false;
1226
-    }
1227
-
1228
-    /**
1229
-     * parse an XML string
1230
-     *
1231
-     * @param    string $xml path or URL
1232
-     * @param    string $type (schema|xml)
1233
-     * @access   private
1234
-     */
1235
-    function parseString($xml, $type)
1236
-    {
1237
-        // parse xml string
1238
-        if ($xml != "") {
1239
-
1240
-            // Create an XML parser.
1241
-            $this->parser = xml_parser_create();
1242
-            // Set the options for parsing the XML data.
1243
-            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1244
-
1245
-            // Set the object for the parser.
1246
-            xml_set_object($this->parser, $this);
1247
-
1248
-            // Set the element handlers for the parser.
1249
-            if ($type == "schema") {
1250
-                xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement');
1251
-                xml_set_character_data_handler($this->parser, 'schemaCharacterData');
1252
-            } elseif ($type == "xml") {
1253
-                xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement');
1254
-                xml_set_character_data_handler($this->parser, 'xmlCharacterData');
1255
-            }
1256
-
1257
-            libxml_disable_entity_loader(true);	// Avoid load of external entities (security problem). Required only for libxml < 2.
1258
-
1259
-            // Parse the XML file.
1260
-            if (!xml_parse($this->parser, $xml, true)) {
1261
-                // Display an error message.
1262
-                $errstr = sprintf('XML error parsing XML schema on line %d: %s',
1263
-                    xml_get_current_line_number($this->parser),
1264
-                    xml_error_string(xml_get_error_code($this->parser))
1265
-                );
1266
-                $this->debug($errstr);
1267
-                $this->debug("XML payload:\n" . $xml);
1268
-                $this->setError($errstr);
1269
-            }
1270
-
1271
-            xml_parser_free($this->parser);
1272
-            unset($this->parser);
1273
-        } else {
1274
-            $this->debug('no xml passed to parseString()!!');
1275
-            $this->setError('no xml passed to parseString()!!');
1276
-        }
1277
-    }
1278
-
1279
-    /**
1280
-     * gets a type name for an unnamed type
1281
-     *
1282
-     * @param    string $ename Element name
1283
-     * @return    string    A type name for an unnamed type
1284
-     * @access    private
1285
-     */
1286
-    function CreateTypeName($ename)
1287
-    {
1288
-        $scope = '';
1289
-        for ($i = 0; $i < count($this->complexTypeStack); $i++) {
1290
-            $scope .= $this->complexTypeStack[$i] . '_';
1291
-        }
1292
-        return $scope . $ename . '_ContainedType';
1293
-    }
1294
-
1295
-    /**
1296
-     * start-element handler
1297
-     *
1298
-     * @param    string $parser XML parser object
1299
-     * @param    string $name element name
1300
-     * @param    array $attrs associative array of attributes
1301
-     * @access   private
1302
-     */
1303
-    function schemaStartElement($parser, $name, $attrs)
1304
-    {
1305
-
1306
-        // position in the total number of elements, starting from 0
1307
-        $pos = $this->position++;
1308
-        $depth = $this->depth++;
1309
-        // set self as current value for this depth
1310
-        $this->depth_array[$depth] = $pos;
1311
-        $this->message[$pos] = array('cdata' => '');
1312
-        if ($depth > 0) {
1313
-            $this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
1314
-        } else {
1315
-            $this->defaultNamespace[$pos] = false;
1316
-        }
1317
-
1318
-        // get element prefix
1319
-        if ($prefix = $this->getPrefix($name)) {
1320
-            // get unqualified name
1321
-            $name = $this->getLocalPart($name);
1322
-        } else {
1323
-            $prefix = '';
1324
-        }
1325
-
1326
-        // loop thru attributes, expanding, and registering namespace declarations
1327
-        if (count($attrs) > 0) {
1328
-            foreach ($attrs as $k => $v) {
1329
-                // if ns declarations, add to class level array of valid namespaces
1330
-                if (preg_match('/^xmlns/', $k)) {
1331
-                    //$this->xdebug("$k: $v");
1332
-                    //$this->xdebug('ns_prefix: '.$this->getPrefix($k));
1333
-                    if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
1334
-                        //$this->xdebug("Add namespace[$ns_prefix] = $v");
1335
-                        $this->namespaces[$ns_prefix] = $v;
1336
-                    } else {
1337
-                        $this->defaultNamespace[$pos] = $v;
1338
-                        if (!$this->getPrefixFromNamespace($v)) {
1339
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
1340
-                        }
1341
-                    }
1342
-                    if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
1343
-                        $this->XMLSchemaVersion = $v;
1344
-                        $this->namespaces['xsi'] = $v . '-instance';
1345
-                    }
1346
-                }
1347
-            }
1348
-            $eAttrs = array ();
1349
-            foreach ($attrs as $k => $v) {
1350
-                // expand each attribute
1351
-                $k = strpos($k, ':') ? $this->expandQname($k) : $k;
1352
-                $v = strpos($v, ':') ? $this->expandQname($v) : $v;
1353
-                $eAttrs[$k] = $v;
1354
-            }
1355
-            $attrs = $eAttrs;
1356
-        } else {
1357
-            $attrs = array();
1358
-        }
1359
-        // find status, register data
1360
-        switch ($name) {
1361
-            case 'all':            // (optional) compositor content for a complexType
1362
-            case 'choice':
1363
-            case 'group':
1364
-            case 'sequence':
1365
-                //$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
1366
-                $this->complexTypes[$this->currentComplexType]['compositor'] = $name;
1367
-                //if($name == 'all' || $name == 'sequence'){
1368
-                //	$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1369
-                //}
1370
-                break;
1371
-            case 'attribute':    // complexType attribute
1372
-                //$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
1373
-                $this->xdebug("parsing attribute:");
1374
-                $this->appendDebug($this->varDump($attrs));
1375
-                if (!isset($attrs['form'])) {
1376
-                    // TODO: handle globals
1377
-                    $attrs['form'] = $this->schemaInfo['attributeFormDefault'];
1378
-                }
1379
-                if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1380
-                    $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1381
-                    if (!strpos($v, ':')) {
1382
-                        // no namespace in arrayType attribute value...
1383
-                        if ($this->defaultNamespace[$pos]) {
1384
-                            // ...so use the default
1385
-                            $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1386
-                        }
1387
-                    }
1388
-                }
1389
-                if (isset($attrs['name'])) {
1390
-                    $this->attributes[$attrs['name']] = $attrs;
1391
-                    $aname = $attrs['name'];
1392
-                } elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
1393
-                    if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1394
-                        $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1395
-                    } else {
1396
-                        $aname = '';
1397
-                    }
1398
-                } elseif (isset($attrs['ref'])) {
1399
-                    $aname = $attrs['ref'];
1400
-                    $this->attributes[$attrs['ref']] = $attrs;
1401
-                } else {
1402
-                    $aname = '';
1403
-                }
1404
-
1405
-                if ($this->currentComplexType) {    // This should *always* be
1406
-                    $this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
1407
-                }
1408
-                // arrayType attribute
1409
-                if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
1410
-                    $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1411
-                    if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1412
-                        $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1413
-                    } else {
1414
-                        $v = '';
1415
-                    }
1416
-                    if (strpos($v, '[,]')) {
1417
-                        $this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
1418
-                    }
1419
-                    $v = substr($v, 0, strpos($v, '[')); // clip the []
1420
-                    if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
1421
-                        $v = $this->XMLSchemaVersion . ':' . $v;
1422
-                    }
1423
-                    $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
1424
-                }
1425
-                break;
1426
-            case 'complexContent':    // (optional) content for a complexType
1427
-                $this->xdebug("do nothing for element $name");
1428
-                break;
1429
-            case 'complexType':
1430
-                $this->complexTypeStack[] = $this->currentComplexType;
1431
-                if (isset($attrs['name'])) {
1432
-                    // TODO: what is the scope of named complexTypes that appear
1433
-                    //       nested within other c complexTypes?
1434
-                    $this->xdebug('processing named complexType ' . $attrs['name']);
1435
-                    //$this->currentElement = false;
1436
-                    $this->currentComplexType = $attrs['name'];
1437
-                } else {
1438
-                    $name = $this->CreateTypeName($this->currentElement);
1439
-                    $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
1440
-                    $this->currentComplexType = $name;
1441
-                    //$this->currentElement = false;
1442
-                }
1443
-                $this->complexTypes[$this->currentComplexType] = $attrs;
1444
-                $this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1445
-                // This is for constructs like
1446
-                //           <complexType name="ListOfString" base="soap:Array">
1447
-                //                <sequence>
1448
-                //                    <element name="string" type="xsd:string"
1449
-                //                        minOccurs="0" maxOccurs="unbounded" />
1450
-                //                </sequence>
1451
-                //            </complexType>
1452
-                if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
1453
-                    $this->xdebug('complexType is unusual array');
1454
-                    $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1455
-                } else {
1456
-                    $this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1457
-                }
1458
-                $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
1459
-                break;
1460
-            case 'element':
1461
-                $this->elementStack[] = $this->currentElement;
1462
-                if (!isset($attrs['form'])) {
1463
-                    if ($this->currentComplexType) {
1464
-                        $attrs['form'] = $this->schemaInfo['elementFormDefault'];
1465
-                    } else {
1466
-                        // global
1467
-                        $attrs['form'] = 'qualified';
1468
-                    }
1469
-                }
1470
-                if (isset($attrs['type'])) {
1471
-                    $this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']);
1472
-                    if (!$this->getPrefix($attrs['type'])) {
1473
-                        if ($this->defaultNamespace[$pos]) {
1474
-                            $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1475
-                            $this->xdebug('used default namespace to make type ' . $attrs['type']);
1476
-                        }
1477
-                    }
1478
-                    // This is for constructs like
1479
-                    //           <complexType name="ListOfString" base="soap:Array">
1480
-                    //                <sequence>
1481
-                    //                    <element name="string" type="xsd:string"
1482
-                    //                        minOccurs="0" maxOccurs="unbounded" />
1483
-                    //                </sequence>
1484
-                    //            </complexType>
1485
-                    if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
1486
-                        $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
1487
-                        $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
1488
-                    }
1489
-                    $this->currentElement = $attrs['name'];
1490
-                    $ename = $attrs['name'];
1491
-                } elseif (isset($attrs['ref'])) {
1492
-                    $this->xdebug("processing element as ref to " . $attrs['ref']);
1493
-                    $this->currentElement = "ref to " . $attrs['ref'];
1494
-                    $ename = $this->getLocalPart($attrs['ref']);
1495
-                } else {
1496
-                    $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
1497
-                    $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
1498
-                    $this->currentElement = $attrs['name'];
1499
-                    $attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
1500
-                    $ename = $attrs['name'];
1501
-                }
1502
-                if (isset($ename) && $this->currentComplexType) {
1503
-                    $this->xdebug("add element $ename to complexType $this->currentComplexType");
1504
-                    $this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
1505
-                } elseif (!isset($attrs['ref'])) {
1506
-                    $this->xdebug("add element $ename to elements array");
1507
-                    $this->elements[$attrs['name']] = $attrs;
1508
-                    $this->elements[$attrs['name']]['typeClass'] = 'element';
1509
-                }
1510
-                break;
1511
-            case 'enumeration':    //	restriction value list member
1512
-                $this->xdebug('enumeration ' . $attrs['value']);
1513
-                if ($this->currentSimpleType) {
1514
-                    $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
1515
-                } elseif ($this->currentComplexType) {
1516
-                    $this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
1517
-                }
1518
-                break;
1519
-            case 'extension':    // simpleContent or complexContent type extension
1520
-                $this->xdebug('extension ' . $attrs['base']);
1521
-                if ($this->currentComplexType) {
1522
-                    $ns = $this->getPrefix($attrs['base']);
1523
-                    if ($ns == '') {
1524
-                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
1525
-                    } else {
1526
-                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
1527
-                    }
1528
-                } else {
1529
-                    $this->xdebug('no current complexType to set extensionBase');
1530
-                }
1531
-                break;
1532
-            case 'import':
1533
-                if (isset($attrs['schemaLocation'])) {
1534
-                    $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
1535
-                    $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1536
-                } else {
1537
-                    $this->xdebug('import namespace ' . $attrs['namespace']);
1538
-                    $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1539
-                    if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
1540
-                        $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
1541
-                    }
1542
-                }
1543
-                break;
1544
-            case 'include':
1545
-                if (isset($attrs['schemaLocation'])) {
1546
-                    $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
1547
-                    $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1548
-                } else {
1549
-                    $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
1550
-                }
1551
-                break;
1552
-            case 'list':    // simpleType value list
1553
-                $this->xdebug("do nothing for element $name");
1554
-                break;
1555
-            case 'restriction':    // simpleType, simpleContent or complexContent value restriction
1556
-                $this->xdebug('restriction ' . $attrs['base']);
1557
-                if ($this->currentSimpleType) {
1558
-                    $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1559
-                } elseif ($this->currentComplexType) {
1560
-                    $this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
1561
-                    if (strstr($attrs['base'], ':') == ':Array') {
1562
-                        $this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1563
-                    }
1564
-                }
1565
-                break;
1566
-            case 'schema':
1567
-                $this->schemaInfo = $attrs;
1568
-                $this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
1569
-                if (isset($attrs['targetNamespace'])) {
1570
-                    $this->schemaTargetNamespace = $attrs['targetNamespace'];
1571
-                }
1572
-                if (!isset($attrs['elementFormDefault'])) {
1573
-                    $this->schemaInfo['elementFormDefault'] = 'unqualified';
1574
-                }
1575
-                if (!isset($attrs['attributeFormDefault'])) {
1576
-                    $this->schemaInfo['attributeFormDefault'] = 'unqualified';
1577
-                }
1578
-                break;
1579
-            case 'simpleContent':    // (optional) content for a complexType
1580
-                if ($this->currentComplexType) {    // This should *always* be
1581
-                    $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
1582
-                } else {
1583
-                    $this->xdebug("do nothing for element $name because there is no current complexType");
1584
-                }
1585
-                break;
1586
-            case 'simpleType':
1587
-                $this->simpleTypeStack[] = $this->currentSimpleType;
1588
-                if (isset($attrs['name'])) {
1589
-                    $this->xdebug("processing simpleType for name " . $attrs['name']);
1590
-                    $this->currentSimpleType = $attrs['name'];
1591
-                    $this->simpleTypes[$attrs['name']] = $attrs;
1592
-                    $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
1593
-                    $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
1594
-                } else {
1595
-                    $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
1596
-                    $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
1597
-                    $this->currentSimpleType = $name;
1598
-                    //$this->currentElement = false;
1599
-                    $this->simpleTypes[$this->currentSimpleType] = $attrs;
1600
-                    $this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
1601
-                }
1602
-                break;
1603
-            case 'union':    // simpleType type list
1604
-                $this->xdebug("do nothing for element $name");
1605
-                break;
1606
-            default:
1607
-                $this->xdebug("do not have any logic to process element $name");
1608
-        }
1609
-    }
1610
-
1611
-    /**
1612
-     * end-element handler
1613
-     *
1614
-     * @param    string $parser XML parser object
1615
-     * @param    string $name element name
1616
-     * @access   private
1617
-     */
1618
-    function schemaEndElement($parser, $name)
1619
-    {
1620
-        // bring depth down a notch
1621
-        $this->depth--;
1622
-        // get element prefix
1623
-        if ($this->getPrefix($name)) {
1624
-            // get unqualified name
1625
-            $name = $this->getLocalPart($name);
1626
-        }
1627
-        // move on...
1628
-        if ($name == 'complexType') {
1629
-            $this->xdebug('done processing complexType ' . ($this->currentComplexType ?: '(unknown)'));
1630
-            $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
1631
-            $this->currentComplexType = array_pop($this->complexTypeStack);
1632
-            //$this->currentElement = false;
1633
-        }
1634
-        if ($name == 'element') {
1635
-            $this->xdebug('done processing element ' . ($this->currentElement ?: '(unknown)'));
1636
-            $this->currentElement = array_pop($this->elementStack);
1637
-        }
1638
-        if ($name == 'simpleType') {
1639
-            $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ?: '(unknown)'));
1640
-            $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
1641
-            $this->currentSimpleType = array_pop($this->simpleTypeStack);
1642
-        }
1643
-    }
1644
-
1645
-    /**
1646
-     * element content handler
1647
-     *
1648
-     * @param    string $parser XML parser object
1649
-     * @param    string $data element content
1650
-     * @access   private
1651
-     */
1652
-    function schemaCharacterData($parser, $data)
1653
-    {
1654
-        $pos = $this->depth_array[$this->depth - 1];
1655
-        $this->message[$pos]['cdata'] .= $data;
1656
-    }
1657
-
1658
-    /**
1659
-     * serialize the schema
1660
-     *
1661
-     * @access   public
1662
-     */
1663
-    function serializeSchema()
1664
-    {
1665
-
1666
-        $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
1667
-        $xml = '';
1668
-        // imports
1669
-        if (sizeof($this->imports) > 0) {
1670
-            foreach ($this->imports as $ns => $list) {
1671
-                foreach ($list as $ii) {
1672
-                    if ($ii['location'] != '') {
1673
-                        $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
1674
-                    } else {
1675
-                        $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
1676
-                    }
1677
-                }
1678
-            }
1679
-        }
1680
-        // complex types
1681
-        foreach ($this->complexTypes as $typeName => $attrs) {
1682
-            $contentStr = '';
1683
-            // serialize child elements
1684
-            if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
1685
-                foreach ($attrs['elements'] as $element => $eParts) {
1686
-                    if (isset($eParts['ref'])) {
1687
-                        $contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
1688
-                    } else {
1689
-                        $contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
1690
-                        foreach ($eParts as $aName => $aValue) {
1691
-                            // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
1692
-                            if ($aName != 'name' && $aName != 'type') {
1693
-                                $contentStr .= " $aName=\"$aValue\"";
1694
-                            }
1695
-                        }
1696
-                        $contentStr .= "/>\n";
1697
-                    }
1698
-                }
1699
-                // compositor wraps elements
1700
-                if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
1701
-                    $contentStr = "  <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . "  </$schemaPrefix:$attrs[compositor]>\n";
1702
-                }
1703
-            }
1704
-            // attributes
1705
-            if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
1706
-                foreach ($attrs['attrs'] as $aParts) {
1707
-                    $contentStr .= "    <$schemaPrefix:attribute";
1708
-                    foreach ($aParts as $a => $v) {
1709
-                        if ($a == 'ref' || $a == 'type') {
1710
-                            $contentStr .= " $a=\"" . $this->contractQName($v) . '"';
1711
-                        } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
1712
-                            $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1713
-                            $contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"';
1714
-                        } else {
1715
-                            $contentStr .= " $a=\"$v\"";
1716
-                        }
1717
-                    }
1718
-                    $contentStr .= "/>\n";
1719
-                }
1720
-            }
1721
-            // if restriction
1722
-            if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
1723
-                $contentStr = "   <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . "   </$schemaPrefix:restriction>\n";
1724
-                // complex or simple content
1725
-                if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
1726
-                    $contentStr = "  <$schemaPrefix:complexContent>\n" . $contentStr . "  </$schemaPrefix:complexContent>\n";
1727
-                }
1728
-            }
1729
-            // finalize complex type
1730
-            if ($contentStr != '') {
1731
-                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " </$schemaPrefix:complexType>\n";
1732
-            } else {
1733
-                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1734
-            }
1735
-            $xml .= $contentStr;
1736
-        }
1737
-        // simple types
1738
-        if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
1739
-            foreach ($this->simpleTypes as $typeName => $eParts) {
1740
-                $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts['type']) . "\">\n";
1741
-                if (isset($eParts['enumeration'])) {
1742
-                    foreach ($eParts['enumeration'] as $e) {
1743
-                        $xml .= "  <$schemaPrefix:enumeration value=\"$e\"/>\n";
1744
-                    }
1745
-                }
1746
-                $xml .= "  </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
1747
-            }
1748
-        }
1749
-        // elements
1750
-        if (isset($this->elements) && count($this->elements) > 0) {
1751
-            foreach ($this->elements as $element => $eParts) {
1752
-                $xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
1753
-            }
1754
-        }
1755
-        // attributes
1756
-        if (isset($this->attributes) && count($this->attributes) > 0) {
1757
-            foreach ($this->attributes as $attr => $aParts) {
1758
-                $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n/>";
1759
-            }
1760
-        }
1761
-        // finish 'er up
1762
-        $attr = '';
1763
-        foreach ($this->schemaInfo as $k => $v) {
1764
-            if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
1765
-                $attr .= " $k=\"$v\"";
1766
-            }
1767
-        }
1768
-        $el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
1769
-        foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1770
-            $el .= " xmlns:$nsp=\"$ns\"";
1771
-        }
1772
-
1773
-      return $el . ">\n" . $xml . "</$schemaPrefix:schema>\n";
1774
-    }
1775
-
1776
-    /**
1777
-     * adds debug data to the clas level debug string
1778
-     *
1779
-     * @param    string $string debug data
1780
-     * @access   private
1781
-     */
1782
-    function xdebug($string)
1783
-    {
1784
-        $this->debug('<' . $this->schemaTargetNamespace . '> ' . $string);
1785
-    }
1786
-
1787
-    /**
1788
-     * get the PHP type of a user defined type in the schema
1789
-     * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
1790
-     * returns false if no type exists, or not w/ the given namespace
1791
-     * else returns a string that is either a native php type, or 'struct'
1792
-     *
1793
-     * @param string $type name of defined type
1794
-     * @param string $ns namespace of type
1795
-     * @return mixed
1796
-     * @access public
1797
-     * @deprecated
1798
-     */
1799
-    function getPHPType($type, $ns)
1800
-    {
1801
-        if (isset($this->typemap[$ns][$type])) {
1802
-            //print "found type '$type' and ns $ns in typemap<br>";
1803
-            return $this->typemap[$ns][$type];
1804
-        } elseif (isset($this->complexTypes[$type])) {
1805
-            //print "getting type '$type' and ns $ns from complexTypes array<br>";
1806
-            return $this->complexTypes[$type]['phpType'];
1807
-        }
1808
-        return false;
1809
-    }
1810
-
1811
-    /**
1812
-     * returns an associative array of information about a given type
1813
-     * returns false if no type exists by the given name
1814
-     *
1815
-     *    For a complexType typeDef = array(
1816
-     *    'restrictionBase' => '',
1817
-     *    'phpType' => '',
1818
-     *    'compositor' => '(sequence|all)',
1819
-     *    'elements' => array(), // refs to elements array
1820
-     *    'attrs' => array() // refs to attributes array
1821
-     *    ... and so on (see addComplexType)
1822
-     *    )
1823
-     *
1824
-     *   For simpleType or element, the array has different keys.
1825
-     *
1826
-     * @param string $type
1827
-     * @return mixed
1828
-     * @access public
1829
-     * @see addComplexType
1830
-     * @see addSimpleType
1831
-     * @see addElement
1832
-     */
1833
-    function getTypeDef($type)
1834
-    {
1835
-        //$this->debug("in getTypeDef for type $type");
1836
-        if (substr($type, -1) == '^') {
1837
-            $is_element = 1;
1838
-            $type = substr($type, 0, -1);
1839
-        } else {
1840
-            $is_element = 0;
1841
-        }
1842
-
1843
-        if ((!$is_element) && isset($this->complexTypes[$type])) {
1844
-            $this->xdebug("in getTypeDef, found complexType $type");
1845
-            return $this->complexTypes[$type];
1846
-        } elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
1847
-            $this->xdebug("in getTypeDef, found simpleType $type");
1848
-            if (!isset($this->simpleTypes[$type]['phpType'])) {
1849
-                // get info for type to tack onto the simple type
1850
-                // TODO: can this ever really apply (i.e. what is a simpleType really?)
1851
-                $uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
1852
-                $etype = $this->getTypeDef($uqType);
1853
-                if ($etype) {
1854
-                    $this->xdebug("in getTypeDef, found type for simpleType $type:");
1855
-                    $this->xdebug($this->varDump($etype));
1856
-                    if (isset($etype['phpType'])) {
1857
-                        $this->simpleTypes[$type]['phpType'] = $etype['phpType'];
1858
-                    }
1859
-                    if (isset($etype['elements'])) {
1860
-                        $this->simpleTypes[$type]['elements'] = $etype['elements'];
1861
-                    }
1862
-                }
1863
-            }
1864
-            return $this->simpleTypes[$type];
1865
-        } elseif (isset($this->elements[$type])) {
1866
-            $this->xdebug("in getTypeDef, found element $type");
1867
-            if (!isset($this->elements[$type]['phpType'])) {
1868
-                // get info for type to tack onto the element
1869
-                $uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
1870
-                $ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
1871
-                $etype = $this->getTypeDef($uqType);
1872
-                if ($etype) {
1873
-                    $this->xdebug("in getTypeDef, found type for element $type:");
1874
-                    $this->xdebug($this->varDump($etype));
1875
-                    if (isset($etype['phpType'])) {
1876
-                        $this->elements[$type]['phpType'] = $etype['phpType'];
1877
-                    }
1878
-                    if (isset($etype['elements'])) {
1879
-                        $this->elements[$type]['elements'] = $etype['elements'];
1880
-                    }
1881
-                    if (isset($etype['extensionBase'])) {
1882
-                        $this->elements[$type]['extensionBase'] = $etype['extensionBase'];
1883
-                    }
1884
-                } elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
1885
-                    $this->xdebug("in getTypeDef, element $type is an XSD type");
1886
-                    $this->elements[$type]['phpType'] = 'scalar';
1887
-                }
1888
-            }
1889
-            return $this->elements[$type];
1890
-        } elseif (isset($this->attributes[$type])) {
1891
-            $this->xdebug("in getTypeDef, found attribute $type");
1892
-            return $this->attributes[$type];
1893
-        } elseif (preg_match('/_ContainedType$/', $type)) {
1894
-            $this->xdebug("in getTypeDef, have an untyped element $type");
1895
-            $typeDef['typeClass'] = 'simpleType';
1896
-            $typeDef['phpType'] = 'scalar';
1897
-            $typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
1898
-            return $typeDef;
1899
-        }
1900
-        $this->xdebug("in getTypeDef, did not find $type");
1901
-        return false;
1902
-    }
1903
-
1904
-    /**
1905
-     * returns a sample serialization of a given type, or false if no type by the given name
1906
-     *
1907
-     * @param string $type name of type
1908
-     * @return false|string
1909
-     * @access public
1910
-     */
1911
-    function serializeTypeDef($type)
1912
-    {
1913
-        $str = '';
1914
-        //print "in sTD() for type $type<br>";
1915
-        if ($typeDef = $this->getTypeDef($type)) {
1916
-            $str .= '<' . $type;
1917
-            if (is_array($typeDef['attrs'])) {
1918
-                foreach ($typeDef['attrs'] as $attName => $data) {
1919
-                    $str .= " $attName=\"{type = " . $data['type'] . "}\"";
1920
-                }
1921
-            }
1922
-            $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
1923
-            if (count($typeDef['elements']) > 0) {
1924
-                $str .= ">";
1925
-                foreach ($typeDef['elements'] as $element => $eData) {
1926
-                    $str .= $this->serializeTypeDef($element);
1927
-                }
1928
-                $str .= "</$type>";
1929
-            } elseif ($typeDef['typeClass'] == 'element') {
1930
-                $str .= "></$type>";
1931
-            } else {
1932
-                $str .= "/>";
1933
-            }
1934
-            return $str;
1935
-        }
1936
-        return false;
1937
-    }
1938
-
1939
-    /**
1940
-     * returns HTML form elements that allow a user
1941
-     * to enter values for creating an instance of the given type.
1942
-     *
1943
-     * @param string $name name for type instance
1944
-     * @param string $type name of type
1945
-     * @return string
1946
-     * @access public
1947
-     * @deprecated
1948
-     */
1949
-    function typeToForm($name, $type)
1950
-    {
1951
-        $buffer = '';
1952
-        // get typedef
1953
-        if ($typeDef = $this->getTypeDef($type)) {
1954
-            // if struct
1955
-            if ($typeDef['phpType'] == 'struct') {
1956
-                $buffer .= '<table>';
1957
-                foreach ($typeDef['elements'] as $childDef) {
1958
-                    $buffer .= "
1959
-					<tr><td align='right'>$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):</td>
1960
-					<td><input type='text' name='parameters[" . $name . "][$childDef[name]]'></td></tr>";
1961
-                }
1962
-                $buffer .= '</table>';
1963
-                // if array
1964
-            } elseif ($typeDef['phpType'] == 'array') {
1965
-                $buffer .= '<table>';
1966
-              $buffer .= str_repeat ("
1967
-					<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1968
-					<td><input type='text' name='parameters[" . $name . "][]'></td></tr>", 3);
1969
-                $buffer .= '</table>';
1970
-                // if scalar
1971
-            } else {
1972
-                $buffer .= "<input type='text' name='parameters[$name]'>";
1973
-            }
1974
-        } else {
1975
-            $buffer .= "<input type='text' name='parameters[$name]'>";
1976
-        }
1977
-        return $buffer;
1978
-    }
1979
-
1980
-    /**
1981
-     * adds a complex type to the schema
1982
-     * example: array
1983
-     * addType(
1984
-     *    'ArrayOfstring',
1985
-     *    'complexType',
1986
-     *    'array',
1987
-     *    '',
1988
-     *    'SOAP-ENC:Array',
1989
-     *    array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
1990
-     *    'xsd:string'
1991
-     * );
1992
-     * example: PHP associative array ( SOAP Struct )
1993
-     * addType(
1994
-     *    'SOAPStruct',
1995
-     *    'complexType',
1996
-     *    'struct',
1997
-     *    'all',
1998
-     *    array('myVar'=> array('name'=>'myVar','type'=>'string')
1999
-     * );
2000
-     *
2001
-     * @param string $name
2002
-     * @param string $typeClass (complexType|simpleType|attribute)
2003
-     * @param string $phpType : currently supported are array and struct (php assoc array)
2004
-     * @param string $compositor (all|sequence|choice)
2005
-     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
2006
-     * @param array $elements = array ( name = array(name=>'',type=>'') )
2007
-     * @param array $attrs = array(
2008
-     *    array(
2009
-     *        'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
2010
-     *        "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
2011
-     *    )
2012
-     * )
2013
-     * @param array $arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string)
2014
-     *
2015
-     * @access public
2016
-     * @see getTypeDef
2017
-     */
2018
-    function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '')
2019
-    {
2020
-        $this->complexTypes[$name] = array(
2021
-            'name' => $name,
2022
-            'typeClass' => $typeClass,
2023
-            'phpType' => $phpType,
2024
-            'compositor' => $compositor,
2025
-            'restrictionBase' => $restrictionBase,
2026
-            'elements' => $elements,
2027
-            'attrs' => $attrs,
2028
-            'arrayType' => $arrayType
2029
-        );
2030
-
2031
-        $this->xdebug("addComplexType $name:");
2032
-        $this->appendDebug($this->varDump($this->complexTypes[$name]));
2033
-    }
2034
-
2035
-    /**
2036
-     * adds a simple type to the schema
2037
-     *
2038
-     * @param string $name
2039
-     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
2040
-     * @param string $typeClass (should always be simpleType)
2041
-     * @param string $phpType (should always be scalar)
2042
-     * @param array $enumeration array of values
2043
-     * @access public
2044
-     * @see nusoap_xmlschema
2045
-     * @see getTypeDef
2046
-     */
2047
-    function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array())
2048
-    {
2049
-        $this->simpleTypes[$name] = array(
2050
-            'name' => $name,
2051
-            'typeClass' => $typeClass,
2052
-            'phpType' => $phpType,
2053
-            'type' => $restrictionBase,
2054
-            'enumeration' => $enumeration
2055
-        );
2056
-
2057
-        $this->xdebug("addSimpleType $name:");
2058
-        $this->appendDebug($this->varDump($this->simpleTypes[$name]));
2059
-    }
2060
-
2061
-    /**
2062
-     * adds an element to the schema
2063
-     *
2064
-     * @param array $attrs attributes that must include name and type
2065
-     * @see nusoap_xmlschema
2066
-     * @access public
2067
-     */
2068
-    function addElement($attrs)
2069
-    {
2070
-        if (!$this->getPrefix($attrs['type'])) {
2071
-            $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
2072
-        }
2073
-        $this->elements[$attrs['name']] = $attrs;
2074
-        $this->elements[$attrs['name']]['typeClass'] = 'element';
2075
-
2076
-        $this->xdebug("addElement " . $attrs['name']);
2077
-        $this->appendDebug($this->varDump($this->elements[$attrs['name']]));
2078
-    }
2079
-}
1137
+	// files
1138
+	var $schema = '';
1139
+	var $xml = '';
1140
+	// namespaces
1141
+	var $enclosingNamespaces;
1142
+	// schema info
1143
+	var $schemaInfo = array();
1144
+	var $schemaTargetNamespace = '';
1145
+	// types, elements, attributes defined by the schema
1146
+	var $attributes = array();
1147
+	var $complexTypes = array();
1148
+	var $complexTypeStack = array();
1149
+	var $currentComplexType = null;
1150
+	var $elements = array();
1151
+	var $elementStack = array();
1152
+	var $currentElement = null;
1153
+	var $simpleTypes = array();
1154
+	var $simpleTypeStack = array();
1155
+	var $currentSimpleType = null;
1156
+	// imports
1157
+	var $imports = array();
1158
+	// parser vars
1159
+	var $parser;
1160
+	var $position = 0;
1161
+	var $depth = 0;
1162
+	var $depth_array = array();
1163
+	var $message = array();
1164
+	var $defaultNamespace = array();
1165
+
1166
+	/**
1167
+	 * constructor
1168
+	 *
1169
+	 * @param    string $schema schema document URI
1170
+	 * @param    string $xml xml document URI
1171
+	 * @param    string $namespaces namespaces defined in enclosing XML
1172
+	 * @access   public
1173
+	 */
1174
+	function __construct($schema = '', $xml = '', $namespaces = array())
1175
+	{
1176
+		parent::__construct();
1177
+		$this->debug('nusoap_xmlschema class instantiated, inside constructor');
1178
+		// files
1179
+		$this->schema = $schema;
1180
+		$this->xml = $xml;
1181
+
1182
+		// namespaces
1183
+		$this->enclosingNamespaces = $namespaces;
1184
+		$this->namespaces = array_merge($this->namespaces, $namespaces);
1185
+
1186
+		// parse schema file
1187
+		if ($schema != '') {
1188
+			$this->debug('initial schema file: ' . $schema);
1189
+			$this->parseFile($schema, 'schema');
1190
+		}
2080 1191
 
2081
-/**
2082
- * Backward compatibility
2083
- */
2084
-class XMLSchema extends nusoap_xmlschema
2085
-{
2086
-}
1192
+		// parse xml file
1193
+		if ($xml != '') {
1194
+			$this->debug('initial xml file: ' . $xml);
1195
+			$this->parseFile($xml, 'xml');
1196
+		}
2087 1197
 
1198
+	}
2088 1199
 
2089
-/**
2090
- * For creating serializable abstractions of native PHP types.  This class
2091
- * allows element name/namespace, XSD type, and XML attributes to be
2092
- * associated with a value.  This is extremely useful when WSDL is not
2093
- * used, but is also useful when WSDL is used with polymorphic types, including
2094
- * xsd:anyType and user-defined types.
2095
- *
2096
- * @author   Dietrich Ayala <[email protected]>
2097
- * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
2098
- * @access   public
2099
- */
2100
-class soapval extends nusoap_base
2101
-{
2102
-    /**
2103
-     * The XML element name
2104
-     *
2105
-     * @var string
2106
-     * @access private
2107
-     */
2108
-    var $name;
2109
-    /**
2110
-     * The XML type name (string or false)
2111
-     *
2112
-     * @var mixed
2113
-     * @access private
2114
-     */
2115
-    var $type;
2116
-    /**
2117
-     * The PHP value
2118
-     *
2119
-     * @var mixed
2120
-     * @access private
2121
-     */
2122
-    var $value;
2123
-    /**
2124
-     * The XML element namespace (string or false)
2125
-     *
2126
-     * @var mixed
2127
-     * @access private
2128
-     */
2129
-    var $element_ns;
2130
-    /**
2131
-     * The XML type namespace (string or false)
2132
-     *
2133
-     * @var mixed
2134
-     * @access private
2135
-     */
2136
-    var $type_ns;
2137
-    /**
2138
-     * The XML element attributes (array or false)
2139
-     *
2140
-     * @var mixed
2141
-     * @access private
2142
-     */
2143
-    var $attributes;
2144
-
2145
-    /** @var false|resource */
2146
-    var $fp;
2147
-
2148
-    /**
2149
-     * constructor
2150
-     *
2151
-     * @param    string $name optional name
2152
-     * @param    mixed $type optional type name
2153
-     * @param    mixed $value optional value
2154
-     * @param    mixed $element_ns optional namespace of value
2155
-     * @param    mixed $type_ns optional namespace of type
2156
-     * @param    mixed $attributes associative array of attributes to add to element serialization
2157
-     * @access   public
2158
-     */
2159
-    function __construct($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false)
2160
-    {
2161
-        parent::__construct();
2162
-        $this->name = $name;
2163
-        $this->type = $type;
2164
-        $this->value = $value;
2165
-        $this->element_ns = $element_ns;
2166
-        $this->type_ns = $type_ns;
2167
-        $this->attributes = $attributes;
2168
-    }
2169
-
2170
-    /**
2171
-     * return serialized value
2172
-     *
2173
-     * @param    string $use The WSDL use value (encoded|literal)
2174
-     * @return    string XML data
2175
-     * @access   public
2176
-     */
2177
-    function serialize($use = 'encoded')
2178
-    {
2179
-        return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
2180
-    }
2181
-
2182
-    /**
2183
-     * decodes a soapval object into a PHP native type
2184
-     *
2185
-     * @return    mixed
2186
-     * @access   public
2187
-     */
2188
-    function decode()
2189
-    {
2190
-        return $this->value;
2191
-    }
2192
-}
1200
+	/**
1201
+	 * parse an XML file
1202
+	 *
1203
+	 * @param string $xml path/URL to XML file
1204
+	 * @param string $type (schema | xml)
1205
+	 * @return boolean
1206
+	 * @access public
1207
+	 */
1208
+	function parseFile($xml, $type)
1209
+	{
1210
+		// parse xml file
1211
+		if ($xml != "") {
1212
+			$xmlStr = @join("", @file($xml));
1213
+			if ($xmlStr == "") {
1214
+				$msg = 'Error reading XML from ' . $xml;
1215
+				$this->setError($msg);
1216
+				$this->debug($msg);
1217
+				return false;
1218
+			} else {
1219
+				$this->debug("parsing $xml");
1220
+				$this->parseString($xmlStr, $type);
1221
+				$this->debug("done parsing $xml");
1222
+				return true;
1223
+			}
1224
+		}
1225
+		return false;
1226
+	}
2193 1227
 
1228
+	/**
1229
+	 * parse an XML string
1230
+	 *
1231
+	 * @param    string $xml path or URL
1232
+	 * @param    string $type (schema|xml)
1233
+	 * @access   private
1234
+	 */
1235
+	function parseString($xml, $type)
1236
+	{
1237
+		// parse xml string
1238
+		if ($xml != "") {
1239
+
1240
+			// Create an XML parser.
1241
+			$this->parser = xml_parser_create();
1242
+			// Set the options for parsing the XML data.
1243
+			xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
1244
+
1245
+			// Set the object for the parser.
1246
+			xml_set_object($this->parser, $this);
1247
+
1248
+			// Set the element handlers for the parser.
1249
+			if ($type == "schema") {
1250
+				xml_set_element_handler($this->parser, 'schemaStartElement', 'schemaEndElement');
1251
+				xml_set_character_data_handler($this->parser, 'schemaCharacterData');
1252
+			} elseif ($type == "xml") {
1253
+				xml_set_element_handler($this->parser, 'xmlStartElement', 'xmlEndElement');
1254
+				xml_set_character_data_handler($this->parser, 'xmlCharacterData');
1255
+			}
2194 1256
 
2195
-/**
2196
- * transport class for sending/receiving data via HTTP and HTTPS
2197
- * NOTE: PHP must be compiled with the CURL extension for HTTPS support
2198
- *
2199
- * @author   Dietrich Ayala <[email protected]>
2200
- * @author   Scott Nichol <[email protected]>
2201
- * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
2202
- * @access public
2203
- */
2204
-class soap_transport_http extends nusoap_base
2205
-{
1257
+			libxml_disable_entity_loader(true);	// Avoid load of external entities (security problem). Required only for libxml < 2.
1258
+
1259
+			// Parse the XML file.
1260
+			if (!xml_parse($this->parser, $xml, true)) {
1261
+				// Display an error message.
1262
+				$errstr = sprintf('XML error parsing XML schema on line %d: %s',
1263
+					xml_get_current_line_number($this->parser),
1264
+					xml_error_string(xml_get_error_code($this->parser))
1265
+				);
1266
+				$this->debug($errstr);
1267
+				$this->debug("XML payload:\n" . $xml);
1268
+				$this->setError($errstr);
1269
+			}
2206 1270
 
2207
-    var $query = '';
2208
-    var $tryagain = false;
2209
-    var $url = '';
2210
-    var $uri = '';
2211
-    var $digest_uri = '';
2212
-    var $scheme = '';
2213
-    var $host = '';
2214
-    var $port = '';
2215
-    var $path = '';
2216
-    var $request_method = 'POST';
2217
-    var $protocol_version = '1.0';
2218
-    var $encoding = '';
2219
-    var $outgoing_headers = array();
2220
-    var $incoming_headers = array();
2221
-    var $incoming_cookies = array();
2222
-    var $outgoing_payload = '';
2223
-    var $incoming_payload = '';
2224
-    var $response_status_line;    // HTTP response status line
2225
-    var $useSOAPAction = true;
2226
-    var $persistentConnection = false;
2227
-    var $ch = false;    // cURL handle
2228
-    var $ch_options = array();    // cURL custom options
2229
-    var $use_curl = false;        // force cURL use
2230
-    var $proxy = null;            // proxy information (associative array)
2231
-    var $username = '';
2232
-    var $password = '';
2233
-    var $authtype = '';
2234
-    var $digestRequest = array();
2235
-    var $certRequest = array();    // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
2236
-    // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
2237
-    // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
2238
-    // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
2239
-    // passphrase: SSL key password/passphrase
2240
-    // certpassword: SSL certificate password
2241
-    // verifypeer: default is 1
2242
-    // verifyhost: default is 1
2243
-
2244
-    /** @var false|resource */
2245
-    var $fp;
2246
-    var $errno;
2247
-
2248
-    /**
2249
-     * constructor
2250
-     *
2251
-     * @param string $url The URL to which to connect
2252
-     * @param array $curl_options User-specified cURL options
2253
-     * @param boolean $use_curl Whether to try to force cURL use
2254
-     * @access public
2255
-     */
2256
-    function __construct($url, $curl_options = null, $use_curl = false)
2257
-    {
2258
-        parent::__construct();
2259
-        $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2260
-        $this->appendDebug($this->varDump($curl_options));
2261
-        $this->setURL($url);
2262
-        if (is_array($curl_options)) {
2263
-            $this->ch_options = $curl_options;
2264
-        }
2265
-        $this->use_curl = $use_curl;
2266
-        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2267
-        $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . $rev[1] . ')');
2268
-    }
2269
-
2270
-    /**
2271
-     * sets a cURL option
2272
-     *
2273
-     * @param    mixed $option The cURL option (always integer?)
2274
-     * @param    mixed $value The cURL option value
2275
-     * @access   private
2276
-     */
2277
-    function setCurlOption($option, $value)
2278
-    {
2279
-        $this->debug("setCurlOption option=$option, value=");
2280
-        $this->appendDebug($this->varDump($value));
2281
-        curl_setopt($this->ch, $option, $value);
2282
-    }
2283
-
2284
-    /**
2285
-     * sets an HTTP header
2286
-     *
2287
-     * @param string $name The name of the header
2288
-     * @param string $value The value of the header
2289
-     * @access private
2290
-     */
2291
-    function setHeader($name, $value)
2292
-    {
2293
-        $this->outgoing_headers[$name] = $value;
2294
-        $this->debug("set header $name: $value");
2295
-    }
2296
-
2297
-    /**
2298
-     * unsets an HTTP header
2299
-     *
2300
-     * @param string $name The name of the header
2301
-     * @access private
2302
-     */
2303
-    function unsetHeader($name)
2304
-    {
2305
-        if (isset($this->outgoing_headers[$name])) {
2306
-            $this->debug("unset header $name");
2307
-            unset($this->outgoing_headers[$name]);
2308
-        }
2309
-    }
2310
-
2311
-    /**
2312
-     * sets the URL to which to connect
2313
-     *
2314
-     * @param string $url The URL to which to connect
2315
-     * @access private
2316
-     */
2317
-    function setURL($url)
2318
-    {
2319
-        $this->url = $url;
2320
-
2321
-        $u = parse_url($url);
2322
-        foreach ($u as $k => $v) {
2323
-            $this->debug("parsed URL $k = $v");
2324
-            $this->$k = $v;
2325
-        }
2326
-
2327
-        // add any GET params to path
2328
-        if (isset($u['query']) && $u['query'] != '') {
2329
-            $this->path .= '?' . $u['query'];
2330
-        }
2331
-
2332
-        // set default port
2333
-        if (!isset($u['port'])) {
2334
-            if ($u['scheme'] == 'https') {
2335
-                $this->port = 443;
2336
-            } else {
2337
-                $this->port = 80;
2338
-            }
2339
-        }
2340
-
2341
-        $this->uri = $this->path;
2342
-        $this->digest_uri = $this->uri;
2343
-
2344
-        // build headers
2345
-        if (!isset($u['port'])) {
2346
-            $this->setHeader('Host', $this->host);
2347
-        } else {
2348
-            $this->setHeader('Host', $this->host . ':' . $this->port);
2349
-        }
2350
-
2351
-        if (isset($u['user']) && $u['user'] != '') {
2352
-            $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2353
-        }
2354
-    }
2355
-
2356
-    /**
2357
-     * gets the I/O method to use
2358
-     *
2359
-     * @return    string    I/O method to use (socket|curl|unknown)
2360
-     * @access    private
2361
-     */
2362
-    function io_method()
2363
-    {
2364
-        if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2365
-            return 'curl';
2366
-        }
2367
-        if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2368
-            return 'socket';
2369
-        }
2370
-        return 'unknown';
2371
-    }
2372
-
2373
-    /**
2374
-     * establish an HTTP connection
2375
-     *
2376
-     * @param    integer $connection_timeout set connection timeout in seconds
2377
-     * @param    integer $response_timeout set response timeout in seconds
2378
-     * @return    boolean true if connected, false if not
2379
-     * @access   private
2380
-     */
2381
-    function connect($connection_timeout = 0, $response_timeout = 30)
2382
-    {
2383
-        // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
2384
-        // "regular" socket.
2385
-        // TODO: disabled for now because OpenSSL must be *compiled* in (not just
2386
-        //       loaded), and until PHP5 stream_get_wrappers is not available.
2387
-//	  	if ($this->scheme == 'https') {
2388
-//		  	if (version_compare(phpversion(), '4.3.0') >= 0) {
2389
-//		  		if (extension_loaded('openssl')) {
2390
-//		  			$this->scheme = 'ssl';
2391
-//		  			$this->debug('Using SSL over OpenSSL');
2392
-//		  		}
2393
-//		  	}
2394
-//		}
2395
-        $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2396
-        if ($this->io_method() == 'socket') {
2397
-            if (!is_array($this->proxy)) {
2398
-                $host = $this->host;
2399
-            } else {
2400
-                $host = $this->proxy['host'];
2401
-            }
2402
-
2403
-            // use persistent connection
2404
-            if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2405
-                if (!feof($this->fp)) {
2406
-                    $this->debug('Re-use persistent connection');
2407
-                    return true;
2408
-                }
2409
-                fclose($this->fp);
2410
-                $this->debug('Closed persistent connection at EOF');
2411
-            }
2412
-
2413
-            // munge host if using OpenSSL
2414
-            if ($this->scheme == 'ssl') {
2415
-                $host = 'ssl://' . $host;
2416
-            }
2417
-            $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2418
-
2419
-            // open socket
2420
-            if ($connection_timeout > 0) {
2421
-                $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2422
-            } else {
2423
-                $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
2424
-            }
2425
-
2426
-            // test pointer
2427
-            if (!$this->fp) {
2428
-                $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2429
-                if ($this->errno) {
2430
-                    $msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2431
-                } else {
2432
-                    $msg .= ' prior to connect().  This is often a problem looking up the host name.';
2433
-                }
2434
-                $this->debug($msg);
2435
-                $this->setError($msg);
2436
-                return false;
2437
-            }
2438
-
2439
-            // set response timeout
2440
-            $this->debug('set response timeout to ' . $response_timeout);
2441
-            socket_set_timeout($this->fp, $response_timeout, 0);
2442
-
2443
-            $this->debug('socket connected');
2444
-            return true;
2445
-        } elseif ($this->io_method() == 'curl') {
2446
-            if (!extension_loaded('curl')) {
2447
-//			$this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
2448
-                $this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
2449
-                return false;
2450
-            }
2451
-            // Avoid warnings when PHP does not have these options
2452
-            if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2453
-                $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2454
-            } else {
2455
-                $CURLOPT_CONNECTIONTIMEOUT = 78;
2456
-            }
2457
-            if (defined('CURLOPT_HTTPAUTH')) {
2458
-                $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2459
-            } else {
2460
-                $CURLOPT_HTTPAUTH = 107;
2461
-            }
2462
-            if (defined('CURLOPT_PROXYAUTH')) {
2463
-                $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2464
-            } else {
2465
-                $CURLOPT_PROXYAUTH = 111;
2466
-            }
2467
-            if (defined('CURLAUTH_BASIC')) {
2468
-                $CURLAUTH_BASIC = CURLAUTH_BASIC;
2469
-            } else {
2470
-                $CURLAUTH_BASIC = 1;
2471
-            }
2472
-            if (defined('CURLAUTH_DIGEST')) {
2473
-                $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2474
-            } else {
2475
-                $CURLAUTH_DIGEST = 2;
2476
-            }
2477
-            if (defined('CURLAUTH_NTLM')) {
2478
-                $CURLAUTH_NTLM = CURLAUTH_NTLM;
2479
-            } else {
2480
-                $CURLAUTH_NTLM = 8;
2481
-            }
2482
-
2483
-            $this->debug('connect using cURL');
2484
-            // init CURL
2485
-            $this->ch = curl_init();
2486
-            // set url
2487
-            $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2488
-            // add path
2489
-            $hostURL .= $this->path;
2490
-            $this->setCurlOption(CURLOPT_URL, $hostURL);
2491
-            // follow location headers (re-directs)
2492
-            if (ini_get('safe_mode') || ini_get('open_basedir')) {
2493
-                $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2494
-                $this->debug('safe_mode = ');
2495
-                $this->appendDebug($this->varDump(ini_get('safe_mode')));
2496
-                $this->debug('open_basedir = ');
2497
-                $this->appendDebug($this->varDump(ini_get('open_basedir')));
2498
-            } else {
2499
-                $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2500
-            }
2501
-            // ask for headers in the response output
2502
-            $this->setCurlOption(CURLOPT_HEADER, 1);
2503
-            // ask for the response output as the return value
2504
-            $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2505
-            // encode
2506
-            // We manage this ourselves through headers and encoding
2507
-//		if(function_exists('gzuncompress')){
2508
-//			$this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2509
-//		}
2510
-            // persistent connection
2511
-            if ($this->persistentConnection) {
2512
-                // I believe the following comment is now bogus, having applied to
2513
-                // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
2514
-                // The way we send data, we cannot use persistent connections, since
2515
-                // there will be some "junk" at the end of our request.
2516
-                //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2517
-                $this->persistentConnection = false;
2518
-                $this->setHeader('Connection', 'close');
2519
-            }
2520
-            // set timeouts
2521
-            if ($connection_timeout != 0) {
2522
-                $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2523
-            }
2524
-            if ($response_timeout != 0) {
2525
-                $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2526
-            }
2527
-
2528
-            if ($this->scheme == 'https') {
2529
-                $this->debug('set cURL SSL verify options');
2530
-                // recent versions of cURL turn on peer/host checking by default,
2531
-                // while PHP binaries are not compiled with a default location for the
2532
-                // CA cert bundle, so disable peer/host checking.
2533
-                //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2534
-                $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2535
-                $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2536
-
2537
-                // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
2538
-                if ($this->authtype == 'certificate') {
2539
-                    $this->debug('set cURL certificate options');
2540
-                    if (isset($this->certRequest['cainfofile'])) {
2541
-                        $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2542
-                    }
2543
-                    if (isset($this->certRequest['verifypeer'])) {
2544
-                        $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2545
-                    } else {
2546
-                        $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2547
-                    }
2548
-                    if (isset($this->certRequest['verifyhost'])) {
2549
-                        $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2550
-                    } else {
2551
-                        $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2552
-                    }
2553
-                    if (isset($this->certRequest['sslcertfile'])) {
2554
-                        $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2555
-                    }
2556
-                    if (isset($this->certRequest['sslkeyfile'])) {
2557
-                        $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2558
-                    }
2559
-                    if (isset($this->certRequest['passphrase'])) {
2560
-                        $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2561
-                    }
2562
-                    if (isset($this->certRequest['certpassword'])) {
2563
-                        $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2564
-                    }
2565
-                }
2566
-            }
2567
-            if ($this->authtype && ($this->authtype != 'certificate')) {
2568
-                if ($this->username) {
2569
-                    $this->debug('set cURL username/password');
2570
-                    $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2571
-                }
2572
-                if ($this->authtype == 'basic') {
2573
-                    $this->debug('set cURL for Basic authentication');
2574
-                    $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2575
-                }
2576
-                if ($this->authtype == 'digest') {
2577
-                    $this->debug('set cURL for digest authentication');
2578
-                    $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2579
-                }
2580
-                if ($this->authtype == 'ntlm') {
2581
-                    $this->debug('set cURL for NTLM authentication');
2582
-                    $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2583
-                }
2584
-            }
2585
-            if (is_array($this->proxy)) {
2586
-                $this->debug('set cURL proxy options');
2587
-                if ($this->proxy['port'] != '') {
2588
-                    $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2589
-                } else {
2590
-                    $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2591
-                }
2592
-                if ($this->proxy['username'] || $this->proxy['password']) {
2593
-                    $this->debug('set cURL proxy authentication options');
2594
-                    $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2595
-                    if ($this->proxy['authtype'] == 'basic') {
2596
-                        $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2597
-                    }
2598
-                    if ($this->proxy['authtype'] == 'ntlm') {
2599
-                        $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2600
-                    }
2601
-                }
2602
-            }
2603
-            $this->debug('cURL connection set up');
2604
-            return true;
2605
-        } else {
2606
-            $this->setError('Unknown scheme ' . $this->scheme);
2607
-            $this->debug('Unknown scheme ' . $this->scheme);
2608
-            return false;
2609
-        }
2610
-    }
2611
-
2612
-    /**
2613
-     * sends the SOAP request and gets the SOAP response via HTTP[S]
2614
-     *
2615
-     * @param    string $data message data
2616
-     * @param    integer $timeout set connection timeout in seconds
2617
-     * @param    integer $response_timeout set response timeout in seconds
2618
-     * @param    array $cookies cookies to send
2619
-     * @return    string data
2620
-     * @access   public
2621
-     */
2622
-    function send($data, $timeout = 0, $response_timeout = 30, $cookies = null)
2623
-    {
2624
-        $this->debug('entered send() with data of length: ' . strlen($data));
2625
-
2626
-        $respdata = "";
2627
-        $this->tryagain = true;
2628
-        $tries = 0;
2629
-        while ($this->tryagain) {
2630
-            $this->tryagain = false;
2631
-            if ($tries++ < 2) {
2632
-                // make connnection
2633
-                if (!$this->connect($timeout, $response_timeout)) {
2634
-                    return false;
2635
-                }
2636
-
2637
-                // send request
2638
-                if (!$this->sendRequest($data, $cookies)) {
2639
-                    return false;
2640
-                }
2641
-
2642
-                // get response
2643
-                $respdata = $this->getResponse();
2644
-            } else {
2645
-                $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2646
-            }
2647
-        }
2648
-        $this->debug('end of send()');
2649
-        return $respdata;
2650
-    }
2651
-
2652
-
2653
-    /**
2654
-     * sends the SOAP request and gets the SOAP response via HTTPS using CURL
2655
-     *
2656
-     * @param    string $data message data
2657
-     * @param    integer $timeout set connection timeout in seconds
2658
-     * @param    integer $response_timeout set response timeout in seconds
2659
-     * @param    array $cookies cookies to send
2660
-     * @return    string data
2661
-     * @access   public
2662
-     */
2663
-    function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies = NULL)
2664
-    {
2665
-        return $this->send($data, $timeout, $response_timeout, $cookies);
2666
-    }
2667
-
2668
-    /**
2669
-     * if authenticating, set user credentials here
2670
-     *
2671
-     * @param    string $username
2672
-     * @param    string $password
2673
-     * @param    string $authtype (basic|digest|certificate|ntlm)
2674
-     * @param    array $digestRequest (keys must be nonce, nc, realm, qop)
2675
-     * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
2676
-     * @access   public
2677
-     */
2678
-    function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array())
2679
-    {
2680
-        $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2681
-        $this->appendDebug($this->varDump($digestRequest));
2682
-        $this->debug("certRequest=");
2683
-        $this->appendDebug($this->varDump($certRequest));
2684
-        // cf. RFC 2617
2685
-        if ($authtype == 'basic') {
2686
-            $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2687
-        } elseif ($authtype == 'digest') {
2688
-            if (isset($digestRequest['nonce'])) {
2689
-                $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2690
-
2691
-                // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2692
-
2693
-                // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2694
-                $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2695
-
2696
-                // H(A1) = MD5(A1)
2697
-                $HA1 = md5($A1);
2698
-
2699
-                // A2 = Method ":" digest-uri-value
2700
-                $A2 = $this->request_method . ':' . $this->digest_uri;
2701
-
2702
-                // H(A2)
2703
-                $HA2 = md5($A2);
2704
-
2705
-                // KD(secret, data) = H(concat(secret, ":", data))
2706
-                // if qop == auth:
2707
-                // request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
2708
-                //                              ":" nc-value
2709
-                //                              ":" unq(cnonce-value)
2710
-                //                              ":" unq(qop-value)
2711
-                //                              ":" H(A2)
2712
-                //                            ) <">
2713
-                // if qop is missing,
2714
-                // request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2715
-
2716
-                $nonce = $digestRequest['nonce'];
2717
-                $cnonce = $nonce;
2718
-                if ($digestRequest['qop'] != '') {
2719
-                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2720
-                } else {
2721
-                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2722
-                }
2723
-
2724
-                $hashedDigest = md5($unhashedDigest);
2725
-
2726
-                $opaque = '';
2727
-                if (isset($digestRequest['opaque'])) {
2728
-                    $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2729
-                }
2730
-
2731
-                $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
2732
-            }
2733
-        } elseif ($authtype == 'certificate') {
2734
-            $this->certRequest = $certRequest;
2735
-            $this->debug('Authorization header not set for certificate');
2736
-        } elseif ($authtype == 'ntlm') {
2737
-            // do nothing
2738
-            $this->debug('Authorization header not set for ntlm');
2739
-        }
2740
-        $this->username = $username;
2741
-        $this->password = $password;
2742
-        $this->authtype = $authtype;
2743
-        $this->digestRequest = $digestRequest;
2744
-    }
2745
-
2746
-    /**
2747
-     * set the soapaction value
2748
-     *
2749
-     * @param    string $soapaction
2750
-     * @access   public
2751
-     */
2752
-    function setSOAPAction($soapaction)
2753
-    {
2754
-        $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2755
-    }
2756
-
2757
-    /**
2758
-     * use http encoding
2759
-     *
2760
-     * @param    string $enc encoding style. supported values: gzip, deflate, or both
2761
-     * @access   public
2762
-     */
2763
-    function setEncoding($enc = 'gzip, deflate')
2764
-    {
2765
-        if (function_exists('gzdeflate')) {
2766
-            $this->protocol_version = '1.1';
2767
-            $this->setHeader('Accept-Encoding', $enc);
2768
-            if (!isset($this->outgoing_headers['Connection'])) {
2769
-                $this->setHeader('Connection', 'close');
2770
-                $this->persistentConnection = false;
2771
-            }
2772
-            // deprecated as of PHP 5.3.0
2773
-            //set_magic_quotes_runtime(0);
2774
-            $this->encoding = $enc;
2775
-        }
2776
-    }
2777
-
2778
-    /**
2779
-     * set proxy info here
2780
-     *
2781
-     * @param    string $proxyhost use an empty string to remove proxy
2782
-     * @param    string $proxyport
2783
-     * @param    string $proxyusername
2784
-     * @param    string $proxypassword
2785
-     * @param    string $proxyauthtype (basic|ntlm)
2786
-     * @access   public
2787
-     */
2788
-    function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic')
2789
-    {
2790
-        if ($proxyhost) {
2791
-            $this->proxy = array(
2792
-                'host' => $proxyhost,
2793
-                'port' => $proxyport,
2794
-                'username' => $proxyusername,
2795
-                'password' => $proxypassword,
2796
-                'authtype' => $proxyauthtype
2797
-            );
2798
-            if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype == 'basic') {
2799
-                $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2800
-            }
2801
-        } else {
2802
-            $this->debug('remove proxy');
2803
-            $this->unsetHeader('Proxy-Authorization');
2804
-        }
2805
-    }
2806
-
2807
-
2808
-    /**
2809
-     * Test if the given string starts with a header that is to be skipped.
2810
-     * Skippable headers result from chunked transfer and proxy requests.
2811
-     *
2812
-     * @param    string $data The string to check.
2813
-     * @returns    boolean    Whether a skippable header was found.
2814
-     * @access    private
2815
-     */
2816
-    function isSkippableCurlHeader($data)
2817
-    {
2818
-        $skipHeaders = array('HTTP/1.1 100',
2819
-            'HTTP/1.0 301',
2820
-            'HTTP/1.1 301',
2821
-            'HTTP/1.0 302',
2822
-            'HTTP/1.1 302',
2823
-            'HTTP/1.0 401',
2824
-            'HTTP/1.1 401',
2825
-            'HTTP/1.0 200 Connection established',
2826
-            'HTTP/1.1 200 Connection established');
2827
-        foreach ($skipHeaders as $hd) {
2828
-            $prefix = substr($data, 0, strlen($hd));
2829
-            if ($prefix == $hd) {
2830
-                return true;
2831
-            }
2832
-        }
2833
-
2834
-        return false;
2835
-    }
2836
-
2837
-    /**
2838
-     * decode a string that is encoded w/ "chunked' transfer encoding
2839
-     * as defined in RFC2068 19.4.6
2840
-     *
2841
-     * @param    string $buffer
2842
-     * @param    string $lb
2843
-     * @returns    string
2844
-     * @access   public
2845
-     * @deprecated
2846
-     */
2847
-    function decodeChunked($buffer, $lb)
2848
-    {
2849
-        $new = '';
2850
-
2851
-        // read chunk-size, chunk-extension (if any) and CRLF
2852
-        // get the position of the linebreak
2853
-        $chunkend = strpos($buffer, $lb);
2854
-        if (!$chunkend) {
2855
-            $this->debug('no linebreak found in decodeChunked');
2856
-            return $new;
2857
-        }
2858
-        $temp = substr($buffer, 0, $chunkend);
2859
-        $chunk_size = hexdec(trim($temp));
2860
-        $chunkstart = $chunkend + strlen($lb);
2861
-        // while (chunk-size > 0) {
2862
-        while ($chunk_size > 0) {
2863
-            $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2864
-            $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2865
-
2866
-            // Just in case we got a broken connection
2867
-            if (!$chunkend) {
2868
-                $chunk = substr($buffer, $chunkstart);
2869
-                // append chunk-data to entity-body
2870
-                $new .= $chunk;
2871
-                break;
2872
-            }
2873
-
2874
-            // read chunk-data and CRLF
2875
-            $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2876
-            // append chunk-data to entity-body
2877
-            $new .= $chunk;
2878
-            // length := length + chunk-size
2879
-            // read chunk-size and CRLF
2880
-            $chunkstart = $chunkend + strlen($lb);
2881
-
2882
-            $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2883
-            if (!$chunkend) {
2884
-                break; //Just in case we got a broken connection
2885
-            }
2886
-            $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2887
-            $chunk_size = hexdec(trim($temp));
2888
-            $chunkstart = $chunkend;
2889
-        }
2890
-        return $new;
2891
-    }
2892
-
2893
-    /**
2894
-     * Writes the payload, including HTTP headers, to $this->outgoing_payload.
2895
-     *
2896
-     * @param    string $data HTTP body
2897
-     * @param    string $cookie_str data for HTTP Cookie header
2898
-     * @return    void
2899
-     * @access    private
2900
-     */
2901
-    function buildPayload($data, $cookie_str = '')
2902
-    {
2903
-        // Note: for cURL connections, $this->outgoing_payload is ignored,
2904
-        // as is the Content-Length header, but these are still created as
2905
-        // debugging guides.
2906
-
2907
-        // add content-length header
2908
-        if ($this->request_method != 'GET') {
2909
-            $this->setHeader('Content-Length', strlen($data));
2910
-        }
2911
-
2912
-        // start building outgoing payload:
2913
-        if ($this->proxy) {
2914
-            $uri = $this->url;
2915
-        } else {
2916
-            $uri = $this->uri;
2917
-        }
2918
-        $req = "$this->request_method $uri HTTP/$this->protocol_version";
2919
-        $this->debug("HTTP request: $req");
2920
-        $this->outgoing_payload = "$req\r\n";
2921
-
2922
-        // loop thru headers, serializing
2923
-        foreach ($this->outgoing_headers as $k => $v) {
2924
-            $hdr = $k . ': ' . $v;
2925
-            $this->debug("HTTP header: $hdr");
2926
-            $this->outgoing_payload .= "$hdr\r\n";
2927
-        }
2928
-
2929
-        // add any cookies
2930
-        if ($cookie_str != '') {
2931
-            $hdr = 'Cookie: ' . $cookie_str;
2932
-            $this->debug("HTTP header: $hdr");
2933
-            $this->outgoing_payload .= "$hdr\r\n";
2934
-        }
2935
-
2936
-        // header/body separator
2937
-        $this->outgoing_payload .= "\r\n";
2938
-
2939
-        // add data
2940
-        $this->outgoing_payload .= $data;
2941
-    }
2942
-
2943
-    /**
2944
-     * sends the SOAP request via HTTP[S]
2945
-     *
2946
-     * @param    string $data message data
2947
-     * @param    array $cookies cookies to send
2948
-     * @return    boolean    true if OK, false if problem
2949
-     * @access   private
2950
-     */
2951
-    function sendRequest($data, $cookies = null)
2952
-    {
2953
-        // build cookie string
2954
-        $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2955
-
2956
-        // build payload
2957
-        $this->buildPayload($data, $cookie_str);
2958
-
2959
-        if ($this->io_method() == 'socket') {
2960
-            // send payload
2961
-            if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2962
-                $this->setError('couldn\'t write message data to socket');
2963
-                $this->debug('couldn\'t write message data to socket');
2964
-                return false;
2965
-            }
2966
-            $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2967
-            return true;
2968
-        } elseif ($this->io_method() == 'curl') {
2969
-            // set payload
2970
-            // cURL does say this should only be the verb, and in fact it
2971
-            // turns out that the URI and HTTP version are appended to this, which
2972
-            // some servers refuse to work with (so we no longer use this method!)
2973
-            //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2974
-            $curl_headers = array();
2975
-            foreach ($this->outgoing_headers as $k => $v) {
2976
-                if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2977
-                    $this->debug("Skip cURL header $k: $v");
2978
-                } else {
2979
-                    $curl_headers[] = "$k: $v";
2980
-                }
2981
-            }
2982
-            if ($cookie_str != '') {
2983
-                $curl_headers[] = 'Cookie: ' . $cookie_str;
2984
-            }
2985
-            $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2986
-            $this->debug('set cURL HTTP headers');
2987
-            if ($this->request_method == "POST") {
2988
-                $this->setCurlOption(CURLOPT_POST, 1);
2989
-                $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2990
-                $this->debug('set cURL POST data');
2991
-            }
2992
-            // insert custom user-set cURL options
2993
-            foreach ($this->ch_options as $key => $val) {
2994
-                $this->setCurlOption($key, $val);
2995
-            }
2996
-
2997
-            $this->debug('set cURL payload');
2998
-            return true;
2999
-        }
3000
-        return false;
3001
-    }
3002
-
3003
-    /**
3004
-     * gets the SOAP response via HTTP[S]
3005
-     *
3006
-     * @return    string the response (also sets member variables like incoming_payload)
3007
-     * @access   private
3008
-     */
3009
-    function getResponse()
3010
-    {
3011
-        $this->incoming_payload = '';
3012
-        $header_array = array ();
3013
-        $data = '';
3014
-
3015
-        if ($this->io_method() == 'socket') {
3016
-            // loop until headers have been retrieved
3017
-            $pos = 0;
3018
-            while (!isset($lb)) {
3019
-                // We might EOF during header read.
3020
-                if (feof($this->fp)) {
3021
-                    $this->incoming_payload = $data;
3022
-                    $this->debug('found no headers before EOF after length ' . strlen($data));
3023
-                    $this->debug("received before EOF:\n" . $data);
3024
-                    $this->setError('server failed to send headers');
3025
-                    return false;
3026
-                }
3027
-
3028
-                $tmp = fgets($this->fp, 256);
3029
-                $tmplen = strlen($tmp);
3030
-                $this->debug("read line of $tmplen bytes: " . trim($tmp));
3031
-
3032
-                if ($tmplen == 0) {
3033
-                    $this->incoming_payload = $data;
3034
-                    $this->debug('socket read of headers timed out after length ' . strlen($data));
3035
-                    $this->debug("read before timeout: " . $data);
3036
-                    $this->setError('socket read of headers timed out');
3037
-                    return false;
3038
-                }
3039
-
3040
-                $data .= $tmp;
3041
-                $pos = strpos($data, "\r\n\r\n");
3042
-                if ($pos > 1) {
3043
-                    $lb = "\r\n";
3044
-                } else {
3045
-                    $pos = strpos($data, "\n\n");
3046
-                    if ($pos > 1) {
3047
-                        $lb = "\n";
3048
-                    }
3049
-                }
3050
-                // remove 100 headers
3051
-                if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
3052
-                    unset($lb);
3053
-                    $data = '';
3054
-                }//
3055
-            }
3056
-            // store header data
3057
-            $this->incoming_payload .= $data;
3058
-            $this->debug('found end of headers after length ' . strlen($data));
3059
-            // process headers
3060
-            $header_data = trim(substr($data, 0, $pos));
3061
-            $header_array = explode($lb, $header_data);
3062
-            $this->incoming_headers = array();
3063
-            $this->incoming_cookies = array();
3064
-            foreach ($header_array as $header_line) {
3065
-                $arr = explode(':', $header_line, 2);
3066
-                if (count($arr) > 1) {
3067
-                    $header_name = strtolower(trim($arr[0]));
3068
-                    $this->incoming_headers[$header_name] = trim($arr[1]);
3069
-                    if ($header_name == 'set-cookie') {
3070
-                        // TODO: allow multiple cookies from parseCookie
3071
-                        $cookie = $this->parseCookie(trim($arr[1]));
3072
-                        if ($cookie) {
3073
-                            $this->incoming_cookies[] = $cookie;
3074
-                            $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3075
-                        } else {
3076
-                            $this->debug('did not find cookie in ' . trim($arr[1]));
3077
-                        }
3078
-                    }
3079
-                } elseif (isset($header_name)) {
3080
-                    // append continuation line to previous header
3081
-                    $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3082
-                }
3083
-            }
3084
-
3085
-            // loop until msg has been received
3086
-            if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3087
-                $content_length = 2147483647;    // ignore any content-length header
3088
-                $chunked = true;
3089
-                $this->debug("want to read chunked content");
3090
-            } elseif (isset($this->incoming_headers['content-length'])) {
3091
-                $content_length = $this->incoming_headers['content-length'];
3092
-                $chunked = false;
3093
-                $this->debug("want to read content of length $content_length");
3094
-            } else {
3095
-                $content_length = 2147483647;
3096
-                $chunked = false;
3097
-                $this->debug("want to read content to EOF");
3098
-            }
3099
-            $data = '';
3100
-            do {
3101
-                if ($chunked) {
3102
-                    $tmp = fgets($this->fp, 256);
3103
-                    $tmplen = strlen($tmp);
3104
-                    $this->debug("read chunk line of $tmplen bytes");
3105
-                    if ($tmplen == 0) {
3106
-                        $this->incoming_payload = $data;
3107
-                        $this->debug('socket read of chunk length timed out after length ' . strlen($data));
3108
-                        $this->debug("read before timeout:\n" . $data);
3109
-                        $this->setError('socket read of chunk length timed out');
3110
-                        return false;
3111
-                    }
3112
-                    $content_length = hexdec(trim($tmp));
3113
-                    $this->debug("chunk length $content_length");
3114
-                }
3115
-                $strlen = 0;
3116
-                while (($strlen < $content_length) && (!feof($this->fp))) {
3117
-                    $readlen = min(8192, $content_length - $strlen);
3118
-                    $tmp = fread($this->fp, $readlen);
3119
-                    $tmplen = strlen($tmp);
3120
-                    $this->debug("read buffer of $tmplen bytes");
3121
-                    if (($tmplen == 0) && (!feof($this->fp))) {
3122
-                        $this->incoming_payload = $data;
3123
-                        $this->debug('socket read of body timed out after length ' . strlen($data));
3124
-                        $this->debug("read before timeout:\n" . $data);
3125
-                        $this->setError('socket read of body timed out');
3126
-                        return false;
3127
-                    }
3128
-                    $strlen += $tmplen;
3129
-                    $data .= $tmp;
3130
-                }
3131
-                if ($chunked && ($content_length > 0)) {
3132
-                    $tmp = fgets($this->fp, 256);
3133
-                    $tmplen = strlen($tmp);
3134
-                    $this->debug("read chunk terminator of $tmplen bytes");
3135
-                    if ($tmplen == 0) {
3136
-                        $this->incoming_payload = $data;
3137
-                        $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3138
-                        $this->debug("read before timeout:\n" . $data);
3139
-                        $this->setError('socket read of chunk terminator timed out');
3140
-                        return false;
3141
-                    }
3142
-                }
3143
-            } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3144
-            if (feof($this->fp)) {
3145
-                $this->debug('read to EOF');
3146
-            }
3147
-            $this->debug('read body of length ' . strlen($data));
3148
-            $this->incoming_payload .= $data;
3149
-            $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
3150
-
3151
-            // close filepointer
3152
-            if (
3153
-                (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
3154
-                (!$this->persistentConnection) || feof($this->fp)
3155
-            ) {
3156
-                fclose($this->fp);
3157
-                $this->fp = false;
3158
-                $this->debug('closed socket');
3159
-            }
3160
-
3161
-            // connection was closed unexpectedly
3162
-            if ($this->incoming_payload == '') {
3163
-                $this->setError('no response from server');
3164
-                return false;
3165
-            }
3166
-
3167
-            // decode transfer-encoding
3168
-//		if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
3169
-//			if(!$data = $this->decodeChunked($data, $lb)){
3170
-//				$this->setError('Decoding of chunked data failed');
3171
-//				return false;
3172
-//			}
3173
-            //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
3174
-            // set decoded payload
3175
-//			$this->incoming_payload = $header_data.$lb.$lb.$data;
3176
-//		}
1271
+			xml_parser_free($this->parser);
1272
+			unset($this->parser);
1273
+		} else {
1274
+			$this->debug('no xml passed to parseString()!!');
1275
+			$this->setError('no xml passed to parseString()!!');
1276
+		}
1277
+	}
3177 1278
 
3178
-        } elseif ($this->io_method() == 'curl') {
3179
-            // send and receive
3180
-            $this->debug('send and receive with cURL');
3181
-            $this->incoming_payload = curl_exec($this->ch);
3182
-            $data = $this->incoming_payload;
3183
-
3184
-            $cErr = curl_error($this->ch);
3185
-            if ($cErr != '') {
3186
-                $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3187
-                // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
3188
-                foreach (curl_getinfo($this->ch) as $k => $v) {
3189
-                    if (is_array($v)) {
3190
-                        $this->debug("$k: " . json_encode($v));
3191
-                    } else {
3192
-                        $this->debug("$k: $v<br>");
3193
-                    }
3194
-                }
3195
-                $this->debug($err);
3196
-                $this->setError($err);
3197
-                curl_close($this->ch);
3198
-                return false;
3199
-            }
3200
-            // close curl
3201
-            $this->debug('No cURL error, closing cURL');
3202
-            curl_close($this->ch);
3203
-
3204
-            // try removing skippable headers
3205
-            $savedata = $data;
3206
-            while ($this->isSkippableCurlHeader($data)) {
3207
-                $this->debug("Found HTTP header to skip");
3208
-                if ($pos = strpos($data, "\r\n\r\n")) {
3209
-                    $data = ltrim(substr($data, $pos));
3210
-                } elseif ($pos = strpos($data, "\n\n")) {
3211
-                    $data = ltrim(substr($data, $pos));
3212
-                }
3213
-            }
3214
-
3215
-            if ($data == '') {
3216
-                // have nothing left; just remove 100 header(s)
3217
-                $data = $savedata;
3218
-                while (preg_match('/^HTTP\/1.1 100/', $data)) {
3219
-                    if ($pos = strpos($data, "\r\n\r\n")) {
3220
-                        $data = ltrim(substr($data, $pos));
3221
-                    } elseif ($pos = strpos($data, "\n\n")) {
3222
-                        $data = ltrim(substr($data, $pos));
3223
-                    }
3224
-                }
3225
-            }
3226
-
3227
-            // separate content from HTTP headers
3228
-            if ($pos = strpos($data, "\r\n\r\n")) {
3229
-                $lb = "\r\n";
3230
-            } elseif ($pos = strpos($data, "\n\n")) {
3231
-                $lb = "\n";
3232
-            } else {
3233
-                $this->debug('no proper separation of headers and document');
3234
-                $this->setError('no proper separation of headers and document');
3235
-                return false;
3236
-            }
3237
-            $header_data = trim(substr($data, 0, $pos));
3238
-            $header_array = explode($lb, $header_data);
3239
-            $data = ltrim(substr($data, $pos));
3240
-            $this->debug('found proper separation of headers and document');
3241
-            $this->debug('cleaned data, stringlen: ' . strlen($data));
3242
-            // clean headers
3243
-            foreach ($header_array as $header_line) {
3244
-                $arr = explode(':', $header_line, 2);
3245
-                if (count($arr) > 1) {
3246
-                    $header_name = strtolower(trim($arr[0]));
3247
-                    $this->incoming_headers[$header_name] = trim($arr[1]);
3248
-                    if ($header_name == 'set-cookie') {
3249
-                        // TODO: allow multiple cookies from parseCookie
3250
-                        $cookie = $this->parseCookie(trim($arr[1]));
3251
-                        if ($cookie) {
3252
-                            $this->incoming_cookies[] = $cookie;
3253
-                            $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3254
-                        } else {
3255
-                            $this->debug('did not find cookie in ' . trim($arr[1]));
3256
-                        }
3257
-                    }
3258
-                } elseif (isset($header_name)) {
3259
-                    // append continuation line to previous header
3260
-                    $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3261
-                }
3262
-            }
3263
-        }
3264
-
3265
-        $this->response_status_line = $header_array[0];
3266
-        $arr = explode(' ', $this->response_status_line, 3);
3267
-        $http_status = intval($arr[1]);
3268
-        $http_reason = count($arr) > 2 ? $arr[2] : '';
3269
-
3270
-        // see if we need to resend the request with http digest authentication
3271
-        if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3272
-            $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3273
-            $this->setURL($this->incoming_headers['location']);
3274
-            $this->tryagain = true;
3275
-            return false;
3276
-        }
3277
-
3278
-        // see if we need to resend the request with http digest authentication
3279
-        if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3280
-            $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
3281
-            if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3282
-                $this->debug('Server wants digest authentication');
3283
-                // remove "Digest " from our elements
3284
-                $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3285
-
3286
-                // parse elements into array
3287
-                $digestElements = explode(',', $digestString);
3288
-                foreach ($digestElements as $val) {
3289
-                    $tempElement = explode('=', trim($val), 2);
3290
-                    $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
3291
-                }
3292
-
3293
-                // should have (at least) qop, realm, nonce
3294
-                if (isset($digestRequest['nonce'])) {
3295
-                    $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
3296
-                    $this->tryagain = true;
3297
-                    return false;
3298
-                }
3299
-            }
3300
-            $this->debug('HTTP authentication failed');
3301
-            $this->setError('HTTP authentication failed');
3302
-            return false;
3303
-        }
3304
-
3305
-        if (
3306
-            ($http_status >= 300 && $http_status <= 307) ||
3307
-            ($http_status >= 400 && $http_status <= 417) ||
3308
-            ($http_status >= 501 && $http_status <= 505)
3309
-        ) {
3310
-            $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3311
-            return false;
3312
-        }
3313
-
3314
-        // decode content-encoding
3315
-        if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
3316
-            if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
3317
-                $header_data = "";
3318
-                // if decoding works, use it. else assume data wasn't gzencoded
3319
-                if (function_exists('gzinflate')) {
3320
-                    //$timer->setMarker('starting decoding of gzip/deflated content');
3321
-                    // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
3322
-                    // this means there are no Zlib headers, although there should be
3323
-                    $this->debug('The gzinflate function exists');
3324
-                    $datalen = strlen($data);
3325
-                    if ($this->incoming_headers['content-encoding'] == 'deflate') {
3326
-                        if ($degzdata = @gzinflate($data)) {
3327
-                            $data = $degzdata;
3328
-                            $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3329
-                            if (strlen($data) < $datalen) {
3330
-                                // test for the case that the payload has been compressed twice
3331
-                                $this->debug('The inflated payload is smaller than the gzipped one; try again');
3332
-                                if ($degzdata = @gzinflate($data)) {
3333
-                                    $data = $degzdata;
3334
-                                    $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3335
-                                }
3336
-                            }
3337
-                        } else {
3338
-                            $this->debug('Error using gzinflate to inflate the payload');
3339
-                            $this->setError('Error using gzinflate to inflate the payload');
3340
-                        }
3341
-                    } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3342
-                        if ($degzdata = @gzinflate(substr($data, 10))) {    // do our best
3343
-                            $data = $degzdata;
3344
-                            $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3345
-                            if (strlen($data) < $datalen) {
3346
-                                // test for the case that the payload has been compressed twice
3347
-                                $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3348
-                                if ($degzdata = @gzinflate(substr($data, 10))) {
3349
-                                    $data = $degzdata;
3350
-                                    $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3351
-                                }
3352
-                            }
3353
-                        } else {
3354
-                            $this->debug('Error using gzinflate to un-gzip the payload');
3355
-                            $this->setError('Error using gzinflate to un-gzip the payload');
3356
-                        }
3357
-                    }
3358
-                    //$timer->setMarker('finished decoding of gzip/deflated content');
3359
-                    //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3360
-                    // set decoded payload
3361
-                    $this->incoming_payload = $header_data . (isset ($lb) ? $lb : "") . (isset ($lb) ? $lb : "") . $data;
3362
-                } else {
3363
-                    $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3364
-                    $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3365
-                }
3366
-            } else {
3367
-                $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3368
-                $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3369
-            }
3370
-        } else {
3371
-            $this->debug('No Content-Encoding header');
3372
-        }
3373
-
3374
-        if (strlen($data) == 0) {
3375
-            $this->debug('no data after headers!');
3376
-            $this->setError('no data present after HTTP headers');
3377
-            return false;
3378
-        }
3379
-
3380
-        return $data;
3381
-    }
3382
-
3383
-    /**
3384
-     * sets the content-type for the SOAP message to be sent
3385
-     *
3386
-     * @param    string $type the content type, MIME style
3387
-     * @param    mixed $charset character set used for encoding (or false)
3388
-     * @access    public
3389
-     */
3390
-    function setContentType($type, $charset = false)
3391
-    {
3392
-        $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3393
-    }
3394
-
3395
-    /**
3396
-     * specifies that an HTTP persistent connection should be used
3397
-     *
3398
-     * @return    boolean whether the request was honored by this method.
3399
-     * @access    public
3400
-     */
3401
-    function usePersistentConnection()
3402
-    {
3403
-        if (isset($this->outgoing_headers['Accept-Encoding'])) {
3404
-            return false;
3405
-        }
3406
-        $this->protocol_version = '1.1';
3407
-        $this->persistentConnection = true;
3408
-        $this->setHeader('Connection', 'Keep-Alive');
3409
-        return true;
3410
-    }
3411
-
3412
-    /**
3413
-     * parse an incoming Cookie into it's parts
3414
-     *
3415
-     * @param    string $cookie_str content of cookie
3416
-     * @return    array with data of that cookie
3417
-     * @access    private
3418
-     */
3419
-    /*
3420
-	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1279
+	/**
1280
+	 * gets a type name for an unnamed type
1281
+	 *
1282
+	 * @param    string $ename Element name
1283
+	 * @return    string    A type name for an unnamed type
1284
+	 * @access    private
3421 1285
 	 */
3422
-    function parseCookie($cookie_str)
3423
-    {
3424
-        $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3425
-        $data = explode (';', $cookie_str);
3426
-        $value_str = $data[0];
3427
-
3428
-        $cookie_param = 'domain=';
3429
-        $start = strpos($cookie_str, $cookie_param);
3430
-        if ($start > 0) {
3431
-            $domain = substr($cookie_str, $start + strlen($cookie_param));
3432
-            $domain = substr($domain, 0, strpos($domain, ';'));
3433
-        } else {
3434
-            $domain = '';
3435
-        }
3436
-
3437
-        $cookie_param = 'expires=';
3438
-        $start = strpos($cookie_str, $cookie_param);
3439
-        if ($start > 0) {
3440
-            $expires = substr($cookie_str, $start + strlen($cookie_param));
3441
-            $expires = substr($expires, 0, strpos($expires, ';'));
3442
-        } else {
3443
-            $expires = '';
3444
-        }
3445
-
3446
-        $cookie_param = 'path=';
3447
-        $start = strpos($cookie_str, $cookie_param);
3448
-        if ($start > 0) {
3449
-            $path = substr($cookie_str, $start + strlen($cookie_param));
3450
-            $path = substr($path, 0, strpos($path, ';'));
3451
-        } else {
3452
-            $path = '/';
3453
-        }
3454
-
3455
-        $cookie_param = ';secure;';
3456
-        if (strpos($cookie_str, $cookie_param) !== false) {
3457
-            $secure = true;
3458
-        } else {
3459
-            $secure = false;
3460
-        }
3461
-
3462
-        $sep_pos = strpos($value_str, '=');
3463
-
3464
-        if ($sep_pos) {
3465
-            $name = substr($value_str, 0, $sep_pos);
3466
-            $value = substr($value_str, $sep_pos + 1);
3467
-
3468
-          return array('name' => $name,
3469
-                     'value' => $value,
3470
-                     'domain' => $domain,
3471
-                     'path' => $path,
3472
-                     'expires' => $expires,
3473
-                     'secure' => $secure
3474
-          );
3475
-        }
3476
-        return array ();
3477
-    }
3478
-
3479
-    /**
3480
-     * sort out cookies for the current request
3481
-     *
3482
-     * @param    array $cookies array with all cookies
3483
-     * @param    boolean $secure is the send-content secure or not?
3484
-     * @return    string for Cookie-HTTP-Header
3485
-     * @access    private
3486
-     */
3487
-    function getCookiesForRequest($cookies, $secure = false)
3488
-    {
3489
-        $cookie_str = '';
3490
-        if ((is_array($cookies))) {
3491
-            foreach ($cookies as $cookie) {
3492
-                if (!is_array($cookie)) {
3493
-                    continue;
3494
-                }
3495
-                $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3496
-                if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
3497
-                    if (strtotime($cookie['expires']) <= time()) {
3498
-                        $this->debug('cookie has expired');
3499
-                        continue;
3500
-                    }
3501
-                }
3502
-                if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) {
3503
-                    $domain = preg_quote($cookie['domain'], "'");
3504
-                    if (!preg_match("'.*$domain$'i", $this->host)) {
3505
-                        $this->debug('cookie has different domain');
3506
-                        continue;
3507
-                    }
3508
-                }
3509
-                if ((isset($cookie['path'])) && (!empty($cookie['path']))) {
3510
-                    $path = preg_quote($cookie['path'], "'");
3511
-                    if (!preg_match("'^$path.*'i", $this->path)) {
3512
-                        $this->debug('cookie is for a different path');
3513
-                        continue;
3514
-                    }
3515
-                }
3516
-                if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3517
-                    $this->debug('cookie is secure, transport is not');
3518
-                    continue;
3519
-                }
3520
-                $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3521
-                $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3522
-            }
3523
-        }
3524
-        return $cookie_str;
3525
-    }
3526
-}
1286
+	function CreateTypeName($ename)
1287
+	{
1288
+		$scope = '';
1289
+		for ($i = 0; $i < count($this->complexTypeStack); $i++) {
1290
+			$scope .= $this->complexTypeStack[$i] . '_';
1291
+		}
1292
+		return $scope . $ename . '_ContainedType';
1293
+	}
3527 1294
 
1295
+	/**
1296
+	 * start-element handler
1297
+	 *
1298
+	 * @param    string $parser XML parser object
1299
+	 * @param    string $name element name
1300
+	 * @param    array $attrs associative array of attributes
1301
+	 * @access   private
1302
+	 */
1303
+	function schemaStartElement($parser, $name, $attrs)
1304
+	{
1305
+
1306
+		// position in the total number of elements, starting from 0
1307
+		$pos = $this->position++;
1308
+		$depth = $this->depth++;
1309
+		// set self as current value for this depth
1310
+		$this->depth_array[$depth] = $pos;
1311
+		$this->message[$pos] = array('cdata' => '');
1312
+		if ($depth > 0) {
1313
+			$this->defaultNamespace[$pos] = $this->defaultNamespace[$this->depth_array[$depth - 1]];
1314
+		} else {
1315
+			$this->defaultNamespace[$pos] = false;
1316
+		}
3528 1317
 
3529
-/**
3530
- *
3531
- * nusoap_server allows the user to create a SOAP server
3532
- * that is capable of receiving messages and returning responses
3533
- *
1318
+		// get element prefix
1319
+		if ($prefix = $this->getPrefix($name)) {
1320
+			// get unqualified name
1321
+			$name = $this->getLocalPart($name);
1322
+		} else {
1323
+			$prefix = '';
1324
+		}
1325
+
1326
+		// loop thru attributes, expanding, and registering namespace declarations
1327
+		if (count($attrs) > 0) {
1328
+			foreach ($attrs as $k => $v) {
1329
+				// if ns declarations, add to class level array of valid namespaces
1330
+				if (preg_match('/^xmlns/', $k)) {
1331
+					//$this->xdebug("$k: $v");
1332
+					//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
1333
+					if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
1334
+						//$this->xdebug("Add namespace[$ns_prefix] = $v");
1335
+						$this->namespaces[$ns_prefix] = $v;
1336
+					} else {
1337
+						$this->defaultNamespace[$pos] = $v;
1338
+						if (!$this->getPrefixFromNamespace($v)) {
1339
+							$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
1340
+						}
1341
+					}
1342
+					if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
1343
+						$this->XMLSchemaVersion = $v;
1344
+						$this->namespaces['xsi'] = $v . '-instance';
1345
+					}
1346
+				}
1347
+			}
1348
+			$eAttrs = array ();
1349
+			foreach ($attrs as $k => $v) {
1350
+				// expand each attribute
1351
+				$k = strpos($k, ':') ? $this->expandQname($k) : $k;
1352
+				$v = strpos($v, ':') ? $this->expandQname($v) : $v;
1353
+				$eAttrs[$k] = $v;
1354
+			}
1355
+			$attrs = $eAttrs;
1356
+		} else {
1357
+			$attrs = array();
1358
+		}
1359
+		// find status, register data
1360
+		switch ($name) {
1361
+			case 'all':            // (optional) compositor content for a complexType
1362
+			case 'choice':
1363
+			case 'group':
1364
+			case 'sequence':
1365
+				//$this->xdebug("compositor $name for currentComplexType: $this->currentComplexType and currentElement: $this->currentElement");
1366
+				$this->complexTypes[$this->currentComplexType]['compositor'] = $name;
1367
+				//if($name == 'all' || $name == 'sequence'){
1368
+				//	$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1369
+				//}
1370
+				break;
1371
+			case 'attribute':    // complexType attribute
1372
+				//$this->xdebug("parsing attribute $attrs[name] $attrs[ref] of value: ".$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']);
1373
+				$this->xdebug("parsing attribute:");
1374
+				$this->appendDebug($this->varDump($attrs));
1375
+				if (!isset($attrs['form'])) {
1376
+					// TODO: handle globals
1377
+					$attrs['form'] = $this->schemaInfo['attributeFormDefault'];
1378
+				}
1379
+				if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1380
+					$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1381
+					if (!strpos($v, ':')) {
1382
+						// no namespace in arrayType attribute value...
1383
+						if ($this->defaultNamespace[$pos]) {
1384
+							// ...so use the default
1385
+							$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1386
+						}
1387
+					}
1388
+				}
1389
+				if (isset($attrs['name'])) {
1390
+					$this->attributes[$attrs['name']] = $attrs;
1391
+					$aname = $attrs['name'];
1392
+				} elseif (isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType') {
1393
+					if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1394
+						$aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1395
+					} else {
1396
+						$aname = '';
1397
+					}
1398
+				} elseif (isset($attrs['ref'])) {
1399
+					$aname = $attrs['ref'];
1400
+					$this->attributes[$attrs['ref']] = $attrs;
1401
+				} else {
1402
+					$aname = '';
1403
+				}
1404
+
1405
+				if ($this->currentComplexType) {    // This should *always* be
1406
+					$this->complexTypes[$this->currentComplexType]['attrs'][$aname] = $attrs;
1407
+				}
1408
+				// arrayType attribute
1409
+				if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType') {
1410
+					$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1411
+					if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
1412
+						$v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1413
+					} else {
1414
+						$v = '';
1415
+					}
1416
+					if (strpos($v, '[,]')) {
1417
+						$this->complexTypes[$this->currentComplexType]['multidimensional'] = true;
1418
+					}
1419
+					$v = substr($v, 0, strpos($v, '[')); // clip the []
1420
+					if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
1421
+						$v = $this->XMLSchemaVersion . ':' . $v;
1422
+					}
1423
+					$this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
1424
+				}
1425
+				break;
1426
+			case 'complexContent':    // (optional) content for a complexType
1427
+				$this->xdebug("do nothing for element $name");
1428
+				break;
1429
+			case 'complexType':
1430
+				$this->complexTypeStack[] = $this->currentComplexType;
1431
+				if (isset($attrs['name'])) {
1432
+					// TODO: what is the scope of named complexTypes that appear
1433
+					//       nested within other c complexTypes?
1434
+					$this->xdebug('processing named complexType ' . $attrs['name']);
1435
+					//$this->currentElement = false;
1436
+					$this->currentComplexType = $attrs['name'];
1437
+				} else {
1438
+					$name = $this->CreateTypeName($this->currentElement);
1439
+					$this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
1440
+					$this->currentComplexType = $name;
1441
+					//$this->currentElement = false;
1442
+				}
1443
+				$this->complexTypes[$this->currentComplexType] = $attrs;
1444
+				$this->complexTypes[$this->currentComplexType]['typeClass'] = 'complexType';
1445
+				// This is for constructs like
1446
+				//           <complexType name="ListOfString" base="soap:Array">
1447
+				//                <sequence>
1448
+				//                    <element name="string" type="xsd:string"
1449
+				//                        minOccurs="0" maxOccurs="unbounded" />
1450
+				//                </sequence>
1451
+				//            </complexType>
1452
+				if (isset($attrs['base']) && preg_match('/:Array$/', $attrs['base'])) {
1453
+					$this->xdebug('complexType is unusual array');
1454
+					$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1455
+				} else {
1456
+					$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
1457
+				}
1458
+				$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
1459
+				break;
1460
+			case 'element':
1461
+				$this->elementStack[] = $this->currentElement;
1462
+				if (!isset($attrs['form'])) {
1463
+					if ($this->currentComplexType) {
1464
+						$attrs['form'] = $this->schemaInfo['elementFormDefault'];
1465
+					} else {
1466
+						// global
1467
+						$attrs['form'] = 'qualified';
1468
+					}
1469
+				}
1470
+				if (isset($attrs['type'])) {
1471
+					$this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']);
1472
+					if (!$this->getPrefix($attrs['type'])) {
1473
+						if ($this->defaultNamespace[$pos]) {
1474
+							$attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1475
+							$this->xdebug('used default namespace to make type ' . $attrs['type']);
1476
+						}
1477
+					}
1478
+					// This is for constructs like
1479
+					//           <complexType name="ListOfString" base="soap:Array">
1480
+					//                <sequence>
1481
+					//                    <element name="string" type="xsd:string"
1482
+					//                        minOccurs="0" maxOccurs="unbounded" />
1483
+					//                </sequence>
1484
+					//            </complexType>
1485
+					if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
1486
+						$this->xdebug('arrayType for unusual array is ' . $attrs['type']);
1487
+						$this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
1488
+					}
1489
+					$this->currentElement = $attrs['name'];
1490
+					$ename = $attrs['name'];
1491
+				} elseif (isset($attrs['ref'])) {
1492
+					$this->xdebug("processing element as ref to " . $attrs['ref']);
1493
+					$this->currentElement = "ref to " . $attrs['ref'];
1494
+					$ename = $this->getLocalPart($attrs['ref']);
1495
+				} else {
1496
+					$type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
1497
+					$this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
1498
+					$this->currentElement = $attrs['name'];
1499
+					$attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
1500
+					$ename = $attrs['name'];
1501
+				}
1502
+				if (isset($ename) && $this->currentComplexType) {
1503
+					$this->xdebug("add element $ename to complexType $this->currentComplexType");
1504
+					$this->complexTypes[$this->currentComplexType]['elements'][$ename] = $attrs;
1505
+				} elseif (!isset($attrs['ref'])) {
1506
+					$this->xdebug("add element $ename to elements array");
1507
+					$this->elements[$attrs['name']] = $attrs;
1508
+					$this->elements[$attrs['name']]['typeClass'] = 'element';
1509
+				}
1510
+				break;
1511
+			case 'enumeration':    //	restriction value list member
1512
+				$this->xdebug('enumeration ' . $attrs['value']);
1513
+				if ($this->currentSimpleType) {
1514
+					$this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
1515
+				} elseif ($this->currentComplexType) {
1516
+					$this->complexTypes[$this->currentComplexType]['enumeration'][] = $attrs['value'];
1517
+				}
1518
+				break;
1519
+			case 'extension':    // simpleContent or complexContent type extension
1520
+				$this->xdebug('extension ' . $attrs['base']);
1521
+				if ($this->currentComplexType) {
1522
+					$ns = $this->getPrefix($attrs['base']);
1523
+					if ($ns == '') {
1524
+						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
1525
+					} else {
1526
+						$this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
1527
+					}
1528
+				} else {
1529
+					$this->xdebug('no current complexType to set extensionBase');
1530
+				}
1531
+				break;
1532
+			case 'import':
1533
+				if (isset($attrs['schemaLocation'])) {
1534
+					$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
1535
+					$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1536
+				} else {
1537
+					$this->xdebug('import namespace ' . $attrs['namespace']);
1538
+					$this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1539
+					if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
1540
+						$this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
1541
+					}
1542
+				}
1543
+				break;
1544
+			case 'include':
1545
+				if (isset($attrs['schemaLocation'])) {
1546
+					$this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
1547
+					$this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1548
+				} else {
1549
+					$this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
1550
+				}
1551
+				break;
1552
+			case 'list':    // simpleType value list
1553
+				$this->xdebug("do nothing for element $name");
1554
+				break;
1555
+			case 'restriction':    // simpleType, simpleContent or complexContent value restriction
1556
+				$this->xdebug('restriction ' . $attrs['base']);
1557
+				if ($this->currentSimpleType) {
1558
+					$this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1559
+				} elseif ($this->currentComplexType) {
1560
+					$this->complexTypes[$this->currentComplexType]['restrictionBase'] = $attrs['base'];
1561
+					if (strstr($attrs['base'], ':') == ':Array') {
1562
+						$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
1563
+					}
1564
+				}
1565
+				break;
1566
+			case 'schema':
1567
+				$this->schemaInfo = $attrs;
1568
+				$this->schemaInfo['schemaVersion'] = $this->getNamespaceFromPrefix($prefix);
1569
+				if (isset($attrs['targetNamespace'])) {
1570
+					$this->schemaTargetNamespace = $attrs['targetNamespace'];
1571
+				}
1572
+				if (!isset($attrs['elementFormDefault'])) {
1573
+					$this->schemaInfo['elementFormDefault'] = 'unqualified';
1574
+				}
1575
+				if (!isset($attrs['attributeFormDefault'])) {
1576
+					$this->schemaInfo['attributeFormDefault'] = 'unqualified';
1577
+				}
1578
+				break;
1579
+			case 'simpleContent':    // (optional) content for a complexType
1580
+				if ($this->currentComplexType) {    // This should *always* be
1581
+					$this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
1582
+				} else {
1583
+					$this->xdebug("do nothing for element $name because there is no current complexType");
1584
+				}
1585
+				break;
1586
+			case 'simpleType':
1587
+				$this->simpleTypeStack[] = $this->currentSimpleType;
1588
+				if (isset($attrs['name'])) {
1589
+					$this->xdebug("processing simpleType for name " . $attrs['name']);
1590
+					$this->currentSimpleType = $attrs['name'];
1591
+					$this->simpleTypes[$attrs['name']] = $attrs;
1592
+					$this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
1593
+					$this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
1594
+				} else {
1595
+					$name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
1596
+					$this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
1597
+					$this->currentSimpleType = $name;
1598
+					//$this->currentElement = false;
1599
+					$this->simpleTypes[$this->currentSimpleType] = $attrs;
1600
+					$this->simpleTypes[$this->currentSimpleType]['phpType'] = 'scalar';
1601
+				}
1602
+				break;
1603
+			case 'union':    // simpleType type list
1604
+				$this->xdebug("do nothing for element $name");
1605
+				break;
1606
+			default:
1607
+				$this->xdebug("do not have any logic to process element $name");
1608
+		}
1609
+	}
1610
+
1611
+	/**
1612
+	 * end-element handler
1613
+	 *
1614
+	 * @param    string $parser XML parser object
1615
+	 * @param    string $name element name
1616
+	 * @access   private
1617
+	 */
1618
+	function schemaEndElement($parser, $name)
1619
+	{
1620
+		// bring depth down a notch
1621
+		$this->depth--;
1622
+		// get element prefix
1623
+		if ($this->getPrefix($name)) {
1624
+			// get unqualified name
1625
+			$name = $this->getLocalPart($name);
1626
+		}
1627
+		// move on...
1628
+		if ($name == 'complexType') {
1629
+			$this->xdebug('done processing complexType ' . ($this->currentComplexType ?: '(unknown)'));
1630
+			$this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
1631
+			$this->currentComplexType = array_pop($this->complexTypeStack);
1632
+			//$this->currentElement = false;
1633
+		}
1634
+		if ($name == 'element') {
1635
+			$this->xdebug('done processing element ' . ($this->currentElement ?: '(unknown)'));
1636
+			$this->currentElement = array_pop($this->elementStack);
1637
+		}
1638
+		if ($name == 'simpleType') {
1639
+			$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ?: '(unknown)'));
1640
+			$this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
1641
+			$this->currentSimpleType = array_pop($this->simpleTypeStack);
1642
+		}
1643
+	}
1644
+
1645
+	/**
1646
+	 * element content handler
1647
+	 *
1648
+	 * @param    string $parser XML parser object
1649
+	 * @param    string $data element content
1650
+	 * @access   private
1651
+	 */
1652
+	function schemaCharacterData($parser, $data)
1653
+	{
1654
+		$pos = $this->depth_array[$this->depth - 1];
1655
+		$this->message[$pos]['cdata'] .= $data;
1656
+	}
1657
+
1658
+	/**
1659
+	 * serialize the schema
1660
+	 *
1661
+	 * @access   public
1662
+	 */
1663
+	function serializeSchema()
1664
+	{
1665
+
1666
+		$schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion);
1667
+		$xml = '';
1668
+		// imports
1669
+		if (sizeof($this->imports) > 0) {
1670
+			foreach ($this->imports as $ns => $list) {
1671
+				foreach ($list as $ii) {
1672
+					if ($ii['location'] != '') {
1673
+						$xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
1674
+					} else {
1675
+						$xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
1676
+					}
1677
+				}
1678
+			}
1679
+		}
1680
+		// complex types
1681
+		foreach ($this->complexTypes as $typeName => $attrs) {
1682
+			$contentStr = '';
1683
+			// serialize child elements
1684
+			if (isset($attrs['elements']) && (count($attrs['elements']) > 0)) {
1685
+				foreach ($attrs['elements'] as $element => $eParts) {
1686
+					if (isset($eParts['ref'])) {
1687
+						$contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
1688
+					} else {
1689
+						$contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
1690
+						foreach ($eParts as $aName => $aValue) {
1691
+							// handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
1692
+							if ($aName != 'name' && $aName != 'type') {
1693
+								$contentStr .= " $aName=\"$aValue\"";
1694
+							}
1695
+						}
1696
+						$contentStr .= "/>\n";
1697
+					}
1698
+				}
1699
+				// compositor wraps elements
1700
+				if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
1701
+					$contentStr = "  <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . "  </$schemaPrefix:$attrs[compositor]>\n";
1702
+				}
1703
+			}
1704
+			// attributes
1705
+			if (isset($attrs['attrs']) && (count($attrs['attrs']) >= 1)) {
1706
+				foreach ($attrs['attrs'] as $aParts) {
1707
+					$contentStr .= "    <$schemaPrefix:attribute";
1708
+					foreach ($aParts as $a => $v) {
1709
+						if ($a == 'ref' || $a == 'type') {
1710
+							$contentStr .= " $a=\"" . $this->contractQName($v) . '"';
1711
+						} elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
1712
+							$this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1713
+							$contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"';
1714
+						} else {
1715
+							$contentStr .= " $a=\"$v\"";
1716
+						}
1717
+					}
1718
+					$contentStr .= "/>\n";
1719
+				}
1720
+			}
1721
+			// if restriction
1722
+			if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
1723
+				$contentStr = "   <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . "   </$schemaPrefix:restriction>\n";
1724
+				// complex or simple content
1725
+				if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
1726
+					$contentStr = "  <$schemaPrefix:complexContent>\n" . $contentStr . "  </$schemaPrefix:complexContent>\n";
1727
+				}
1728
+			}
1729
+			// finalize complex type
1730
+			if ($contentStr != '') {
1731
+				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " </$schemaPrefix:complexType>\n";
1732
+			} else {
1733
+				$contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1734
+			}
1735
+			$xml .= $contentStr;
1736
+		}
1737
+		// simple types
1738
+		if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
1739
+			foreach ($this->simpleTypes as $typeName => $eParts) {
1740
+				$xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts['type']) . "\">\n";
1741
+				if (isset($eParts['enumeration'])) {
1742
+					foreach ($eParts['enumeration'] as $e) {
1743
+						$xml .= "  <$schemaPrefix:enumeration value=\"$e\"/>\n";
1744
+					}
1745
+				}
1746
+				$xml .= "  </$schemaPrefix:restriction>\n </$schemaPrefix:simpleType>";
1747
+			}
1748
+		}
1749
+		// elements
1750
+		if (isset($this->elements) && count($this->elements) > 0) {
1751
+			foreach ($this->elements as $element => $eParts) {
1752
+				$xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
1753
+			}
1754
+		}
1755
+		// attributes
1756
+		if (isset($this->attributes) && count($this->attributes) > 0) {
1757
+			foreach ($this->attributes as $attr => $aParts) {
1758
+				$xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n/>";
1759
+			}
1760
+		}
1761
+		// finish 'er up
1762
+		$attr = '';
1763
+		foreach ($this->schemaInfo as $k => $v) {
1764
+			if ($k == 'elementFormDefault' || $k == 'attributeFormDefault') {
1765
+				$attr .= " $k=\"$v\"";
1766
+			}
1767
+		}
1768
+		$el = "<$schemaPrefix:schema$attr targetNamespace=\"$this->schemaTargetNamespace\"\n";
1769
+		foreach (array_diff($this->usedNamespaces, $this->enclosingNamespaces) as $nsp => $ns) {
1770
+			$el .= " xmlns:$nsp=\"$ns\"";
1771
+		}
1772
+
1773
+	  return $el . ">\n" . $xml . "</$schemaPrefix:schema>\n";
1774
+	}
1775
+
1776
+	/**
1777
+	 * adds debug data to the clas level debug string
1778
+	 *
1779
+	 * @param    string $string debug data
1780
+	 * @access   private
1781
+	 */
1782
+	function xdebug($string)
1783
+	{
1784
+		$this->debug('<' . $this->schemaTargetNamespace . '> ' . $string);
1785
+	}
1786
+
1787
+	/**
1788
+	 * get the PHP type of a user defined type in the schema
1789
+	 * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
1790
+	 * returns false if no type exists, or not w/ the given namespace
1791
+	 * else returns a string that is either a native php type, or 'struct'
1792
+	 *
1793
+	 * @param string $type name of defined type
1794
+	 * @param string $ns namespace of type
1795
+	 * @return mixed
1796
+	 * @access public
1797
+	 * @deprecated
1798
+	 */
1799
+	function getPHPType($type, $ns)
1800
+	{
1801
+		if (isset($this->typemap[$ns][$type])) {
1802
+			//print "found type '$type' and ns $ns in typemap<br>";
1803
+			return $this->typemap[$ns][$type];
1804
+		} elseif (isset($this->complexTypes[$type])) {
1805
+			//print "getting type '$type' and ns $ns from complexTypes array<br>";
1806
+			return $this->complexTypes[$type]['phpType'];
1807
+		}
1808
+		return false;
1809
+	}
1810
+
1811
+	/**
1812
+	 * returns an associative array of information about a given type
1813
+	 * returns false if no type exists by the given name
1814
+	 *
1815
+	 *    For a complexType typeDef = array(
1816
+	 *    'restrictionBase' => '',
1817
+	 *    'phpType' => '',
1818
+	 *    'compositor' => '(sequence|all)',
1819
+	 *    'elements' => array(), // refs to elements array
1820
+	 *    'attrs' => array() // refs to attributes array
1821
+	 *    ... and so on (see addComplexType)
1822
+	 *    )
1823
+	 *
1824
+	 *   For simpleType or element, the array has different keys.
1825
+	 *
1826
+	 * @param string $type
1827
+	 * @return mixed
1828
+	 * @access public
1829
+	 * @see addComplexType
1830
+	 * @see addSimpleType
1831
+	 * @see addElement
1832
+	 */
1833
+	function getTypeDef($type)
1834
+	{
1835
+		//$this->debug("in getTypeDef for type $type");
1836
+		if (substr($type, -1) == '^') {
1837
+			$is_element = 1;
1838
+			$type = substr($type, 0, -1);
1839
+		} else {
1840
+			$is_element = 0;
1841
+		}
1842
+
1843
+		if ((!$is_element) && isset($this->complexTypes[$type])) {
1844
+			$this->xdebug("in getTypeDef, found complexType $type");
1845
+			return $this->complexTypes[$type];
1846
+		} elseif ((!$is_element) && isset($this->simpleTypes[$type])) {
1847
+			$this->xdebug("in getTypeDef, found simpleType $type");
1848
+			if (!isset($this->simpleTypes[$type]['phpType'])) {
1849
+				// get info for type to tack onto the simple type
1850
+				// TODO: can this ever really apply (i.e. what is a simpleType really?)
1851
+				$uqType = substr($this->simpleTypes[$type]['type'], strrpos($this->simpleTypes[$type]['type'], ':') + 1);
1852
+				$etype = $this->getTypeDef($uqType);
1853
+				if ($etype) {
1854
+					$this->xdebug("in getTypeDef, found type for simpleType $type:");
1855
+					$this->xdebug($this->varDump($etype));
1856
+					if (isset($etype['phpType'])) {
1857
+						$this->simpleTypes[$type]['phpType'] = $etype['phpType'];
1858
+					}
1859
+					if (isset($etype['elements'])) {
1860
+						$this->simpleTypes[$type]['elements'] = $etype['elements'];
1861
+					}
1862
+				}
1863
+			}
1864
+			return $this->simpleTypes[$type];
1865
+		} elseif (isset($this->elements[$type])) {
1866
+			$this->xdebug("in getTypeDef, found element $type");
1867
+			if (!isset($this->elements[$type]['phpType'])) {
1868
+				// get info for type to tack onto the element
1869
+				$uqType = substr($this->elements[$type]['type'], strrpos($this->elements[$type]['type'], ':') + 1);
1870
+				$ns = substr($this->elements[$type]['type'], 0, strrpos($this->elements[$type]['type'], ':'));
1871
+				$etype = $this->getTypeDef($uqType);
1872
+				if ($etype) {
1873
+					$this->xdebug("in getTypeDef, found type for element $type:");
1874
+					$this->xdebug($this->varDump($etype));
1875
+					if (isset($etype['phpType'])) {
1876
+						$this->elements[$type]['phpType'] = $etype['phpType'];
1877
+					}
1878
+					if (isset($etype['elements'])) {
1879
+						$this->elements[$type]['elements'] = $etype['elements'];
1880
+					}
1881
+					if (isset($etype['extensionBase'])) {
1882
+						$this->elements[$type]['extensionBase'] = $etype['extensionBase'];
1883
+					}
1884
+				} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
1885
+					$this->xdebug("in getTypeDef, element $type is an XSD type");
1886
+					$this->elements[$type]['phpType'] = 'scalar';
1887
+				}
1888
+			}
1889
+			return $this->elements[$type];
1890
+		} elseif (isset($this->attributes[$type])) {
1891
+			$this->xdebug("in getTypeDef, found attribute $type");
1892
+			return $this->attributes[$type];
1893
+		} elseif (preg_match('/_ContainedType$/', $type)) {
1894
+			$this->xdebug("in getTypeDef, have an untyped element $type");
1895
+			$typeDef['typeClass'] = 'simpleType';
1896
+			$typeDef['phpType'] = 'scalar';
1897
+			$typeDef['type'] = 'http://www.w3.org/2001/XMLSchema:string';
1898
+			return $typeDef;
1899
+		}
1900
+		$this->xdebug("in getTypeDef, did not find $type");
1901
+		return false;
1902
+	}
1903
+
1904
+	/**
1905
+	 * returns a sample serialization of a given type, or false if no type by the given name
1906
+	 *
1907
+	 * @param string $type name of type
1908
+	 * @return false|string
1909
+	 * @access public
1910
+	 */
1911
+	function serializeTypeDef($type)
1912
+	{
1913
+		$str = '';
1914
+		//print "in sTD() for type $type<br>";
1915
+		if ($typeDef = $this->getTypeDef($type)) {
1916
+			$str .= '<' . $type;
1917
+			if (is_array($typeDef['attrs'])) {
1918
+				foreach ($typeDef['attrs'] as $attName => $data) {
1919
+					$str .= " $attName=\"{type = " . $data['type'] . "}\"";
1920
+				}
1921
+			}
1922
+			$str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
1923
+			if (count($typeDef['elements']) > 0) {
1924
+				$str .= ">";
1925
+				foreach ($typeDef['elements'] as $element => $eData) {
1926
+					$str .= $this->serializeTypeDef($element);
1927
+				}
1928
+				$str .= "</$type>";
1929
+			} elseif ($typeDef['typeClass'] == 'element') {
1930
+				$str .= "></$type>";
1931
+			} else {
1932
+				$str .= "/>";
1933
+			}
1934
+			return $str;
1935
+		}
1936
+		return false;
1937
+	}
1938
+
1939
+	/**
1940
+	 * returns HTML form elements that allow a user
1941
+	 * to enter values for creating an instance of the given type.
1942
+	 *
1943
+	 * @param string $name name for type instance
1944
+	 * @param string $type name of type
1945
+	 * @return string
1946
+	 * @access public
1947
+	 * @deprecated
1948
+	 */
1949
+	function typeToForm($name, $type)
1950
+	{
1951
+		$buffer = '';
1952
+		// get typedef
1953
+		if ($typeDef = $this->getTypeDef($type)) {
1954
+			// if struct
1955
+			if ($typeDef['phpType'] == 'struct') {
1956
+				$buffer .= '<table>';
1957
+				foreach ($typeDef['elements'] as $childDef) {
1958
+					$buffer .= "
1959
+					<tr><td align='right'>$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):</td>
1960
+					<td><input type='text' name='parameters[" . $name . "][$childDef[name]]'></td></tr>";
1961
+				}
1962
+				$buffer .= '</table>';
1963
+				// if array
1964
+			} elseif ($typeDef['phpType'] == 'array') {
1965
+				$buffer .= '<table>';
1966
+			  $buffer .= str_repeat ("
1967
+					<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1968
+					<td><input type='text' name='parameters[" . $name . "][]'></td></tr>", 3);
1969
+				$buffer .= '</table>';
1970
+				// if scalar
1971
+			} else {
1972
+				$buffer .= "<input type='text' name='parameters[$name]'>";
1973
+			}
1974
+		} else {
1975
+			$buffer .= "<input type='text' name='parameters[$name]'>";
1976
+		}
1977
+		return $buffer;
1978
+	}
1979
+
1980
+	/**
1981
+	 * adds a complex type to the schema
1982
+	 * example: array
1983
+	 * addType(
1984
+	 *    'ArrayOfstring',
1985
+	 *    'complexType',
1986
+	 *    'array',
1987
+	 *    '',
1988
+	 *    'SOAP-ENC:Array',
1989
+	 *    array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'),
1990
+	 *    'xsd:string'
1991
+	 * );
1992
+	 * example: PHP associative array ( SOAP Struct )
1993
+	 * addType(
1994
+	 *    'SOAPStruct',
1995
+	 *    'complexType',
1996
+	 *    'struct',
1997
+	 *    'all',
1998
+	 *    array('myVar'=> array('name'=>'myVar','type'=>'string')
1999
+	 * );
2000
+	 *
2001
+	 * @param string $name
2002
+	 * @param string $typeClass (complexType|simpleType|attribute)
2003
+	 * @param string $phpType : currently supported are array and struct (php assoc array)
2004
+	 * @param string $compositor (all|sequence|choice)
2005
+	 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
2006
+	 * @param array $elements = array ( name = array(name=>'',type=>'') )
2007
+	 * @param array $attrs = array(
2008
+	 *    array(
2009
+	 *        'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType",
2010
+	 *        "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]"
2011
+	 *    )
2012
+	 * )
2013
+	 * @param array $arrayType : namespace:name (http://www.w3.org/2001/XMLSchema:string)
2014
+	 *
2015
+	 * @access public
2016
+	 * @see getTypeDef
2017
+	 */
2018
+	function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '')
2019
+	{
2020
+		$this->complexTypes[$name] = array(
2021
+			'name' => $name,
2022
+			'typeClass' => $typeClass,
2023
+			'phpType' => $phpType,
2024
+			'compositor' => $compositor,
2025
+			'restrictionBase' => $restrictionBase,
2026
+			'elements' => $elements,
2027
+			'attrs' => $attrs,
2028
+			'arrayType' => $arrayType
2029
+		);
2030
+
2031
+		$this->xdebug("addComplexType $name:");
2032
+		$this->appendDebug($this->varDump($this->complexTypes[$name]));
2033
+	}
2034
+
2035
+	/**
2036
+	 * adds a simple type to the schema
2037
+	 *
2038
+	 * @param string $name
2039
+	 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
2040
+	 * @param string $typeClass (should always be simpleType)
2041
+	 * @param string $phpType (should always be scalar)
2042
+	 * @param array $enumeration array of values
2043
+	 * @access public
2044
+	 * @see nusoap_xmlschema
2045
+	 * @see getTypeDef
2046
+	 */
2047
+	function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array())
2048
+	{
2049
+		$this->simpleTypes[$name] = array(
2050
+			'name' => $name,
2051
+			'typeClass' => $typeClass,
2052
+			'phpType' => $phpType,
2053
+			'type' => $restrictionBase,
2054
+			'enumeration' => $enumeration
2055
+		);
2056
+
2057
+		$this->xdebug("addSimpleType $name:");
2058
+		$this->appendDebug($this->varDump($this->simpleTypes[$name]));
2059
+	}
2060
+
2061
+	/**
2062
+	 * adds an element to the schema
2063
+	 *
2064
+	 * @param array $attrs attributes that must include name and type
2065
+	 * @see nusoap_xmlschema
2066
+	 * @access public
2067
+	 */
2068
+	function addElement($attrs)
2069
+	{
2070
+		if (!$this->getPrefix($attrs['type'])) {
2071
+			$attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
2072
+		}
2073
+		$this->elements[$attrs['name']] = $attrs;
2074
+		$this->elements[$attrs['name']]['typeClass'] = 'element';
2075
+
2076
+		$this->xdebug("addElement " . $attrs['name']);
2077
+		$this->appendDebug($this->varDump($this->elements[$attrs['name']]));
2078
+	}
2079
+}
2080
+
2081
+/**
2082
+ * Backward compatibility
2083
+ */
2084
+class XMLSchema extends nusoap_xmlschema
2085
+{
2086
+}
2087
+
2088
+
2089
+/**
2090
+ * For creating serializable abstractions of native PHP types.  This class
2091
+ * allows element name/namespace, XSD type, and XML attributes to be
2092
+ * associated with a value.  This is extremely useful when WSDL is not
2093
+ * used, but is also useful when WSDL is used with polymorphic types, including
2094
+ * xsd:anyType and user-defined types.
2095
+ *
3534 2096
  * @author   Dietrich Ayala <[email protected]>
3535
- * @author   Scott Nichol <[email protected]>
3536 2097
  * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
3537 2098
  * @access   public
3538 2099
  */
3539
-class nusoap_server extends nusoap_base
2100
+class soapval extends nusoap_base
3540 2101
 {
3541
-    /**
3542
-     * HTTP headers of request
3543
-     *
3544
-     * @var array
3545
-     * @access private
3546
-     */
3547
-    var $headers = array();
3548
-    /**
3549
-     * HTTP request
3550
-     *
3551
-     * @var string
3552
-     * @access private
3553
-     */
3554
-    var $request = '';
3555
-    /**
3556
-     * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
3557
-     *
3558
-     * @var string
3559
-     * @access public
3560
-     */
3561
-    var $requestHeaders = '';
3562
-    /**
3563
-     * SOAP Headers from request (parsed)
3564
-     *
3565
-     * @var mixed
3566
-     * @access public
3567
-     */
3568
-    var $requestHeader = null;
3569
-    /**
3570
-     * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
3571
-     *
3572
-     * @var string
3573
-     * @access public
3574
-     */
3575
-    var $document = '';
3576
-    /**
3577
-     * SOAP payload for request (text)
3578
-     *
3579
-     * @var string
3580
-     * @access public
3581
-     */
3582
-    var $requestSOAP = '';
3583
-    /**
3584
-     * requested method namespace URI
3585
-     *
3586
-     * @var string
3587
-     * @access private
3588
-     */
3589
-    var $methodURI = '';
3590
-    /**
3591
-     * name of method requested
3592
-     *
3593
-     * @var string
3594
-     * @access private
3595
-     */
3596
-    var $methodname = '';
3597
-    /**
3598
-     * name of the response tag name
3599
-     *
3600
-     * @var string
3601
-     * @access private
3602
-     */
3603
-    var $responseTagName = '';
3604
-    /**
3605
-     * method parameters from request
3606
-     *
3607
-     * @var array
3608
-     * @access private
3609
-     */
3610
-    var $methodparams = array();
3611
-    /**
3612
-     * SOAP Action from request
3613
-     *
3614
-     * @var string
3615
-     * @access private
3616
-     */
3617
-    var $SOAPAction = '';
3618
-    /**
3619
-     * character set encoding of incoming (request) messages
3620
-     *
3621
-     * @var string
3622
-     * @access public
3623
-     */
3624
-    var $xml_encoding = '';
3625
-    /**
3626
-     * toggles whether the parser decodes element content w/ utf8_decode()
3627
-     *
3628
-     * @var boolean
3629
-     * @access public
3630
-     */
3631
-    var $decode_utf8 = true;
3632
-
3633
-    /**
3634
-     * HTTP headers of response
3635
-     *
3636
-     * @var array
3637
-     * @access public
3638
-     */
3639
-    var $outgoing_headers = array();
3640
-    /**
3641
-     * HTTP response
3642
-     *
3643
-     * @var string
3644
-     * @access private
3645
-     */
3646
-    var $response = '';
3647
-    /**
3648
-     * SOAP headers for response (text or array of soapval or associative array)
3649
-     *
3650
-     * @var mixed
3651
-     * @access public
3652
-     */
3653
-    var $responseHeaders = '';
3654
-    /**
3655
-     * SOAP payload for response (text)
3656
-     *
3657
-     * @var string
3658
-     * @access private
3659
-     */
3660
-    var $responseSOAP = '';
3661
-    /**
3662
-     * SOAP attachments in response
3663
-     *
3664
-     * @var string
3665
-     * @access private
3666
-     */
3667
-    var $attachments= '';
3668
-    /**
3669
-     * method return value to place in response
3670
-     *
3671
-     * @var mixed
3672
-     * @access private
3673
-     */
3674
-    var $methodreturn = false;
3675
-    /**
3676
-     * whether $methodreturn is a string of literal XML
3677
-     *
3678
-     * @var boolean
3679
-     * @access public
3680
-     */
3681
-    var $methodreturnisliteralxml = false;
3682
-    /**
3683
-     * SOAP fault for response (or false)
3684
-     *
3685
-     * @var mixed
3686
-     * @access private
3687
-     */
3688
-    var $fault = false;
3689
-    /**
3690
-     * text indication of result (for debugging)
3691
-     *
3692
-     * @var string
3693
-     * @access private
3694
-     */
3695
-    var $result = 'successful';
3696
-
3697
-    /**
3698
-     * assoc array of operations => opData; operations are added by the register()
3699
-     * method or by parsing an external WSDL definition
3700
-     *
3701
-     * @var array
3702
-     * @access private
3703
-     */
3704
-    var $operations = array();
3705
-    /**
3706
-     * wsdl instance (if one)
3707
-     *
3708
-     * @var mixed
3709
-     * @access private
3710
-     */
3711
-    var $wsdl = false;
3712
-    /**
3713
-     * URL for WSDL (if one)
3714
-     *
3715
-     * @var mixed
3716
-     * @access private
3717
-     */
3718
-    var $externalWSDLURL = false;
3719
-    /**
3720
-     * whether to append debug to response as XML comment
3721
-     *
3722
-     * @var boolean
3723
-     * @access public
3724
-     */
3725
-    var $debug_flag = false;
3726
-
3727
-    /** @var array */
3728
-    var $opData;
3729
-
3730
-
3731
-    /**
3732
-     * constructor
3733
-     * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
3734
-     *
3735
-     * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
3736
-     * @access   public
3737
-     */
3738
-    function __construct($wsdl = false)
3739
-    {
3740
-        parent::__construct();
3741
-        // turn on debugging?
3742
-        global $debug;
3743
-        global $HTTP_SERVER_VARS;
3744
-
3745
-        if (isset($_SERVER)) {
3746
-            $this->debug("_SERVER is defined:");
3747
-            $this->appendDebug($this->varDump($_SERVER));
3748
-        } elseif (isset($HTTP_SERVER_VARS)) {
3749
-            $this->debug("HTTP_SERVER_VARS is defined:");
3750
-            $this->appendDebug($this->varDump($HTTP_SERVER_VARS));
3751
-        } else {
3752
-            $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3753
-        }
3754
-
3755
-        if (isset($debug)) {
3756
-            $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
3757
-            $this->debug_flag = $debug;
3758
-        } elseif (isset($_SERVER['QUERY_STRING'])) {
3759
-            $qs = explode('&', $_SERVER['QUERY_STRING']);
3760
-            foreach ($qs as $v) {
3761
-                if (substr($v, 0, 6) == 'debug=') {
3762
-                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
3763
-                    $this->debug_flag = substr($v, 6);
3764
-                }
3765
-            }
3766
-        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3767
-            $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
3768
-            foreach ($qs as $v) {
3769
-                if (substr($v, 0, 6) == 'debug=') {
3770
-                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
3771
-                    $this->debug_flag = substr($v, 6);
3772
-                }
3773
-            }
3774
-        }
3775
-
3776
-        // wsdl
3777
-        if ($wsdl) {
3778
-            $this->debug("In nusoap_server, WSDL is specified");
3779
-            if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
3780
-                $this->wsdl = $wsdl;
3781
-                $this->externalWSDLURL = $this->wsdl->wsdl;
3782
-                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
3783
-            } else {
3784
-                $this->debug('Create wsdl from ' . $wsdl);
3785
-                $this->wsdl = new wsdl($wsdl);
3786
-                $this->externalWSDLURL = $wsdl;
3787
-            }
3788
-            $this->appendDebug($this->wsdl->getDebug());
3789
-            $this->wsdl->clearDebug();
3790
-            if ($err = $this->wsdl->getError()) {
3791
-                die('WSDL ERROR: ' . $err);
3792
-            }
3793
-        }
3794
-    }
3795
-
3796
-    /**
3797
-     * processes request and returns response
3798
-     *
3799
-     * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
3800
-     * @access   public
3801
-     */
3802
-    function service($data)
3803
-    {
3804
-        global $HTTP_SERVER_VARS;
3805
-
3806
-        if (isset($_SERVER['REQUEST_METHOD'])) {
3807
-            $rm = $_SERVER['REQUEST_METHOD'];
3808
-        } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
3809
-            $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
3810
-        } else {
3811
-            $rm = '';
3812
-        }
3813
-
3814
-        if (isset($_SERVER['QUERY_STRING'])) {
3815
-            $qs = $_SERVER['QUERY_STRING'];
3816
-        } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3817
-            $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
3818
-        } else {
3819
-            $qs = '';
3820
-        }
3821
-        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
3822
-
3823
-        if ($rm == 'POST') {
3824
-            $this->debug("In service, invoke the request");
3825
-            $this->parse_request($data);
3826
-            if (!$this->fault) {
3827
-                $this->invoke_method();
3828
-            }
3829
-            if (!$this->fault) {
3830
-                $this->serialize_return();
3831
-            }
3832
-            $this->send_response();
3833
-        } elseif (preg_match('/wsdl/', $qs)) {
3834
-            $this->debug("In service, this is a request for WSDL");
3835
-            if ($this->externalWSDLURL) {
3836
-                if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
3837
-                    $this->debug("In service, re-direct for WSDL");
3838
-                    header('Location: ' . $this->externalWSDLURL);
3839
-                } else { // assume file
3840
-                    $this->debug("In service, use file passthru for WSDL");
3841
-                    header("Content-Type: text/xml\r\n");
3842
-                    $fp = fopen($this->externalWSDLURL, 'r');
3843
-                    fpassthru($fp);
3844
-                }
3845
-            } elseif ($this->wsdl) {
3846
-                $this->debug("In service, serialize WSDL");
3847
-                header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
3848
-                print $this->wsdl->serialize($this->debug_flag);
3849
-                if ($this->debug_flag) {
3850
-                    $this->debug('wsdl:');
3851
-                    $this->appendDebug($this->varDump($this->wsdl));
3852
-                    print $this->getDebugAsXMLComment();
3853
-                }
3854
-            } else {
3855
-                $this->debug("In service, there is no WSDL");
3856
-                header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3857
-                print "This service does not provide WSDL";
3858
-            }
3859
-        } elseif ($this->wsdl) {
3860
-            $this->debug("In service, return Web description");
3861
-            print $this->wsdl->webDescription();
3862
-        } else {
3863
-            $this->debug("In service, no Web description");
3864
-            header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3865
-            print "This service does not provide a Web description";
3866
-        }
3867
-    }
3868
-
3869
-    /**
3870
-     * parses HTTP request headers.
3871
-     *
3872
-     * The following fields are set by this function (when successful)
3873
-     *
3874
-     * headers
3875
-     * request
3876
-     * xml_encoding
3877
-     * SOAPAction
3878
-     *
3879
-     * @access   private
3880
-     */
3881
-    function parse_http_headers()
3882
-    {
3883
-        global $HTTP_SERVER_VARS;
3884
-
3885
-        $this->request = '';
3886
-        $this->SOAPAction = '';
3887
-        if (function_exists('getallheaders')) {
3888
-            $this->debug("In parse_http_headers, use getallheaders");
3889
-            $headers = getallheaders();
3890
-            foreach ($headers as $k => $v) {
3891
-                $k = strtolower($k);
3892
-                $this->headers[$k] = $v;
3893
-                $this->request .= "$k: $v\r\n";
3894
-                $this->debug("$k: $v");
3895
-            }
3896
-            // get SOAPAction header
3897
-            if (isset($this->headers['soapaction'])) {
3898
-                $this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
3899
-            }
3900
-            // get the character encoding of the incoming request
3901
-            if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
3902
-                $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
3903
-                if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3904
-                    $this->xml_encoding = strtoupper($enc);
3905
-                } else {
3906
-                    $this->xml_encoding = 'US-ASCII';
3907
-                }
3908
-            } else {
3909
-                // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3910
-                $this->xml_encoding = 'ISO-8859-1';
3911
-            }
3912
-        } elseif (isset($_SERVER) && is_array($_SERVER)) {
3913
-            $this->debug("In parse_http_headers, use _SERVER");
3914
-            foreach ($_SERVER as $k => $v) {
3915
-                if (substr($k, 0, 5) == 'HTTP_') {
3916
-                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3917
-                } else {
3918
-                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3919
-                }
3920
-                if ($k == 'soapaction') {
3921
-                    // get SOAPAction header
3922
-                    $k = 'SOAPAction';
3923
-                    $v = str_replace('"', '', $v);
3924
-                    $v = str_replace('\\', '', $v);
3925
-                    $this->SOAPAction = $v;
3926
-                } elseif ($k == 'content-type') {
3927
-                    // get the character encoding of the incoming request
3928
-                    if (strpos($v, '=')) {
3929
-                        $enc = substr(strstr($v, '='), 1);
3930
-                        $enc = str_replace('"', '', $enc);
3931
-                        $enc = str_replace('\\', '', $enc);
3932
-                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3933
-                            $this->xml_encoding = strtoupper($enc);
3934
-                        } else {
3935
-                            $this->xml_encoding = 'US-ASCII';
3936
-                        }
3937
-                    } else {
3938
-                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3939
-                        $this->xml_encoding = 'ISO-8859-1';
3940
-                    }
3941
-                }
3942
-                $this->headers[$k] = $v;
3943
-                if (is_array($v)) {
3944
-                    $this->request .= "$k: " . json_encode($v) . "\r\n";
3945
-                    $this->debug("$k: " . json_encode($v));
3946
-                } else {
3947
-                    $this->request .= "$k: $v\r\n";
3948
-                    $this->debug("$k: $v");
3949
-                }
3950
-            }
3951
-        } elseif (is_array($HTTP_SERVER_VARS)) {
3952
-            $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
3953
-            foreach ($HTTP_SERVER_VARS as $k => $v) {
3954
-                if (substr($k, 0, 5) == 'HTTP_') {
3955
-                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3956
-                    $k = strtolower(substr($k, 5));
3957
-                } else {
3958
-                    $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3959
-                    $k = strtolower($k);
3960
-                }
3961
-                if ($k == 'soapaction') {
3962
-                    // get SOAPAction header
3963
-                    $k = 'SOAPAction';
3964
-                    $v = str_replace('"', '', $v);
3965
-                    $v = str_replace('\\', '', $v);
3966
-                    $this->SOAPAction = $v;
3967
-                } elseif ($k == 'content-type') {
3968
-                    // get the character encoding of the incoming request
3969
-                    if (strpos($v, '=')) {
3970
-                        $enc = substr(strstr($v, '='), 1);
3971
-                        $enc = str_replace('"', '', $enc);
3972
-                        $enc = str_replace('\\', '', $enc);
3973
-                        if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3974
-                            $this->xml_encoding = strtoupper($enc);
3975
-                        } else {
3976
-                            $this->xml_encoding = 'US-ASCII';
3977
-                        }
3978
-                    } else {
3979
-                        // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3980
-                        $this->xml_encoding = 'ISO-8859-1';
3981
-                    }
3982
-                }
3983
-                $this->headers[$k] = $v;
3984
-                $this->request .= "$k: $v\r\n";
3985
-                $this->debug("$k: $v");
3986
-            }
3987
-        } else {
3988
-            $this->debug("In parse_http_headers, HTTP headers not accessible");
3989
-            $this->setError("HTTP headers not accessible");
3990
-        }
3991
-    }
3992
-
3993
-    /**
3994
-     * parses a request
3995
-     *
3996
-     * The following fields are set by this function (when successful)
3997
-     *
3998
-     * headers
3999
-     * request
4000
-     * xml_encoding
4001
-     * SOAPAction
4002
-     * request
4003
-     * requestSOAP
4004
-     * methodURI
4005
-     * methodname
4006
-     * methodparams
4007
-     * requestHeaders
4008
-     * document
4009
-     *
4010
-     * This sets the fault field on error
4011
-     *
4012
-     * @param    string $data XML string
4013
-     * @access   private
4014
-     */
4015
-    function parse_request($data = '')
4016
-    {
4017
-        $this->debug('entering parse_request()');
4018
-        $this->parse_http_headers();
4019
-        $this->debug('got character encoding: ' . $this->xml_encoding);
4020
-        // uncompress if necessary
4021
-        if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
4022
-            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
4023
-            if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
4024
-                // if decoding works, use it. else assume data wasn't gzencoded
4025
-                if (function_exists('gzuncompress')) {
4026
-                    if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
4027
-                        $data = $degzdata;
4028
-                    } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
4029
-                        $data = $degzdata;
4030
-                    } else {
4031
-                        $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
4032
-                        return;
4033
-                    }
4034
-                } else {
4035
-                    $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
4036
-                    return;
4037
-                }
4038
-            }
4039
-        }
4040
-        $this->request .= "\r\n" . $data;
4041
-        $data = $this->parseRequest($this->headers, $data);
4042
-        $this->requestSOAP = $data;
4043
-        $this->debug('leaving parse_request');
4044
-    }
4045
-
4046
-    /**
4047
-     * invokes a PHP function for the requested SOAP method
4048
-     *
4049
-     * The following fields are set by this function (when successful)
4050
-     *
4051
-     * methodreturn
4052
-     *
4053
-     * Note that the PHP function that is called may also set the following
4054
-     * fields to affect the response sent to the client
4055
-     *
4056
-     * responseHeaders
4057
-     * outgoing_headers
4058
-     *
4059
-     * This sets the fault field on error
4060
-     *
4061
-     * @access   private
4062
-     */
4063
-    function invoke_method()
4064
-    {
4065
-        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
4066
-
4067
-        //
4068
-        // if you are debugging in this area of the code, your service uses a class to implement methods,
4069
-        // you use SOAP RPC, and the client is .NET, please be aware of the following...
4070
-        // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
4071
-        // method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
4072
-        // the XML request and reading the XML response.  you need to add the RequestElementName and
4073
-        // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
4074
-        // generates for the method.  these parameters are used to specify the correct XML element names
4075
-        // for .NET to use, i.e. the names with the '.' in them.
4076
-        //
4077
-        $orig_methodname = $this->methodname;
4078
-        if ($this->wsdl) {
4079
-            if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
4080
-                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
4081
-                $this->appendDebug('opData=' . $this->varDump($this->opData));
4082
-            } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
4083
-                // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
4084
-                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
4085
-                $this->appendDebug('opData=' . $this->varDump($this->opData));
4086
-                $this->methodname = $this->opData['name'];
4087
-            } else {
4088
-                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
4089
-                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
4090
-                return;
4091
-            }
4092
-        } else {
4093
-            $this->debug('in invoke_method, no WSDL to validate method');
4094
-        }
4095
-
4096
-        // if a . is present in $this->methodname, we see if there is a class in scope,
4097
-        // which could be referred to. We will also distinguish between two deliminators,
4098
-        // to allow methods to be called a the class or an instance
4099
-        if (strpos($this->methodname, '..') > 0) {
4100
-            $delim = '..';
4101
-        } elseif (strpos($this->methodname, '.') > 0) {
4102
-            $delim = '.';
4103
-        } else {
4104
-            $delim = '';
4105
-        }
4106
-        $this->debug("in invoke_method, delim=$delim");
4107
-
4108
-        $class = '';
4109
-        $method = '';
4110
-        $try_class = '';
4111
-        if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
4112
-            $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
4113
-            if (class_exists($try_class)) {
4114
-                // get the class and method name
4115
-                $class = $try_class;
4116
-                $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
4117
-                $this->debug("in invoke_method, class=$class method=$method delim=$delim");
4118
-            } else {
4119
-                $this->debug("in invoke_method, class=$try_class not found");
4120
-            }
4121
-        } elseif (strlen($delim) > 0 && substr_count($this->methodname, $delim) > 1) {
4122
-            $split = explode($delim, $this->methodname);
4123
-            $method = array_pop($split);
4124
-            $class = implode('\\', $split);
4125
-        } else {
4126
-            $this->debug("in invoke_method, no class to try");
4127
-        }
4128
-
4129
-        // does method exist?
4130
-        if ($class == '') {
4131
-            if (!function_exists($this->methodname)) {
4132
-                $this->debug("in invoke_method, function '$this->methodname' not found!");
4133
-                $this->result = 'fault: method not found';
4134
-                $this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
4135
-                return;
4136
-            }
4137
-        } else {
4138
-            $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
4139
-            if (!in_array($method_to_compare, get_class_methods($class))) {
4140
-                $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
4141
-                $this->result = 'fault: method not found';
4142
-                $this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
4143
-                return;
4144
-            }
4145
-        }
4146
-
4147
-        // evaluate message, getting back parameters
4148
-        // verify that request parameters match the method's signature
4149
-        if (!$this->verify_method($this->methodname, $this->methodparams)) {
4150
-            // debug
4151
-            $this->debug('ERROR: request not verified against method signature');
4152
-            $this->result = 'fault: request failed validation against method signature';
4153
-            // return fault
4154
-            $this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service.");
4155
-            return;
4156
-        }
4157
-
4158
-        // if there are parameters to pass
4159
-        $this->debug('in invoke_method, params:');
4160
-        $this->appendDebug($this->varDump($this->methodparams));
4161
-        $this->debug("in invoke_method, calling '$this->methodname'");
4162
-        if (!function_exists('call_user_func_array')) {
4163
-            if ($class == '') {
4164
-                $this->debug('in invoke_method, calling function using eval()');
4165
-                $funcCall = "\$this->methodreturn = $this->methodname(";
4166
-            } else {
4167
-                if ($delim == '..') {
4168
-                    $this->debug('in invoke_method, calling class method using eval()');
4169
-                    $funcCall = "\$this->methodreturn = " . $class . "::" . $method . "(";
4170
-                } else {
4171
-                    $this->debug('in invoke_method, calling instance method using eval()');
4172
-                    // generate unique instance name
4173
-                    $instname = "\$inst_" . time();
4174
-                    $funcCall = $instname . " = new " . $class . "(); ";
4175
-                    $funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "(";
4176
-                }
4177
-            }
4178
-            if ($this->methodparams) {
4179
-                foreach ($this->methodparams as $param) {
4180
-                    if (is_array($param) || is_object($param)) {
4181
-                        $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
4182
-                        return;
4183
-                    }
4184
-                    $funcCall .= "\"$param\",";
4185
-                }
4186
-                $funcCall = substr($funcCall, 0, -1);
4187
-            }
4188
-            $funcCall .= ');';
4189
-            $this->debug('in invoke_method, function call: ' . $funcCall);
4190
-            @eval($funcCall);
4191
-        } else {
4192
-            if ($class == '') {
4193
-                $this->debug('in invoke_method, calling function using call_user_func_array()');
4194
-                $call_arg = "$this->methodname";    // straight assignment changes $this->methodname to lower case after call_user_func_array()
4195
-            } elseif ($delim == '..') {
4196
-                $this->debug('in invoke_method, calling class method using call_user_func_array()');
4197
-                $call_arg = array($class, $method);
4198
-            } else {
4199
-                $this->debug('in invoke_method, calling instance method using call_user_func_array()');
4200
-                $instance = new $class ();
4201
-                $call_arg = array(&$instance, $method);
4202
-            }
4203
-            if (is_array($this->methodparams)) {
4204
-                $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
4205
-            } else {
4206
-                $this->methodreturn = call_user_func_array($call_arg, array());
4207
-            }
4208
-        }
4209
-        $this->debug('in invoke_method, methodreturn:');
4210
-        $this->appendDebug($this->varDump($this->methodreturn));
4211
-        $this->debug("in invoke_method, called method $this->methodname, received data of type " . gettype($this->methodreturn));
4212
-    }
4213
-
4214
-    /**
4215
-     * serializes the return value from a PHP function into a full SOAP Envelope
4216
-     *
4217
-     * The following fields are set by this function (when successful)
4218
-     *
4219
-     * responseSOAP
4220
-     *
4221
-     * This sets the fault field on error
4222
-     *
4223
-     * @access   private
4224
-     */
4225
-    function serialize_return()
4226
-    {
4227
-        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4228
-        // if fault
4229
-        if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
4230
-            $this->debug('got a fault object from method');
4231
-            $this->fault = $this->methodreturn;
4232
-            return;
4233
-        } elseif ($this->methodreturnisliteralxml) {
4234
-            $return_val = $this->methodreturn;
4235
-            // returned value(s)
4236
-        } else {
4237
-            $this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method');
4238
-            $this->debug('serializing return value');
4239
-            if ($this->wsdl) {
4240
-                if (sizeof($this->opData['output']['parts']) > 1) {
4241
-                    $this->debug('more than one output part, so use the method return unchanged');
4242
-                    $opParams = $this->methodreturn;
4243
-                } elseif (sizeof($this->opData['output']['parts']) == 1) {
4244
-                    $this->debug('exactly one output part, so wrap the method return in a simple array');
4245
-                    // TODO: verify that it is not already wrapped!
4246
-                    //foreach ($this->opData['output']['parts'] as $name => $type) {
4247
-                    //	$this->debug('wrap in element named ' . $name);
4248
-                    //}
4249
-                    $opParams = array($this->methodreturn);
4250
-                }
4251
-                $opParams = isset($opParams) ? $opParams : [];
4252
-                $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams);
4253
-                $this->appendDebug($this->wsdl->getDebug());
4254
-                $this->wsdl->clearDebug();
4255
-                if ($errstr = $this->wsdl->getError()) {
4256
-                    $this->debug('got wsdl error: ' . $errstr);
4257
-                    $this->fault('SOAP-ENV:Server', 'unable to serialize result');
4258
-                    return;
4259
-                }
4260
-            } else {
4261
-                if (isset($this->methodreturn)) {
4262
-                    $return_val = $this->serialize_val($this->methodreturn, 'return');
4263
-                } else {
4264
-                    $return_val = '';
4265
-                    $this->debug('in absence of WSDL, assume void return for backward compatibility');
4266
-                }
4267
-            }
4268
-        }
4269
-        $this->debug('return value:');
4270
-        $this->appendDebug($this->varDump($return_val));
4271
-
4272
-        $this->debug('serializing response');
4273
-        if ($this->wsdl) {
4274
-            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
4275
-            if ($this->opData['style'] == 'rpc') {
4276
-                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
4277
-                if ($this->opData['output']['use'] == 'literal') {
4278
-                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
4279
-                    if ($this->methodURI) {
4280
-                        $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4281
-                    } else {
4282
-                        $payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . 'Response>';
4283
-                    }
4284
-                } else {
4285
-                    if ($this->methodURI) {
4286
-                        $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4287
-                    } else {
4288
-                        $payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . '>';
4289
-                    }
4290
-                }
4291
-            } else {
4292
-                $this->debug('style is not rpc for serialization: assume document');
4293
-                $payload = $return_val;
4294
-            }
4295
-        } else {
4296
-            $this->debug('do not have WSDL for serialization: assume rpc/encoded');
4297
-            $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4298
-        }
4299
-        $this->result = 'successful';
4300
-        if ($this->wsdl) {
4301
-            //if($this->debug_flag){
4302
-            $this->appendDebug($this->wsdl->getDebug());
4303
-            //	}
4304
-            if (isset($this->opData['output']['encodingStyle'])) {
4305
-                $encodingStyle = $this->opData['output']['encodingStyle'];
4306
-            } else {
4307
-                $encodingStyle = '';
4308
-            }
4309
-            // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
4310
-            $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle);
4311
-        } else {
4312
-            $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders);
4313
-        }
4314
-        $this->debug("Leaving serialize_return");
4315
-    }
4316
-
4317
-    /**
4318
-     * sends an HTTP response
4319
-     *
4320
-     * The following fields are set by this function (when successful)
4321
-     *
4322
-     * outgoing_headers
4323
-     * response
4324
-     *
4325
-     * @access   private
4326
-     */
4327
-    function send_response()
4328
-    {
4329
-        $this->debug('Enter send_response');
4330
-        if ($this->fault) {
4331
-            $payload = $this->fault->serialize();
4332
-            $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
4333
-            $this->outgoing_headers[] = "Status: 500 Internal Server Error";
4334
-        } else {
4335
-            $payload = $this->responseSOAP;
4336
-            // Some combinations of PHP+Web server allow the Status
4337
-            // to come through as a header.  Since OK is the default
4338
-            // just do nothing.
4339
-            // $this->outgoing_headers[] = "HTTP/1.0 200 OK";
4340
-            // $this->outgoing_headers[] = "Status: 200 OK";
4341
-        }
4342
-        // add debug data if in debug mode
4343
-        if (isset($this->debug_flag) && $this->debug_flag) {
4344
-            $payload .= $this->getDebugAsXMLComment();
4345
-        }
4346
-        $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
4347
-        $rev = array();
4348
-        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
4349
-        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . (isset($rev[1]) ? $rev[1] : '') . ")";
4350
-        // Let the Web server decide about this
4351
-        //$this->outgoing_headers[] = "Connection: Close\r\n";
4352
-        $payload = $this->getHTTPBody($payload);
4353
-        $type = $this->getHTTPContentType();
4354
-        $charset = $this->getHTTPContentTypeCharset();
4355
-        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
4356
-        //begin code to compress payload - by John
4357
-        // NOTE: there is no way to know whether the Web server will also compress
4358
-        // this data.
4359
-        if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
4360
-            if (strstr($this->headers['accept-encoding'], 'gzip')) {
4361
-                if (function_exists('gzencode')) {
4362
-                    if (isset($this->debug_flag) && $this->debug_flag) {
4363
-                        $payload .= "<!-- Content being gzipped -->";
4364
-                    }
4365
-                    $this->outgoing_headers[] = "Content-Encoding: gzip";
4366
-                    $payload = gzencode($payload);
4367
-                } else {
4368
-                    if (isset($this->debug_flag) && $this->debug_flag) {
4369
-                        $payload .= "<!-- Content will not be gzipped: no gzencode -->";
4370
-                    }
4371
-                }
4372
-            } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
4373
-                // Note: MSIE requires gzdeflate output (no Zlib header and checksum),
4374
-                // instead of gzcompress output,
4375
-                // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
4376
-                if (function_exists('gzdeflate')) {
4377
-                    if (isset($this->debug_flag) && $this->debug_flag) {
4378
-                        $payload .= "<!-- Content being deflated -->";
4379
-                    }
4380
-                    $this->outgoing_headers[] = "Content-Encoding: deflate";
4381
-                    $payload = gzdeflate($payload);
4382
-                } else {
4383
-                    if (isset($this->debug_flag) && $this->debug_flag) {
4384
-                        $payload .= "<!-- Content will not be deflated: no gzcompress -->";
4385
-                    }
4386
-                }
4387
-            }
4388
-        }
4389
-        //end code
4390
-        $this->outgoing_headers[] = "Content-Length: " . strlen($payload);
4391
-        reset($this->outgoing_headers);
4392
-        foreach ($this->outgoing_headers as $hdr) {
4393
-            header($hdr, false);
4394
-        }
4395
-        print $payload;
4396
-        $this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload;
4397
-    }
4398
-
4399
-    /**
4400
-     * takes the value that was created by parsing the request
4401
-     * and compares to the method's signature, if available.
4402
-     *
4403
-     * @param    string $operation The operation to be invoked
4404
-     * @param    array $request The array of parameter values
4405
-     * @return    boolean    Whether the operation was found
4406
-     * @access   private
4407
-     */
4408
-    function verify_method($operation, $request)
4409
-    {
4410
-        if (isset($this->wsdl) && is_object($this->wsdl)) {
4411
-            if ($this->wsdl->getOperationData($operation)) {
4412
-                return true;
4413
-            }
4414
-        } elseif (isset($this->operations[$operation])) {
4415
-            return true;
4416
-        }
4417
-        return false;
4418
-    }
4419
-
4420
-    /**
4421
-     * processes SOAP message received from client
4422
-     *
4423
-     * @param    array $headers The HTTP headers
4424
-     * @param    string $data unprocessed request data from client
4425
-     * @return   false|void void or false on error
4426
-     * @access   private
4427
-     */
4428
-    function parseRequest($headers, $data)
4429
-    {
4430
-        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
4431
-        $this->appendDebug($this->varDump($headers));
4432
-        if (!isset($headers['content-type'])) {
4433
-            $this->setError('Request not of type '.$this->contentType.' (no content-type header)');
4434
-            return false;
4435
-        }
4436
-        if (!strstr($headers['content-type'], $this->contentType)) {
4437
-            $this->setError('Request not of type '.$this->contentType.': ' . $headers['content-type']);
4438
-            return false;
4439
-        }
4440
-        if (strpos($headers['content-type'], '=')) {
4441
-            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
4442
-            $this->debug('Got response encoding: ' . $enc);
4443
-            if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
4444
-                $this->xml_encoding = strtoupper($enc);
4445
-            } else {
4446
-                $this->xml_encoding = 'US-ASCII';
4447
-            }
4448
-        } else {
4449
-            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
4450
-            $this->xml_encoding = 'ISO-8859-1';
4451
-        }
4452
-        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
4453
-        // parse response, get soap parser obj
4454
-        $parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
4455
-        // parser debug
4456
-        $this->debug("parser debug: \n" . $parser->getDebug());
4457
-        // if fault occurred during message parsing
4458
-        if ($err = $parser->getError()) {
4459
-            $this->result = 'fault: error in msg parsing: ' . $err;
4460
-            $this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err);
4461
-            // else successfully parsed request into soapval object
4462
-        } else {
4463
-            // get/set methodname
4464
-            $this->methodURI = $parser->root_struct_namespace;
4465
-            $this->methodname = $parser->root_struct_name;
4466
-            $this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4467
-
4468
-            // get/set custom response tag name
4469
-            $outputMessage = $this->wsdl->getOperationData($this->methodname)['output']['message'];
4470
-            $this->responseTagName = $outputMessage;
4471
-            $this->debug('responseTagName: ' . $this->responseTagName . ' methodURI: ' . $this->methodURI);
4472
-
4473
-            $this->debug('calling parser->get_soapbody()');
4474
-            $this->methodparams = $parser->get_soapbody();
4475
-            // get SOAP headers
4476
-            $this->requestHeaders = $parser->getHeaders();
4477
-            // get SOAP Header
4478
-            $this->requestHeader = $parser->get_soapheader();
4479
-            // add document for doclit support
4480
-            $this->document = $parser->document;
4481
-        }
4482
-    }
4483
-
4484
-    /**
4485
-     * gets the HTTP body for the current response.
4486
-     *
4487
-     * @param string $soapmsg The SOAP payload
4488
-     * @return string The HTTP body, which includes the SOAP payload
4489
-     * @access private
4490
-     */
4491
-    function getHTTPBody($soapmsg)
4492
-    {
4493
-        return $soapmsg;
4494
-    }
4495
-
4496
-    /**
4497
-     * gets the HTTP content type for the current response.
4498
-     *
4499
-     * Note: getHTTPBody must be called before this.
4500
-     *
4501
-     * @return string the HTTP content type for the current response.
4502
-     * @access private
4503
-     */
4504
-    function getHTTPContentType()
4505
-    {
4506
-        return 'text/xml';
4507
-    }
4508
-
4509
-    /**
4510
-     * gets the HTTP content type charset for the current response.
4511
-     * returns false for non-text content types.
4512
-     *
4513
-     * Note: getHTTPBody must be called before this.
4514
-     *
4515
-     * @return string the HTTP content type charset for the current response.
4516
-     * @access private
4517
-     */
4518
-    function getHTTPContentTypeCharset()
4519
-    {
4520
-        return $this->soap_defencoding;
4521
-    }
4522
-
4523
-    /**
4524
-     * add a method to the dispatch map (this has been replaced by the register method)
4525
-     *
4526
-     * @param    string $methodname
4527
-     * @param    string $in array of input values
4528
-     * @param    string $out array of output values
4529
-     * @access   public
4530
-     * @deprecated
4531
-     */
4532
-    function add_to_map($methodname, $in, $out)
4533
-    {
4534
-        $this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out);
4535
-    }
4536
-
4537
-    /**
4538
-     * register a service function with the server
4539
-     *
4540
-     * @param    string $name the name of the PHP function, class.method or class..method
4541
-     * @param    array $in assoc array of input values: key = param name, value = param type
4542
-     * @param    array $out assoc array of output values: key = param name, value = param type
4543
-     * @param    mixed $namespace the element namespace for the method or false
4544
-     * @param    mixed $soapaction the soapaction for the method or false
4545
-     * @param    mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
4546
-     * @param    mixed $use optional (encoded|literal) or false
4547
-     * @param    string $documentation optional Description to include in WSDL
4548
-     * @param    string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
4549
-     * @param    string $customResponseTagName optional Name of the outgoing response, default $name . 'Response'
4550
-     * @access   public
4551
-     */
4552
-    function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '', $customResponseTagName = '')
4553
-    {
4554
-        global $HTTP_SERVER_VARS;
4555
-
4556
-        if ($this->externalWSDLURL) {
4557
-            die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
4558
-        }
4559
-        if (!$name) {
4560
-            die('You must specify a name when you register an operation');
4561
-        }
4562
-        if (!is_array($in)) {
4563
-            die('You must provide an array for operation inputs');
4564
-        }
4565
-        if (!is_array($out)) {
4566
-            die('You must provide an array for operation outputs');
4567
-        }
4568
-        if (!$soapaction) {
4569
-            if (isset($_SERVER)) {
4570
-                $SERVER_NAME = $_SERVER['SERVER_NAME'];
4571
-                $SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
4572
-                $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
4573
-            } elseif (isset($HTTP_SERVER_VARS)) {
4574
-                $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4575
-                $SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
4576
-                $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4577
-            } else {
4578
-                $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4579
-                $HTTPS = '';
4580
-                $SERVER_NAME = '';
4581
-                $SCRIPT_NAME = '';
4582
-            }
4583
-            if ($HTTPS == '1' || $HTTPS == 'on') {
4584
-                $SCHEME = 'https';
4585
-            } else {
4586
-                $SCHEME = 'http';
4587
-            }
4588
-            $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
4589
-        }
4590
-        if (!$style) {
4591
-            $style = "rpc";
4592
-        }
4593
-        if (!$use) {
4594
-            $use = "encoded";
4595
-        }
4596
-        if ($use == 'encoded' && $encodingStyle == '') {
4597
-            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
4598
-        }
4599
-        if (!$customResponseTagName) {
4600
-            $customResponseTagName = $name . 'Response';
4601
-        }
4602
-
4603
-        $this->operations[$name] = array(
4604
-            'name' => $name,
4605
-            'in' => $in,
4606
-            'out' => $out,
4607
-            'namespace' => $namespace,
4608
-            'soapaction' => $soapaction,
4609
-            'style' => $style,
4610
-            'outputMessage' => $customResponseTagName,
4611
-        );
4612
-        if ($this->wsdl) {
4613
-            $this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle, $customResponseTagName);
4614
-        }
4615
-        return true;
4616
-    }
4617
-
4618
-    /**
4619
-     * Specify a fault to be returned to the client.
4620
-     * This also acts as a flag to the server that a fault has occured.
4621
-     *
4622
-     * @param    string $faultcode
4623
-     * @param    string $faultstring
4624
-     * @param    string $faultactor
4625
-     * @param    string $faultdetail
4626
-     * @access   public
4627
-     */
4628
-    function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '')
4629
-    {
4630
-        if ($faultdetail == '' && $this->debug_flag) {
4631
-            $faultdetail = $this->getDebug();
4632
-        }
4633
-        $this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail);
4634
-        $this->fault->soap_defencoding = $this->soap_defencoding;
4635
-    }
4636
-
4637
-    /**
4638
-     * Sets up wsdl object.
4639
-     * Acts as a flag to enable internal WSDL generation
4640
-     *
4641
-     * @param string $serviceName , name of the service
4642
-     * @param mixed $namespace optional 'tns' service namespace or false
4643
-     * @param mixed $endpoint optional URL of service endpoint or false
4644
-     * @param string $style optional (rpc|document) WSDL style (also specified by operation)
4645
-     * @param string $transport optional SOAP transport
4646
-     * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
4647
-     */
4648
-    function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
4649
-    {
4650
-        global $HTTP_SERVER_VARS;
4651
-
4652
-        if (isset($_SERVER)) {
4653
-            $SERVER_NAME = $_SERVER['SERVER_NAME'];
4654
-            $SERVER_PORT = $_SERVER['SERVER_PORT'];
4655
-            $SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
4656
-            $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
4657
-        } elseif (isset($HTTP_SERVER_VARS)) {
4658
-            $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4659
-            $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
4660
-            $SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
4661
-            $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4662
-        } else {
4663
-            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4664
-            $SERVER_PORT = '';
4665
-            $SERVER_NAME = '';
4666
-            $SCRIPT_NAME = '';
4667
-            $HTTPS = '';
4668
-        }
4669
-        // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
4670
-        $colon = strpos($SERVER_NAME, ":");
4671
-        if ($colon) {
4672
-            $SERVER_NAME = substr($SERVER_NAME, 0, $colon);
4673
-        }
4674
-        if ($SERVER_PORT == 80) {
4675
-            $SERVER_PORT = '';
4676
-        } else {
4677
-            $SERVER_PORT = ':' . $SERVER_PORT;
4678
-        }
4679
-        if (!$namespace) {
4680
-            $namespace = "http://$SERVER_NAME/soap/$serviceName";
4681
-        }
4682
-
4683
-        if (!$endpoint) {
4684
-            if ($HTTPS == '1' || $HTTPS == 'on') {
4685
-                $SCHEME = 'https';
4686
-            } else {
4687
-                $SCHEME = 'http';
4688
-            }
4689
-            $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
4690
-        }
4691
-
4692
-        if (!$schemaTargetNamespace) {
4693
-            $schemaTargetNamespace = $namespace;
4694
-        }
4695
-
4696
-        $this->wsdl = new wsdl;
4697
-        $this->wsdl->serviceName = $serviceName;
4698
-        $this->wsdl->endpoint = $endpoint;
4699
-        $this->wsdl->namespaces['tns'] = $namespace;
4700
-        $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
4701
-        $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
4702
-        if ($schemaTargetNamespace != $namespace) {
4703
-            $this->wsdl->namespaces['types'] = $schemaTargetNamespace;
4704
-        }
4705
-        $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
4706
-        if ($style == 'document') {
4707
-            $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
4708
-        }
4709
-        $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4710
-        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
4711
-        $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
4712
-        $this->wsdl->bindings[$serviceName . 'Binding'] = array(
4713
-            'name' => $serviceName . 'Binding',
4714
-            'style' => $style,
4715
-            'transport' => $transport,
4716
-            'portType' => $serviceName . 'PortType');
4717
-        $this->wsdl->ports[$serviceName . 'Port'] = array(
4718
-            'binding' => $serviceName . 'Binding',
4719
-            'location' => $endpoint,
4720
-            'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/');
4721
-    }
2102
+	/**
2103
+	 * The XML element name
2104
+	 *
2105
+	 * @var string
2106
+	 * @access private
2107
+	 */
2108
+	var $name;
2109
+	/**
2110
+	 * The XML type name (string or false)
2111
+	 *
2112
+	 * @var mixed
2113
+	 * @access private
2114
+	 */
2115
+	var $type;
2116
+	/**
2117
+	 * The PHP value
2118
+	 *
2119
+	 * @var mixed
2120
+	 * @access private
2121
+	 */
2122
+	var $value;
2123
+	/**
2124
+	 * The XML element namespace (string or false)
2125
+	 *
2126
+	 * @var mixed
2127
+	 * @access private
2128
+	 */
2129
+	var $element_ns;
2130
+	/**
2131
+	 * The XML type namespace (string or false)
2132
+	 *
2133
+	 * @var mixed
2134
+	 * @access private
2135
+	 */
2136
+	var $type_ns;
2137
+	/**
2138
+	 * The XML element attributes (array or false)
2139
+	 *
2140
+	 * @var mixed
2141
+	 * @access private
2142
+	 */
2143
+	var $attributes;
2144
+
2145
+	/** @var false|resource */
2146
+	var $fp;
2147
+
2148
+	/**
2149
+	 * constructor
2150
+	 *
2151
+	 * @param    string $name optional name
2152
+	 * @param    mixed $type optional type name
2153
+	 * @param    mixed $value optional value
2154
+	 * @param    mixed $element_ns optional namespace of value
2155
+	 * @param    mixed $type_ns optional namespace of type
2156
+	 * @param    mixed $attributes associative array of attributes to add to element serialization
2157
+	 * @access   public
2158
+	 */
2159
+	function __construct($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false)
2160
+	{
2161
+		parent::__construct();
2162
+		$this->name = $name;
2163
+		$this->type = $type;
2164
+		$this->value = $value;
2165
+		$this->element_ns = $element_ns;
2166
+		$this->type_ns = $type_ns;
2167
+		$this->attributes = $attributes;
2168
+	}
2169
+
2170
+	/**
2171
+	 * return serialized value
2172
+	 *
2173
+	 * @param    string $use The WSDL use value (encoded|literal)
2174
+	 * @return    string XML data
2175
+	 * @access   public
2176
+	 */
2177
+	function serialize($use = 'encoded')
2178
+	{
2179
+		return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
2180
+	}
2181
+
2182
+	/**
2183
+	 * decodes a soapval object into a PHP native type
2184
+	 *
2185
+	 * @return    mixed
2186
+	 * @access   public
2187
+	 */
2188
+	function decode()
2189
+	{
2190
+		return $this->value;
2191
+	}
4722 2192
 }
4723 2193
 
4724
-/**
4725
- * Backward compatibility
4726
- */
4727
-class soap_server extends nusoap_server
4728
-{
4729
-}
4730 2194
 
2195
+/**
2196
+ * transport class for sending/receiving data via HTTP and HTTPS
2197
+ * NOTE: PHP must be compiled with the CURL extension for HTTPS support
2198
+ *
2199
+ * @author   Dietrich Ayala <[email protected]>
2200
+ * @author   Scott Nichol <[email protected]>
2201
+ * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
2202
+ * @access public
2203
+ */
2204
+class soap_transport_http extends nusoap_base
2205
+{
2206
+
2207
+	var $query = '';
2208
+	var $tryagain = false;
2209
+	var $url = '';
2210
+	var $uri = '';
2211
+	var $digest_uri = '';
2212
+	var $scheme = '';
2213
+	var $host = '';
2214
+	var $port = '';
2215
+	var $path = '';
2216
+	var $request_method = 'POST';
2217
+	var $protocol_version = '1.0';
2218
+	var $encoding = '';
2219
+	var $outgoing_headers = array();
2220
+	var $incoming_headers = array();
2221
+	var $incoming_cookies = array();
2222
+	var $outgoing_payload = '';
2223
+	var $incoming_payload = '';
2224
+	var $response_status_line;    // HTTP response status line
2225
+	var $useSOAPAction = true;
2226
+	var $persistentConnection = false;
2227
+	var $ch = false;    // cURL handle
2228
+	var $ch_options = array();    // cURL custom options
2229
+	var $use_curl = false;        // force cURL use
2230
+	var $proxy = null;            // proxy information (associative array)
2231
+	var $username = '';
2232
+	var $password = '';
2233
+	var $authtype = '';
2234
+	var $digestRequest = array();
2235
+	var $certRequest = array();    // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
2236
+	// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
2237
+	// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
2238
+	// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
2239
+	// passphrase: SSL key password/passphrase
2240
+	// certpassword: SSL certificate password
2241
+	// verifypeer: default is 1
2242
+	// verifyhost: default is 1
2243
+
2244
+	/** @var false|resource */
2245
+	var $fp;
2246
+	var $errno;
2247
+
2248
+	/**
2249
+	 * constructor
2250
+	 *
2251
+	 * @param string $url The URL to which to connect
2252
+	 * @param array $curl_options User-specified cURL options
2253
+	 * @param boolean $use_curl Whether to try to force cURL use
2254
+	 * @access public
2255
+	 */
2256
+	function __construct($url, $curl_options = null, $use_curl = false)
2257
+	{
2258
+		parent::__construct();
2259
+		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2260
+		$this->appendDebug($this->varDump($curl_options));
2261
+		$this->setURL($url);
2262
+		if (is_array($curl_options)) {
2263
+			$this->ch_options = $curl_options;
2264
+		}
2265
+		$this->use_curl = $use_curl;
2266
+		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2267
+		$this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . $rev[1] . ')');
2268
+	}
2269
+
2270
+	/**
2271
+	 * sets a cURL option
2272
+	 *
2273
+	 * @param    mixed $option The cURL option (always integer?)
2274
+	 * @param    mixed $value The cURL option value
2275
+	 * @access   private
2276
+	 */
2277
+	function setCurlOption($option, $value)
2278
+	{
2279
+		$this->debug("setCurlOption option=$option, value=");
2280
+		$this->appendDebug($this->varDump($value));
2281
+		curl_setopt($this->ch, $option, $value);
2282
+	}
2283
+
2284
+	/**
2285
+	 * sets an HTTP header
2286
+	 *
2287
+	 * @param string $name The name of the header
2288
+	 * @param string $value The value of the header
2289
+	 * @access private
2290
+	 */
2291
+	function setHeader($name, $value)
2292
+	{
2293
+		$this->outgoing_headers[$name] = $value;
2294
+		$this->debug("set header $name: $value");
2295
+	}
2296
+
2297
+	/**
2298
+	 * unsets an HTTP header
2299
+	 *
2300
+	 * @param string $name The name of the header
2301
+	 * @access private
2302
+	 */
2303
+	function unsetHeader($name)
2304
+	{
2305
+		if (isset($this->outgoing_headers[$name])) {
2306
+			$this->debug("unset header $name");
2307
+			unset($this->outgoing_headers[$name]);
2308
+		}
2309
+	}
2310
+
2311
+	/**
2312
+	 * sets the URL to which to connect
2313
+	 *
2314
+	 * @param string $url The URL to which to connect
2315
+	 * @access private
2316
+	 */
2317
+	function setURL($url)
2318
+	{
2319
+		$this->url = $url;
2320
+
2321
+		$u = parse_url($url);
2322
+		foreach ($u as $k => $v) {
2323
+			$this->debug("parsed URL $k = $v");
2324
+			$this->$k = $v;
2325
+		}
2326
+
2327
+		// add any GET params to path
2328
+		if (isset($u['query']) && $u['query'] != '') {
2329
+			$this->path .= '?' . $u['query'];
2330
+		}
2331
+
2332
+		// set default port
2333
+		if (!isset($u['port'])) {
2334
+			if ($u['scheme'] == 'https') {
2335
+				$this->port = 443;
2336
+			} else {
2337
+				$this->port = 80;
2338
+			}
2339
+		}
2340
+
2341
+		$this->uri = $this->path;
2342
+		$this->digest_uri = $this->uri;
2343
+
2344
+		// build headers
2345
+		if (!isset($u['port'])) {
2346
+			$this->setHeader('Host', $this->host);
2347
+		} else {
2348
+			$this->setHeader('Host', $this->host . ':' . $this->port);
2349
+		}
2350
+
2351
+		if (isset($u['user']) && $u['user'] != '') {
2352
+			$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2353
+		}
2354
+	}
2355
+
2356
+	/**
2357
+	 * gets the I/O method to use
2358
+	 *
2359
+	 * @return    string    I/O method to use (socket|curl|unknown)
2360
+	 * @access    private
2361
+	 */
2362
+	function io_method()
2363
+	{
2364
+		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2365
+			return 'curl';
2366
+		}
2367
+		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2368
+			return 'socket';
2369
+		}
2370
+		return 'unknown';
2371
+	}
2372
+
2373
+	/**
2374
+	 * establish an HTTP connection
2375
+	 *
2376
+	 * @param    integer $connection_timeout set connection timeout in seconds
2377
+	 * @param    integer $response_timeout set response timeout in seconds
2378
+	 * @return    boolean true if connected, false if not
2379
+	 * @access   private
2380
+	 */
2381
+	function connect($connection_timeout = 0, $response_timeout = 30)
2382
+	{
2383
+		// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
2384
+		// "regular" socket.
2385
+		// TODO: disabled for now because OpenSSL must be *compiled* in (not just
2386
+		//       loaded), and until PHP5 stream_get_wrappers is not available.
2387
+//	  	if ($this->scheme == 'https') {
2388
+//		  	if (version_compare(phpversion(), '4.3.0') >= 0) {
2389
+//		  		if (extension_loaded('openssl')) {
2390
+//		  			$this->scheme = 'ssl';
2391
+//		  			$this->debug('Using SSL over OpenSSL');
2392
+//		  		}
2393
+//		  	}
2394
+//		}
2395
+		$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2396
+		if ($this->io_method() == 'socket') {
2397
+			if (!is_array($this->proxy)) {
2398
+				$host = $this->host;
2399
+			} else {
2400
+				$host = $this->proxy['host'];
2401
+			}
2402
+
2403
+			// use persistent connection
2404
+			if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2405
+				if (!feof($this->fp)) {
2406
+					$this->debug('Re-use persistent connection');
2407
+					return true;
2408
+				}
2409
+				fclose($this->fp);
2410
+				$this->debug('Closed persistent connection at EOF');
2411
+			}
2412
+
2413
+			// munge host if using OpenSSL
2414
+			if ($this->scheme == 'ssl') {
2415
+				$host = 'ssl://' . $host;
2416
+			}
2417
+			$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2418
+
2419
+			// open socket
2420
+			if ($connection_timeout > 0) {
2421
+				$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2422
+			} else {
2423
+				$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
2424
+			}
2425
+
2426
+			// test pointer
2427
+			if (!$this->fp) {
2428
+				$msg = 'Couldn\'t open socket connection to server ' . $this->url;
2429
+				if ($this->errno) {
2430
+					$msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2431
+				} else {
2432
+					$msg .= ' prior to connect().  This is often a problem looking up the host name.';
2433
+				}
2434
+				$this->debug($msg);
2435
+				$this->setError($msg);
2436
+				return false;
2437
+			}
2438
+
2439
+			// set response timeout
2440
+			$this->debug('set response timeout to ' . $response_timeout);
2441
+			socket_set_timeout($this->fp, $response_timeout, 0);
2442
+
2443
+			$this->debug('socket connected');
2444
+			return true;
2445
+		} elseif ($this->io_method() == 'curl') {
2446
+			if (!extension_loaded('curl')) {
2447
+//			$this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
2448
+				$this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
2449
+				return false;
2450
+			}
2451
+			// Avoid warnings when PHP does not have these options
2452
+			if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2453
+				$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2454
+			} else {
2455
+				$CURLOPT_CONNECTIONTIMEOUT = 78;
2456
+			}
2457
+			if (defined('CURLOPT_HTTPAUTH')) {
2458
+				$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2459
+			} else {
2460
+				$CURLOPT_HTTPAUTH = 107;
2461
+			}
2462
+			if (defined('CURLOPT_PROXYAUTH')) {
2463
+				$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2464
+			} else {
2465
+				$CURLOPT_PROXYAUTH = 111;
2466
+			}
2467
+			if (defined('CURLAUTH_BASIC')) {
2468
+				$CURLAUTH_BASIC = CURLAUTH_BASIC;
2469
+			} else {
2470
+				$CURLAUTH_BASIC = 1;
2471
+			}
2472
+			if (defined('CURLAUTH_DIGEST')) {
2473
+				$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2474
+			} else {
2475
+				$CURLAUTH_DIGEST = 2;
2476
+			}
2477
+			if (defined('CURLAUTH_NTLM')) {
2478
+				$CURLAUTH_NTLM = CURLAUTH_NTLM;
2479
+			} else {
2480
+				$CURLAUTH_NTLM = 8;
2481
+			}
2482
+
2483
+			$this->debug('connect using cURL');
2484
+			// init CURL
2485
+			$this->ch = curl_init();
2486
+			// set url
2487
+			$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2488
+			// add path
2489
+			$hostURL .= $this->path;
2490
+			$this->setCurlOption(CURLOPT_URL, $hostURL);
2491
+			// follow location headers (re-directs)
2492
+			if (ini_get('safe_mode') || ini_get('open_basedir')) {
2493
+				$this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2494
+				$this->debug('safe_mode = ');
2495
+				$this->appendDebug($this->varDump(ini_get('safe_mode')));
2496
+				$this->debug('open_basedir = ');
2497
+				$this->appendDebug($this->varDump(ini_get('open_basedir')));
2498
+			} else {
2499
+				$this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2500
+			}
2501
+			// ask for headers in the response output
2502
+			$this->setCurlOption(CURLOPT_HEADER, 1);
2503
+			// ask for the response output as the return value
2504
+			$this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2505
+			// encode
2506
+			// We manage this ourselves through headers and encoding
2507
+//		if(function_exists('gzuncompress')){
2508
+//			$this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2509
+//		}
2510
+			// persistent connection
2511
+			if ($this->persistentConnection) {
2512
+				// I believe the following comment is now bogus, having applied to
2513
+				// the code when it used CURLOPT_CUSTOMREQUEST to send the request.
2514
+				// The way we send data, we cannot use persistent connections, since
2515
+				// there will be some "junk" at the end of our request.
2516
+				//$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2517
+				$this->persistentConnection = false;
2518
+				$this->setHeader('Connection', 'close');
2519
+			}
2520
+			// set timeouts
2521
+			if ($connection_timeout != 0) {
2522
+				$this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2523
+			}
2524
+			if ($response_timeout != 0) {
2525
+				$this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2526
+			}
2527
+
2528
+			if ($this->scheme == 'https') {
2529
+				$this->debug('set cURL SSL verify options');
2530
+				// recent versions of cURL turn on peer/host checking by default,
2531
+				// while PHP binaries are not compiled with a default location for the
2532
+				// CA cert bundle, so disable peer/host checking.
2533
+				//$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2534
+				$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2535
+				$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2536
+
2537
+				// support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
2538
+				if ($this->authtype == 'certificate') {
2539
+					$this->debug('set cURL certificate options');
2540
+					if (isset($this->certRequest['cainfofile'])) {
2541
+						$this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2542
+					}
2543
+					if (isset($this->certRequest['verifypeer'])) {
2544
+						$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2545
+					} else {
2546
+						$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2547
+					}
2548
+					if (isset($this->certRequest['verifyhost'])) {
2549
+						$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2550
+					} else {
2551
+						$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2552
+					}
2553
+					if (isset($this->certRequest['sslcertfile'])) {
2554
+						$this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2555
+					}
2556
+					if (isset($this->certRequest['sslkeyfile'])) {
2557
+						$this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2558
+					}
2559
+					if (isset($this->certRequest['passphrase'])) {
2560
+						$this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2561
+					}
2562
+					if (isset($this->certRequest['certpassword'])) {
2563
+						$this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2564
+					}
2565
+				}
2566
+			}
2567
+			if ($this->authtype && ($this->authtype != 'certificate')) {
2568
+				if ($this->username) {
2569
+					$this->debug('set cURL username/password');
2570
+					$this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2571
+				}
2572
+				if ($this->authtype == 'basic') {
2573
+					$this->debug('set cURL for Basic authentication');
2574
+					$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2575
+				}
2576
+				if ($this->authtype == 'digest') {
2577
+					$this->debug('set cURL for digest authentication');
2578
+					$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2579
+				}
2580
+				if ($this->authtype == 'ntlm') {
2581
+					$this->debug('set cURL for NTLM authentication');
2582
+					$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2583
+				}
2584
+			}
2585
+			if (is_array($this->proxy)) {
2586
+				$this->debug('set cURL proxy options');
2587
+				if ($this->proxy['port'] != '') {
2588
+					$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2589
+				} else {
2590
+					$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2591
+				}
2592
+				if ($this->proxy['username'] || $this->proxy['password']) {
2593
+					$this->debug('set cURL proxy authentication options');
2594
+					$this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2595
+					if ($this->proxy['authtype'] == 'basic') {
2596
+						$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2597
+					}
2598
+					if ($this->proxy['authtype'] == 'ntlm') {
2599
+						$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2600
+					}
2601
+				}
2602
+			}
2603
+			$this->debug('cURL connection set up');
2604
+			return true;
2605
+		} else {
2606
+			$this->setError('Unknown scheme ' . $this->scheme);
2607
+			$this->debug('Unknown scheme ' . $this->scheme);
2608
+			return false;
2609
+		}
2610
+	}
2611
+
2612
+	/**
2613
+	 * sends the SOAP request and gets the SOAP response via HTTP[S]
2614
+	 *
2615
+	 * @param    string $data message data
2616
+	 * @param    integer $timeout set connection timeout in seconds
2617
+	 * @param    integer $response_timeout set response timeout in seconds
2618
+	 * @param    array $cookies cookies to send
2619
+	 * @return    string data
2620
+	 * @access   public
2621
+	 */
2622
+	function send($data, $timeout = 0, $response_timeout = 30, $cookies = null)
2623
+	{
2624
+		$this->debug('entered send() with data of length: ' . strlen($data));
2625
+
2626
+		$respdata = "";
2627
+		$this->tryagain = true;
2628
+		$tries = 0;
2629
+		while ($this->tryagain) {
2630
+			$this->tryagain = false;
2631
+			if ($tries++ < 2) {
2632
+				// make connnection
2633
+				if (!$this->connect($timeout, $response_timeout)) {
2634
+					return false;
2635
+				}
2636
+
2637
+				// send request
2638
+				if (!$this->sendRequest($data, $cookies)) {
2639
+					return false;
2640
+				}
2641
+
2642
+				// get response
2643
+				$respdata = $this->getResponse();
2644
+			} else {
2645
+				$this->setError("Too many tries to get an OK response ($this->response_status_line)");
2646
+			}
2647
+		}
2648
+		$this->debug('end of send()');
2649
+		return $respdata;
2650
+	}
2651
+
2652
+
2653
+	/**
2654
+	 * sends the SOAP request and gets the SOAP response via HTTPS using CURL
2655
+	 *
2656
+	 * @param    string $data message data
2657
+	 * @param    integer $timeout set connection timeout in seconds
2658
+	 * @param    integer $response_timeout set response timeout in seconds
2659
+	 * @param    array $cookies cookies to send
2660
+	 * @return    string data
2661
+	 * @access   public
2662
+	 */
2663
+	function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies = NULL)
2664
+	{
2665
+		return $this->send($data, $timeout, $response_timeout, $cookies);
2666
+	}
2667
+
2668
+	/**
2669
+	 * if authenticating, set user credentials here
2670
+	 *
2671
+	 * @param    string $username
2672
+	 * @param    string $password
2673
+	 * @param    string $authtype (basic|digest|certificate|ntlm)
2674
+	 * @param    array $digestRequest (keys must be nonce, nc, realm, qop)
2675
+	 * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
2676
+	 * @access   public
2677
+	 */
2678
+	function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array())
2679
+	{
2680
+		$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2681
+		$this->appendDebug($this->varDump($digestRequest));
2682
+		$this->debug("certRequest=");
2683
+		$this->appendDebug($this->varDump($certRequest));
2684
+		// cf. RFC 2617
2685
+		if ($authtype == 'basic') {
2686
+			$this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2687
+		} elseif ($authtype == 'digest') {
2688
+			if (isset($digestRequest['nonce'])) {
2689
+				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2690
+
2691
+				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2692
+
2693
+				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2694
+				$A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2695
+
2696
+				// H(A1) = MD5(A1)
2697
+				$HA1 = md5($A1);
2698
+
2699
+				// A2 = Method ":" digest-uri-value
2700
+				$A2 = $this->request_method . ':' . $this->digest_uri;
2701
+
2702
+				// H(A2)
2703
+				$HA2 = md5($A2);
2704
+
2705
+				// KD(secret, data) = H(concat(secret, ":", data))
2706
+				// if qop == auth:
2707
+				// request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
2708
+				//                              ":" nc-value
2709
+				//                              ":" unq(cnonce-value)
2710
+				//                              ":" unq(qop-value)
2711
+				//                              ":" H(A2)
2712
+				//                            ) <">
2713
+				// if qop is missing,
2714
+				// request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2715
+
2716
+				$nonce = $digestRequest['nonce'];
2717
+				$cnonce = $nonce;
2718
+				if ($digestRequest['qop'] != '') {
2719
+					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2720
+				} else {
2721
+					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2722
+				}
2723
+
2724
+				$hashedDigest = md5($unhashedDigest);
2725
+
2726
+				$opaque = '';
2727
+				if (isset($digestRequest['opaque'])) {
2728
+					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2729
+				}
2730
+
2731
+				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
2732
+			}
2733
+		} elseif ($authtype == 'certificate') {
2734
+			$this->certRequest = $certRequest;
2735
+			$this->debug('Authorization header not set for certificate');
2736
+		} elseif ($authtype == 'ntlm') {
2737
+			// do nothing
2738
+			$this->debug('Authorization header not set for ntlm');
2739
+		}
2740
+		$this->username = $username;
2741
+		$this->password = $password;
2742
+		$this->authtype = $authtype;
2743
+		$this->digestRequest = $digestRequest;
2744
+	}
2745
+
2746
+	/**
2747
+	 * set the soapaction value
2748
+	 *
2749
+	 * @param    string $soapaction
2750
+	 * @access   public
2751
+	 */
2752
+	function setSOAPAction($soapaction)
2753
+	{
2754
+		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
2755
+	}
2756
+
2757
+	/**
2758
+	 * use http encoding
2759
+	 *
2760
+	 * @param    string $enc encoding style. supported values: gzip, deflate, or both
2761
+	 * @access   public
2762
+	 */
2763
+	function setEncoding($enc = 'gzip, deflate')
2764
+	{
2765
+		if (function_exists('gzdeflate')) {
2766
+			$this->protocol_version = '1.1';
2767
+			$this->setHeader('Accept-Encoding', $enc);
2768
+			if (!isset($this->outgoing_headers['Connection'])) {
2769
+				$this->setHeader('Connection', 'close');
2770
+				$this->persistentConnection = false;
2771
+			}
2772
+			// deprecated as of PHP 5.3.0
2773
+			//set_magic_quotes_runtime(0);
2774
+			$this->encoding = $enc;
2775
+		}
2776
+	}
2777
+
2778
+	/**
2779
+	 * set proxy info here
2780
+	 *
2781
+	 * @param    string $proxyhost use an empty string to remove proxy
2782
+	 * @param    string $proxyport
2783
+	 * @param    string $proxyusername
2784
+	 * @param    string $proxypassword
2785
+	 * @param    string $proxyauthtype (basic|ntlm)
2786
+	 * @access   public
2787
+	 */
2788
+	function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic')
2789
+	{
2790
+		if ($proxyhost) {
2791
+			$this->proxy = array(
2792
+				'host' => $proxyhost,
2793
+				'port' => $proxyport,
2794
+				'username' => $proxyusername,
2795
+				'password' => $proxypassword,
2796
+				'authtype' => $proxyauthtype
2797
+			);
2798
+			if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype == 'basic') {
2799
+				$this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2800
+			}
2801
+		} else {
2802
+			$this->debug('remove proxy');
2803
+			$this->unsetHeader('Proxy-Authorization');
2804
+		}
2805
+	}
2806
+
2807
+
2808
+	/**
2809
+	 * Test if the given string starts with a header that is to be skipped.
2810
+	 * Skippable headers result from chunked transfer and proxy requests.
2811
+	 *
2812
+	 * @param    string $data The string to check.
2813
+	 * @returns    boolean    Whether a skippable header was found.
2814
+	 * @access    private
2815
+	 */
2816
+	function isSkippableCurlHeader($data)
2817
+	{
2818
+		$skipHeaders = array('HTTP/1.1 100',
2819
+			'HTTP/1.0 301',
2820
+			'HTTP/1.1 301',
2821
+			'HTTP/1.0 302',
2822
+			'HTTP/1.1 302',
2823
+			'HTTP/1.0 401',
2824
+			'HTTP/1.1 401',
2825
+			'HTTP/1.0 200 Connection established',
2826
+			'HTTP/1.1 200 Connection established');
2827
+		foreach ($skipHeaders as $hd) {
2828
+			$prefix = substr($data, 0, strlen($hd));
2829
+			if ($prefix == $hd) {
2830
+				return true;
2831
+			}
2832
+		}
2833
+
2834
+		return false;
2835
+	}
2836
+
2837
+	/**
2838
+	 * decode a string that is encoded w/ "chunked' transfer encoding
2839
+	 * as defined in RFC2068 19.4.6
2840
+	 *
2841
+	 * @param    string $buffer
2842
+	 * @param    string $lb
2843
+	 * @returns    string
2844
+	 * @access   public
2845
+	 * @deprecated
2846
+	 */
2847
+	function decodeChunked($buffer, $lb)
2848
+	{
2849
+		$new = '';
2850
+
2851
+		// read chunk-size, chunk-extension (if any) and CRLF
2852
+		// get the position of the linebreak
2853
+		$chunkend = strpos($buffer, $lb);
2854
+		if (!$chunkend) {
2855
+			$this->debug('no linebreak found in decodeChunked');
2856
+			return $new;
2857
+		}
2858
+		$temp = substr($buffer, 0, $chunkend);
2859
+		$chunk_size = hexdec(trim($temp));
2860
+		$chunkstart = $chunkend + strlen($lb);
2861
+		// while (chunk-size > 0) {
2862
+		while ($chunk_size > 0) {
2863
+			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2864
+			$chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2865
+
2866
+			// Just in case we got a broken connection
2867
+			if (!$chunkend) {
2868
+				$chunk = substr($buffer, $chunkstart);
2869
+				// append chunk-data to entity-body
2870
+				$new .= $chunk;
2871
+				break;
2872
+			}
2873
+
2874
+			// read chunk-data and CRLF
2875
+			$chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2876
+			// append chunk-data to entity-body
2877
+			$new .= $chunk;
2878
+			// length := length + chunk-size
2879
+			// read chunk-size and CRLF
2880
+			$chunkstart = $chunkend + strlen($lb);
2881
+
2882
+			$chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2883
+			if (!$chunkend) {
2884
+				break; //Just in case we got a broken connection
2885
+			}
2886
+			$temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2887
+			$chunk_size = hexdec(trim($temp));
2888
+			$chunkstart = $chunkend;
2889
+		}
2890
+		return $new;
2891
+	}
2892
+
2893
+	/**
2894
+	 * Writes the payload, including HTTP headers, to $this->outgoing_payload.
2895
+	 *
2896
+	 * @param    string $data HTTP body
2897
+	 * @param    string $cookie_str data for HTTP Cookie header
2898
+	 * @return    void
2899
+	 * @access    private
2900
+	 */
2901
+	function buildPayload($data, $cookie_str = '')
2902
+	{
2903
+		// Note: for cURL connections, $this->outgoing_payload is ignored,
2904
+		// as is the Content-Length header, but these are still created as
2905
+		// debugging guides.
2906
+
2907
+		// add content-length header
2908
+		if ($this->request_method != 'GET') {
2909
+			$this->setHeader('Content-Length', strlen($data));
2910
+		}
2911
+
2912
+		// start building outgoing payload:
2913
+		if ($this->proxy) {
2914
+			$uri = $this->url;
2915
+		} else {
2916
+			$uri = $this->uri;
2917
+		}
2918
+		$req = "$this->request_method $uri HTTP/$this->protocol_version";
2919
+		$this->debug("HTTP request: $req");
2920
+		$this->outgoing_payload = "$req\r\n";
2921
+
2922
+		// loop thru headers, serializing
2923
+		foreach ($this->outgoing_headers as $k => $v) {
2924
+			$hdr = $k . ': ' . $v;
2925
+			$this->debug("HTTP header: $hdr");
2926
+			$this->outgoing_payload .= "$hdr\r\n";
2927
+		}
2928
+
2929
+		// add any cookies
2930
+		if ($cookie_str != '') {
2931
+			$hdr = 'Cookie: ' . $cookie_str;
2932
+			$this->debug("HTTP header: $hdr");
2933
+			$this->outgoing_payload .= "$hdr\r\n";
2934
+		}
2935
+
2936
+		// header/body separator
2937
+		$this->outgoing_payload .= "\r\n";
2938
+
2939
+		// add data
2940
+		$this->outgoing_payload .= $data;
2941
+	}
2942
+
2943
+	/**
2944
+	 * sends the SOAP request via HTTP[S]
2945
+	 *
2946
+	 * @param    string $data message data
2947
+	 * @param    array $cookies cookies to send
2948
+	 * @return    boolean    true if OK, false if problem
2949
+	 * @access   private
2950
+	 */
2951
+	function sendRequest($data, $cookies = null)
2952
+	{
2953
+		// build cookie string
2954
+		$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2955
+
2956
+		// build payload
2957
+		$this->buildPayload($data, $cookie_str);
2958
+
2959
+		if ($this->io_method() == 'socket') {
2960
+			// send payload
2961
+			if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2962
+				$this->setError('couldn\'t write message data to socket');
2963
+				$this->debug('couldn\'t write message data to socket');
2964
+				return false;
2965
+			}
2966
+			$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2967
+			return true;
2968
+		} elseif ($this->io_method() == 'curl') {
2969
+			// set payload
2970
+			// cURL does say this should only be the verb, and in fact it
2971
+			// turns out that the URI and HTTP version are appended to this, which
2972
+			// some servers refuse to work with (so we no longer use this method!)
2973
+			//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2974
+			$curl_headers = array();
2975
+			foreach ($this->outgoing_headers as $k => $v) {
2976
+				if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2977
+					$this->debug("Skip cURL header $k: $v");
2978
+				} else {
2979
+					$curl_headers[] = "$k: $v";
2980
+				}
2981
+			}
2982
+			if ($cookie_str != '') {
2983
+				$curl_headers[] = 'Cookie: ' . $cookie_str;
2984
+			}
2985
+			$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2986
+			$this->debug('set cURL HTTP headers');
2987
+			if ($this->request_method == "POST") {
2988
+				$this->setCurlOption(CURLOPT_POST, 1);
2989
+				$this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2990
+				$this->debug('set cURL POST data');
2991
+			}
2992
+			// insert custom user-set cURL options
2993
+			foreach ($this->ch_options as $key => $val) {
2994
+				$this->setCurlOption($key, $val);
2995
+			}
2996
+
2997
+			$this->debug('set cURL payload');
2998
+			return true;
2999
+		}
3000
+		return false;
3001
+	}
3002
+
3003
+	/**
3004
+	 * gets the SOAP response via HTTP[S]
3005
+	 *
3006
+	 * @return    string the response (also sets member variables like incoming_payload)
3007
+	 * @access   private
3008
+	 */
3009
+	function getResponse()
3010
+	{
3011
+		$this->incoming_payload = '';
3012
+		$header_array = array ();
3013
+		$data = '';
3014
+
3015
+		if ($this->io_method() == 'socket') {
3016
+			// loop until headers have been retrieved
3017
+			$pos = 0;
3018
+			while (!isset($lb)) {
3019
+				// We might EOF during header read.
3020
+				if (feof($this->fp)) {
3021
+					$this->incoming_payload = $data;
3022
+					$this->debug('found no headers before EOF after length ' . strlen($data));
3023
+					$this->debug("received before EOF:\n" . $data);
3024
+					$this->setError('server failed to send headers');
3025
+					return false;
3026
+				}
3027
+
3028
+				$tmp = fgets($this->fp, 256);
3029
+				$tmplen = strlen($tmp);
3030
+				$this->debug("read line of $tmplen bytes: " . trim($tmp));
3031
+
3032
+				if ($tmplen == 0) {
3033
+					$this->incoming_payload = $data;
3034
+					$this->debug('socket read of headers timed out after length ' . strlen($data));
3035
+					$this->debug("read before timeout: " . $data);
3036
+					$this->setError('socket read of headers timed out');
3037
+					return false;
3038
+				}
3039
+
3040
+				$data .= $tmp;
3041
+				$pos = strpos($data, "\r\n\r\n");
3042
+				if ($pos > 1) {
3043
+					$lb = "\r\n";
3044
+				} else {
3045
+					$pos = strpos($data, "\n\n");
3046
+					if ($pos > 1) {
3047
+						$lb = "\n";
3048
+					}
3049
+				}
3050
+				// remove 100 headers
3051
+				if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
3052
+					unset($lb);
3053
+					$data = '';
3054
+				}//
3055
+			}
3056
+			// store header data
3057
+			$this->incoming_payload .= $data;
3058
+			$this->debug('found end of headers after length ' . strlen($data));
3059
+			// process headers
3060
+			$header_data = trim(substr($data, 0, $pos));
3061
+			$header_array = explode($lb, $header_data);
3062
+			$this->incoming_headers = array();
3063
+			$this->incoming_cookies = array();
3064
+			foreach ($header_array as $header_line) {
3065
+				$arr = explode(':', $header_line, 2);
3066
+				if (count($arr) > 1) {
3067
+					$header_name = strtolower(trim($arr[0]));
3068
+					$this->incoming_headers[$header_name] = trim($arr[1]);
3069
+					if ($header_name == 'set-cookie') {
3070
+						// TODO: allow multiple cookies from parseCookie
3071
+						$cookie = $this->parseCookie(trim($arr[1]));
3072
+						if ($cookie) {
3073
+							$this->incoming_cookies[] = $cookie;
3074
+							$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3075
+						} else {
3076
+							$this->debug('did not find cookie in ' . trim($arr[1]));
3077
+						}
3078
+					}
3079
+				} elseif (isset($header_name)) {
3080
+					// append continuation line to previous header
3081
+					$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3082
+				}
3083
+			}
3084
+
3085
+			// loop until msg has been received
3086
+			if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3087
+				$content_length = 2147483647;    // ignore any content-length header
3088
+				$chunked = true;
3089
+				$this->debug("want to read chunked content");
3090
+			} elseif (isset($this->incoming_headers['content-length'])) {
3091
+				$content_length = $this->incoming_headers['content-length'];
3092
+				$chunked = false;
3093
+				$this->debug("want to read content of length $content_length");
3094
+			} else {
3095
+				$content_length = 2147483647;
3096
+				$chunked = false;
3097
+				$this->debug("want to read content to EOF");
3098
+			}
3099
+			$data = '';
3100
+			do {
3101
+				if ($chunked) {
3102
+					$tmp = fgets($this->fp, 256);
3103
+					$tmplen = strlen($tmp);
3104
+					$this->debug("read chunk line of $tmplen bytes");
3105
+					if ($tmplen == 0) {
3106
+						$this->incoming_payload = $data;
3107
+						$this->debug('socket read of chunk length timed out after length ' . strlen($data));
3108
+						$this->debug("read before timeout:\n" . $data);
3109
+						$this->setError('socket read of chunk length timed out');
3110
+						return false;
3111
+					}
3112
+					$content_length = hexdec(trim($tmp));
3113
+					$this->debug("chunk length $content_length");
3114
+				}
3115
+				$strlen = 0;
3116
+				while (($strlen < $content_length) && (!feof($this->fp))) {
3117
+					$readlen = min(8192, $content_length - $strlen);
3118
+					$tmp = fread($this->fp, $readlen);
3119
+					$tmplen = strlen($tmp);
3120
+					$this->debug("read buffer of $tmplen bytes");
3121
+					if (($tmplen == 0) && (!feof($this->fp))) {
3122
+						$this->incoming_payload = $data;
3123
+						$this->debug('socket read of body timed out after length ' . strlen($data));
3124
+						$this->debug("read before timeout:\n" . $data);
3125
+						$this->setError('socket read of body timed out');
3126
+						return false;
3127
+					}
3128
+					$strlen += $tmplen;
3129
+					$data .= $tmp;
3130
+				}
3131
+				if ($chunked && ($content_length > 0)) {
3132
+					$tmp = fgets($this->fp, 256);
3133
+					$tmplen = strlen($tmp);
3134
+					$this->debug("read chunk terminator of $tmplen bytes");
3135
+					if ($tmplen == 0) {
3136
+						$this->incoming_payload = $data;
3137
+						$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3138
+						$this->debug("read before timeout:\n" . $data);
3139
+						$this->setError('socket read of chunk terminator timed out');
3140
+						return false;
3141
+					}
3142
+				}
3143
+			} while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3144
+			if (feof($this->fp)) {
3145
+				$this->debug('read to EOF');
3146
+			}
3147
+			$this->debug('read body of length ' . strlen($data));
3148
+			$this->incoming_payload .= $data;
3149
+			$this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
3150
+
3151
+			// close filepointer
3152
+			if (
3153
+				(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
3154
+				(!$this->persistentConnection) || feof($this->fp)
3155
+			) {
3156
+				fclose($this->fp);
3157
+				$this->fp = false;
3158
+				$this->debug('closed socket');
3159
+			}
3160
+
3161
+			// connection was closed unexpectedly
3162
+			if ($this->incoming_payload == '') {
3163
+				$this->setError('no response from server');
3164
+				return false;
3165
+			}
3166
+
3167
+			// decode transfer-encoding
3168
+//		if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
3169
+//			if(!$data = $this->decodeChunked($data, $lb)){
3170
+//				$this->setError('Decoding of chunked data failed');
3171
+//				return false;
3172
+//			}
3173
+			//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
3174
+			// set decoded payload
3175
+//			$this->incoming_payload = $header_data.$lb.$lb.$data;
3176
+//		}
3177
+
3178
+		} elseif ($this->io_method() == 'curl') {
3179
+			// send and receive
3180
+			$this->debug('send and receive with cURL');
3181
+			$this->incoming_payload = curl_exec($this->ch);
3182
+			$data = $this->incoming_payload;
3183
+
3184
+			$cErr = curl_error($this->ch);
3185
+			if ($cErr != '') {
3186
+				$err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3187
+				// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
3188
+				foreach (curl_getinfo($this->ch) as $k => $v) {
3189
+					if (is_array($v)) {
3190
+						$this->debug("$k: " . json_encode($v));
3191
+					} else {
3192
+						$this->debug("$k: $v<br>");
3193
+					}
3194
+				}
3195
+				$this->debug($err);
3196
+				$this->setError($err);
3197
+				curl_close($this->ch);
3198
+				return false;
3199
+			}
3200
+			// close curl
3201
+			$this->debug('No cURL error, closing cURL');
3202
+			curl_close($this->ch);
3203
+
3204
+			// try removing skippable headers
3205
+			$savedata = $data;
3206
+			while ($this->isSkippableCurlHeader($data)) {
3207
+				$this->debug("Found HTTP header to skip");
3208
+				if ($pos = strpos($data, "\r\n\r\n")) {
3209
+					$data = ltrim(substr($data, $pos));
3210
+				} elseif ($pos = strpos($data, "\n\n")) {
3211
+					$data = ltrim(substr($data, $pos));
3212
+				}
3213
+			}
3214
+
3215
+			if ($data == '') {
3216
+				// have nothing left; just remove 100 header(s)
3217
+				$data = $savedata;
3218
+				while (preg_match('/^HTTP\/1.1 100/', $data)) {
3219
+					if ($pos = strpos($data, "\r\n\r\n")) {
3220
+						$data = ltrim(substr($data, $pos));
3221
+					} elseif ($pos = strpos($data, "\n\n")) {
3222
+						$data = ltrim(substr($data, $pos));
3223
+					}
3224
+				}
3225
+			}
3226
+
3227
+			// separate content from HTTP headers
3228
+			if ($pos = strpos($data, "\r\n\r\n")) {
3229
+				$lb = "\r\n";
3230
+			} elseif ($pos = strpos($data, "\n\n")) {
3231
+				$lb = "\n";
3232
+			} else {
3233
+				$this->debug('no proper separation of headers and document');
3234
+				$this->setError('no proper separation of headers and document');
3235
+				return false;
3236
+			}
3237
+			$header_data = trim(substr($data, 0, $pos));
3238
+			$header_array = explode($lb, $header_data);
3239
+			$data = ltrim(substr($data, $pos));
3240
+			$this->debug('found proper separation of headers and document');
3241
+			$this->debug('cleaned data, stringlen: ' . strlen($data));
3242
+			// clean headers
3243
+			foreach ($header_array as $header_line) {
3244
+				$arr = explode(':', $header_line, 2);
3245
+				if (count($arr) > 1) {
3246
+					$header_name = strtolower(trim($arr[0]));
3247
+					$this->incoming_headers[$header_name] = trim($arr[1]);
3248
+					if ($header_name == 'set-cookie') {
3249
+						// TODO: allow multiple cookies from parseCookie
3250
+						$cookie = $this->parseCookie(trim($arr[1]));
3251
+						if ($cookie) {
3252
+							$this->incoming_cookies[] = $cookie;
3253
+							$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3254
+						} else {
3255
+							$this->debug('did not find cookie in ' . trim($arr[1]));
3256
+						}
3257
+					}
3258
+				} elseif (isset($header_name)) {
3259
+					// append continuation line to previous header
3260
+					$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3261
+				}
3262
+			}
3263
+		}
3264
+
3265
+		$this->response_status_line = $header_array[0];
3266
+		$arr = explode(' ', $this->response_status_line, 3);
3267
+		$http_status = intval($arr[1]);
3268
+		$http_reason = count($arr) > 2 ? $arr[2] : '';
3269
+
3270
+		// see if we need to resend the request with http digest authentication
3271
+		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3272
+			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3273
+			$this->setURL($this->incoming_headers['location']);
3274
+			$this->tryagain = true;
3275
+			return false;
3276
+		}
3277
+
3278
+		// see if we need to resend the request with http digest authentication
3279
+		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3280
+			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
3281
+			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3282
+				$this->debug('Server wants digest authentication');
3283
+				// remove "Digest " from our elements
3284
+				$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3285
+
3286
+				// parse elements into array
3287
+				$digestElements = explode(',', $digestString);
3288
+				foreach ($digestElements as $val) {
3289
+					$tempElement = explode('=', trim($val), 2);
3290
+					$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
3291
+				}
3292
+
3293
+				// should have (at least) qop, realm, nonce
3294
+				if (isset($digestRequest['nonce'])) {
3295
+					$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
3296
+					$this->tryagain = true;
3297
+					return false;
3298
+				}
3299
+			}
3300
+			$this->debug('HTTP authentication failed');
3301
+			$this->setError('HTTP authentication failed');
3302
+			return false;
3303
+		}
3304
+
3305
+		if (
3306
+			($http_status >= 300 && $http_status <= 307) ||
3307
+			($http_status >= 400 && $http_status <= 417) ||
3308
+			($http_status >= 501 && $http_status <= 505)
3309
+		) {
3310
+			$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3311
+			return false;
3312
+		}
3313
+
3314
+		// decode content-encoding
3315
+		if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
3316
+			if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
3317
+				$header_data = "";
3318
+				// if decoding works, use it. else assume data wasn't gzencoded
3319
+				if (function_exists('gzinflate')) {
3320
+					//$timer->setMarker('starting decoding of gzip/deflated content');
3321
+					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
3322
+					// this means there are no Zlib headers, although there should be
3323
+					$this->debug('The gzinflate function exists');
3324
+					$datalen = strlen($data);
3325
+					if ($this->incoming_headers['content-encoding'] == 'deflate') {
3326
+						if ($degzdata = @gzinflate($data)) {
3327
+							$data = $degzdata;
3328
+							$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3329
+							if (strlen($data) < $datalen) {
3330
+								// test for the case that the payload has been compressed twice
3331
+								$this->debug('The inflated payload is smaller than the gzipped one; try again');
3332
+								if ($degzdata = @gzinflate($data)) {
3333
+									$data = $degzdata;
3334
+									$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3335
+								}
3336
+							}
3337
+						} else {
3338
+							$this->debug('Error using gzinflate to inflate the payload');
3339
+							$this->setError('Error using gzinflate to inflate the payload');
3340
+						}
3341
+					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3342
+						if ($degzdata = @gzinflate(substr($data, 10))) {    // do our best
3343
+							$data = $degzdata;
3344
+							$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3345
+							if (strlen($data) < $datalen) {
3346
+								// test for the case that the payload has been compressed twice
3347
+								$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3348
+								if ($degzdata = @gzinflate(substr($data, 10))) {
3349
+									$data = $degzdata;
3350
+									$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3351
+								}
3352
+							}
3353
+						} else {
3354
+							$this->debug('Error using gzinflate to un-gzip the payload');
3355
+							$this->setError('Error using gzinflate to un-gzip the payload');
3356
+						}
3357
+					}
3358
+					//$timer->setMarker('finished decoding of gzip/deflated content');
3359
+					//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3360
+					// set decoded payload
3361
+					$this->incoming_payload = $header_data . (isset ($lb) ? $lb : "") . (isset ($lb) ? $lb : "") . $data;
3362
+				} else {
3363
+					$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3364
+					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3365
+				}
3366
+			} else {
3367
+				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3368
+				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3369
+			}
3370
+		} else {
3371
+			$this->debug('No Content-Encoding header');
3372
+		}
3373
+
3374
+		if (strlen($data) == 0) {
3375
+			$this->debug('no data after headers!');
3376
+			$this->setError('no data present after HTTP headers');
3377
+			return false;
3378
+		}
3379
+
3380
+		return $data;
3381
+	}
3382
+
3383
+	/**
3384
+	 * sets the content-type for the SOAP message to be sent
3385
+	 *
3386
+	 * @param    string $type the content type, MIME style
3387
+	 * @param    mixed $charset character set used for encoding (or false)
3388
+	 * @access    public
3389
+	 */
3390
+	function setContentType($type, $charset = false)
3391
+	{
3392
+		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3393
+	}
3394
+
3395
+	/**
3396
+	 * specifies that an HTTP persistent connection should be used
3397
+	 *
3398
+	 * @return    boolean whether the request was honored by this method.
3399
+	 * @access    public
3400
+	 */
3401
+	function usePersistentConnection()
3402
+	{
3403
+		if (isset($this->outgoing_headers['Accept-Encoding'])) {
3404
+			return false;
3405
+		}
3406
+		$this->protocol_version = '1.1';
3407
+		$this->persistentConnection = true;
3408
+		$this->setHeader('Connection', 'Keep-Alive');
3409
+		return true;
3410
+	}
3411
+
3412
+	/**
3413
+	 * parse an incoming Cookie into it's parts
3414
+	 *
3415
+	 * @param    string $cookie_str content of cookie
3416
+	 * @return    array with data of that cookie
3417
+	 * @access    private
3418
+	 */
3419
+	/*
3420
+	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
3421
+	 */
3422
+	function parseCookie($cookie_str)
3423
+	{
3424
+		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3425
+		$data = explode (';', $cookie_str);
3426
+		$value_str = $data[0];
3427
+
3428
+		$cookie_param = 'domain=';
3429
+		$start = strpos($cookie_str, $cookie_param);
3430
+		if ($start > 0) {
3431
+			$domain = substr($cookie_str, $start + strlen($cookie_param));
3432
+			$domain = substr($domain, 0, strpos($domain, ';'));
3433
+		} else {
3434
+			$domain = '';
3435
+		}
3436
+
3437
+		$cookie_param = 'expires=';
3438
+		$start = strpos($cookie_str, $cookie_param);
3439
+		if ($start > 0) {
3440
+			$expires = substr($cookie_str, $start + strlen($cookie_param));
3441
+			$expires = substr($expires, 0, strpos($expires, ';'));
3442
+		} else {
3443
+			$expires = '';
3444
+		}
3445
+
3446
+		$cookie_param = 'path=';
3447
+		$start = strpos($cookie_str, $cookie_param);
3448
+		if ($start > 0) {
3449
+			$path = substr($cookie_str, $start + strlen($cookie_param));
3450
+			$path = substr($path, 0, strpos($path, ';'));
3451
+		} else {
3452
+			$path = '/';
3453
+		}
3454
+
3455
+		$cookie_param = ';secure;';
3456
+		if (strpos($cookie_str, $cookie_param) !== false) {
3457
+			$secure = true;
3458
+		} else {
3459
+			$secure = false;
3460
+		}
3461
+
3462
+		$sep_pos = strpos($value_str, '=');
3463
+
3464
+		if ($sep_pos) {
3465
+			$name = substr($value_str, 0, $sep_pos);
3466
+			$value = substr($value_str, $sep_pos + 1);
3467
+
3468
+		  return array('name' => $name,
3469
+					 'value' => $value,
3470
+					 'domain' => $domain,
3471
+					 'path' => $path,
3472
+					 'expires' => $expires,
3473
+					 'secure' => $secure
3474
+		  );
3475
+		}
3476
+		return array ();
3477
+	}
3478
+
3479
+	/**
3480
+	 * sort out cookies for the current request
3481
+	 *
3482
+	 * @param    array $cookies array with all cookies
3483
+	 * @param    boolean $secure is the send-content secure or not?
3484
+	 * @return    string for Cookie-HTTP-Header
3485
+	 * @access    private
3486
+	 */
3487
+	function getCookiesForRequest($cookies, $secure = false)
3488
+	{
3489
+		$cookie_str = '';
3490
+		if ((is_array($cookies))) {
3491
+			foreach ($cookies as $cookie) {
3492
+				if (!is_array($cookie)) {
3493
+					continue;
3494
+				}
3495
+				$this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3496
+				if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
3497
+					if (strtotime($cookie['expires']) <= time()) {
3498
+						$this->debug('cookie has expired');
3499
+						continue;
3500
+					}
3501
+				}
3502
+				if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) {
3503
+					$domain = preg_quote($cookie['domain'], "'");
3504
+					if (!preg_match("'.*$domain$'i", $this->host)) {
3505
+						$this->debug('cookie has different domain');
3506
+						continue;
3507
+					}
3508
+				}
3509
+				if ((isset($cookie['path'])) && (!empty($cookie['path']))) {
3510
+					$path = preg_quote($cookie['path'], "'");
3511
+					if (!preg_match("'^$path.*'i", $this->path)) {
3512
+						$this->debug('cookie is for a different path');
3513
+						continue;
3514
+					}
3515
+				}
3516
+				if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3517
+					$this->debug('cookie is secure, transport is not');
3518
+					continue;
3519
+				}
3520
+				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3521
+				$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3522
+			}
3523
+		}
3524
+		return $cookie_str;
3525
+	}
3526
+}
3527
+
3528
+
3529
+/**
3530
+ *
3531
+ * nusoap_server allows the user to create a SOAP server
3532
+ * that is capable of receiving messages and returning responses
3533
+ *
3534
+ * @author   Dietrich Ayala <[email protected]>
3535
+ * @author   Scott Nichol <[email protected]>
3536
+ * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
3537
+ * @access   public
3538
+ */
3539
+class nusoap_server extends nusoap_base
3540
+{
3541
+	/**
3542
+	 * HTTP headers of request
3543
+	 *
3544
+	 * @var array
3545
+	 * @access private
3546
+	 */
3547
+	var $headers = array();
3548
+	/**
3549
+	 * HTTP request
3550
+	 *
3551
+	 * @var string
3552
+	 * @access private
3553
+	 */
3554
+	var $request = '';
3555
+	/**
3556
+	 * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text)
3557
+	 *
3558
+	 * @var string
3559
+	 * @access public
3560
+	 */
3561
+	var $requestHeaders = '';
3562
+	/**
3563
+	 * SOAP Headers from request (parsed)
3564
+	 *
3565
+	 * @var mixed
3566
+	 * @access public
3567
+	 */
3568
+	var $requestHeader = null;
3569
+	/**
3570
+	 * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text)
3571
+	 *
3572
+	 * @var string
3573
+	 * @access public
3574
+	 */
3575
+	var $document = '';
3576
+	/**
3577
+	 * SOAP payload for request (text)
3578
+	 *
3579
+	 * @var string
3580
+	 * @access public
3581
+	 */
3582
+	var $requestSOAP = '';
3583
+	/**
3584
+	 * requested method namespace URI
3585
+	 *
3586
+	 * @var string
3587
+	 * @access private
3588
+	 */
3589
+	var $methodURI = '';
3590
+	/**
3591
+	 * name of method requested
3592
+	 *
3593
+	 * @var string
3594
+	 * @access private
3595
+	 */
3596
+	var $methodname = '';
3597
+	/**
3598
+	 * name of the response tag name
3599
+	 *
3600
+	 * @var string
3601
+	 * @access private
3602
+	 */
3603
+	var $responseTagName = '';
3604
+	/**
3605
+	 * method parameters from request
3606
+	 *
3607
+	 * @var array
3608
+	 * @access private
3609
+	 */
3610
+	var $methodparams = array();
3611
+	/**
3612
+	 * SOAP Action from request
3613
+	 *
3614
+	 * @var string
3615
+	 * @access private
3616
+	 */
3617
+	var $SOAPAction = '';
3618
+	/**
3619
+	 * character set encoding of incoming (request) messages
3620
+	 *
3621
+	 * @var string
3622
+	 * @access public
3623
+	 */
3624
+	var $xml_encoding = '';
3625
+	/**
3626
+	 * toggles whether the parser decodes element content w/ utf8_decode()
3627
+	 *
3628
+	 * @var boolean
3629
+	 * @access public
3630
+	 */
3631
+	var $decode_utf8 = true;
3632
+
3633
+	/**
3634
+	 * HTTP headers of response
3635
+	 *
3636
+	 * @var array
3637
+	 * @access public
3638
+	 */
3639
+	var $outgoing_headers = array();
3640
+	/**
3641
+	 * HTTP response
3642
+	 *
3643
+	 * @var string
3644
+	 * @access private
3645
+	 */
3646
+	var $response = '';
3647
+	/**
3648
+	 * SOAP headers for response (text or array of soapval or associative array)
3649
+	 *
3650
+	 * @var mixed
3651
+	 * @access public
3652
+	 */
3653
+	var $responseHeaders = '';
3654
+	/**
3655
+	 * SOAP payload for response (text)
3656
+	 *
3657
+	 * @var string
3658
+	 * @access private
3659
+	 */
3660
+	var $responseSOAP = '';
3661
+	/**
3662
+	 * SOAP attachments in response
3663
+	 *
3664
+	 * @var string
3665
+	 * @access private
3666
+	 */
3667
+	var $attachments= '';
3668
+	/**
3669
+	 * method return value to place in response
3670
+	 *
3671
+	 * @var mixed
3672
+	 * @access private
3673
+	 */
3674
+	var $methodreturn = false;
3675
+	/**
3676
+	 * whether $methodreturn is a string of literal XML
3677
+	 *
3678
+	 * @var boolean
3679
+	 * @access public
3680
+	 */
3681
+	var $methodreturnisliteralxml = false;
3682
+	/**
3683
+	 * SOAP fault for response (or false)
3684
+	 *
3685
+	 * @var mixed
3686
+	 * @access private
3687
+	 */
3688
+	var $fault = false;
3689
+	/**
3690
+	 * text indication of result (for debugging)
3691
+	 *
3692
+	 * @var string
3693
+	 * @access private
3694
+	 */
3695
+	var $result = 'successful';
3696
+
3697
+	/**
3698
+	 * assoc array of operations => opData; operations are added by the register()
3699
+	 * method or by parsing an external WSDL definition
3700
+	 *
3701
+	 * @var array
3702
+	 * @access private
3703
+	 */
3704
+	var $operations = array();
3705
+	/**
3706
+	 * wsdl instance (if one)
3707
+	 *
3708
+	 * @var mixed
3709
+	 * @access private
3710
+	 */
3711
+	var $wsdl = false;
3712
+	/**
3713
+	 * URL for WSDL (if one)
3714
+	 *
3715
+	 * @var mixed
3716
+	 * @access private
3717
+	 */
3718
+	var $externalWSDLURL = false;
3719
+	/**
3720
+	 * whether to append debug to response as XML comment
3721
+	 *
3722
+	 * @var boolean
3723
+	 * @access public
3724
+	 */
3725
+	var $debug_flag = false;
3726
+
3727
+	/** @var array */
3728
+	var $opData;
3729
+
3730
+
3731
+	/**
3732
+	 * constructor
3733
+	 * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to.
3734
+	 *
3735
+	 * @param mixed $wsdl file path or URL (string), or wsdl instance (object)
3736
+	 * @access   public
3737
+	 */
3738
+	function __construct($wsdl = false)
3739
+	{
3740
+		parent::__construct();
3741
+		// turn on debugging?
3742
+		global $debug;
3743
+		global $HTTP_SERVER_VARS;
3744
+
3745
+		if (isset($_SERVER)) {
3746
+			$this->debug("_SERVER is defined:");
3747
+			$this->appendDebug($this->varDump($_SERVER));
3748
+		} elseif (isset($HTTP_SERVER_VARS)) {
3749
+			$this->debug("HTTP_SERVER_VARS is defined:");
3750
+			$this->appendDebug($this->varDump($HTTP_SERVER_VARS));
3751
+		} else {
3752
+			$this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
3753
+		}
3754
+
3755
+		if (isset($debug)) {
3756
+			$this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
3757
+			$this->debug_flag = $debug;
3758
+		} elseif (isset($_SERVER['QUERY_STRING'])) {
3759
+			$qs = explode('&', $_SERVER['QUERY_STRING']);
3760
+			foreach ($qs as $v) {
3761
+				if (substr($v, 0, 6) == 'debug=') {
3762
+					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
3763
+					$this->debug_flag = substr($v, 6);
3764
+				}
3765
+			}
3766
+		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3767
+			$qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
3768
+			foreach ($qs as $v) {
3769
+				if (substr($v, 0, 6) == 'debug=') {
3770
+					$this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
3771
+					$this->debug_flag = substr($v, 6);
3772
+				}
3773
+			}
3774
+		}
3775
+
3776
+		// wsdl
3777
+		if ($wsdl) {
3778
+			$this->debug("In nusoap_server, WSDL is specified");
3779
+			if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
3780
+				$this->wsdl = $wsdl;
3781
+				$this->externalWSDLURL = $this->wsdl->wsdl;
3782
+				$this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
3783
+			} else {
3784
+				$this->debug('Create wsdl from ' . $wsdl);
3785
+				$this->wsdl = new wsdl($wsdl);
3786
+				$this->externalWSDLURL = $wsdl;
3787
+			}
3788
+			$this->appendDebug($this->wsdl->getDebug());
3789
+			$this->wsdl->clearDebug();
3790
+			if ($err = $this->wsdl->getError()) {
3791
+				die('WSDL ERROR: ' . $err);
3792
+			}
3793
+		}
3794
+	}
3795
+
3796
+	/**
3797
+	 * processes request and returns response
3798
+	 *
3799
+	 * @param    string $data usually is the value of $HTTP_RAW_POST_DATA
3800
+	 * @access   public
3801
+	 */
3802
+	function service($data)
3803
+	{
3804
+		global $HTTP_SERVER_VARS;
3805
+
3806
+		if (isset($_SERVER['REQUEST_METHOD'])) {
3807
+			$rm = $_SERVER['REQUEST_METHOD'];
3808
+		} elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
3809
+			$rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
3810
+		} else {
3811
+			$rm = '';
3812
+		}
3813
+
3814
+		if (isset($_SERVER['QUERY_STRING'])) {
3815
+			$qs = $_SERVER['QUERY_STRING'];
3816
+		} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
3817
+			$qs = $HTTP_SERVER_VARS['QUERY_STRING'];
3818
+		} else {
3819
+			$qs = '';
3820
+		}
3821
+		$this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
3822
+
3823
+		if ($rm == 'POST') {
3824
+			$this->debug("In service, invoke the request");
3825
+			$this->parse_request($data);
3826
+			if (!$this->fault) {
3827
+				$this->invoke_method();
3828
+			}
3829
+			if (!$this->fault) {
3830
+				$this->serialize_return();
3831
+			}
3832
+			$this->send_response();
3833
+		} elseif (preg_match('/wsdl/', $qs)) {
3834
+			$this->debug("In service, this is a request for WSDL");
3835
+			if ($this->externalWSDLURL) {
3836
+				if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
3837
+					$this->debug("In service, re-direct for WSDL");
3838
+					header('Location: ' . $this->externalWSDLURL);
3839
+				} else { // assume file
3840
+					$this->debug("In service, use file passthru for WSDL");
3841
+					header("Content-Type: text/xml\r\n");
3842
+					$fp = fopen($this->externalWSDLURL, 'r');
3843
+					fpassthru($fp);
3844
+				}
3845
+			} elseif ($this->wsdl) {
3846
+				$this->debug("In service, serialize WSDL");
3847
+				header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
3848
+				print $this->wsdl->serialize($this->debug_flag);
3849
+				if ($this->debug_flag) {
3850
+					$this->debug('wsdl:');
3851
+					$this->appendDebug($this->varDump($this->wsdl));
3852
+					print $this->getDebugAsXMLComment();
3853
+				}
3854
+			} else {
3855
+				$this->debug("In service, there is no WSDL");
3856
+				header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3857
+				print "This service does not provide WSDL";
3858
+			}
3859
+		} elseif ($this->wsdl) {
3860
+			$this->debug("In service, return Web description");
3861
+			print $this->wsdl->webDescription();
3862
+		} else {
3863
+			$this->debug("In service, no Web description");
3864
+			header("Content-Type: text/html; charset=ISO-8859-1\r\n");
3865
+			print "This service does not provide a Web description";
3866
+		}
3867
+	}
3868
+
3869
+	/**
3870
+	 * parses HTTP request headers.
3871
+	 *
3872
+	 * The following fields are set by this function (when successful)
3873
+	 *
3874
+	 * headers
3875
+	 * request
3876
+	 * xml_encoding
3877
+	 * SOAPAction
3878
+	 *
3879
+	 * @access   private
3880
+	 */
3881
+	function parse_http_headers()
3882
+	{
3883
+		global $HTTP_SERVER_VARS;
3884
+
3885
+		$this->request = '';
3886
+		$this->SOAPAction = '';
3887
+		if (function_exists('getallheaders')) {
3888
+			$this->debug("In parse_http_headers, use getallheaders");
3889
+			$headers = getallheaders();
3890
+			foreach ($headers as $k => $v) {
3891
+				$k = strtolower($k);
3892
+				$this->headers[$k] = $v;
3893
+				$this->request .= "$k: $v\r\n";
3894
+				$this->debug("$k: $v");
3895
+			}
3896
+			// get SOAPAction header
3897
+			if (isset($this->headers['soapaction'])) {
3898
+				$this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
3899
+			}
3900
+			// get the character encoding of the incoming request
3901
+			if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
3902
+				$enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
3903
+				if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3904
+					$this->xml_encoding = strtoupper($enc);
3905
+				} else {
3906
+					$this->xml_encoding = 'US-ASCII';
3907
+				}
3908
+			} else {
3909
+				// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3910
+				$this->xml_encoding = 'ISO-8859-1';
3911
+			}
3912
+		} elseif (isset($_SERVER) && is_array($_SERVER)) {
3913
+			$this->debug("In parse_http_headers, use _SERVER");
3914
+			foreach ($_SERVER as $k => $v) {
3915
+				if (substr($k, 0, 5) == 'HTTP_') {
3916
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3917
+				} else {
3918
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3919
+				}
3920
+				if ($k == 'soapaction') {
3921
+					// get SOAPAction header
3922
+					$k = 'SOAPAction';
3923
+					$v = str_replace('"', '', $v);
3924
+					$v = str_replace('\\', '', $v);
3925
+					$this->SOAPAction = $v;
3926
+				} elseif ($k == 'content-type') {
3927
+					// get the character encoding of the incoming request
3928
+					if (strpos($v, '=')) {
3929
+						$enc = substr(strstr($v, '='), 1);
3930
+						$enc = str_replace('"', '', $enc);
3931
+						$enc = str_replace('\\', '', $enc);
3932
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3933
+							$this->xml_encoding = strtoupper($enc);
3934
+						} else {
3935
+							$this->xml_encoding = 'US-ASCII';
3936
+						}
3937
+					} else {
3938
+						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3939
+						$this->xml_encoding = 'ISO-8859-1';
3940
+					}
3941
+				}
3942
+				$this->headers[$k] = $v;
3943
+				if (is_array($v)) {
3944
+					$this->request .= "$k: " . json_encode($v) . "\r\n";
3945
+					$this->debug("$k: " . json_encode($v));
3946
+				} else {
3947
+					$this->request .= "$k: $v\r\n";
3948
+					$this->debug("$k: $v");
3949
+				}
3950
+			}
3951
+		} elseif (is_array($HTTP_SERVER_VARS)) {
3952
+			$this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
3953
+			foreach ($HTTP_SERVER_VARS as $k => $v) {
3954
+				if (substr($k, 0, 5) == 'HTTP_') {
3955
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
3956
+					$k = strtolower(substr($k, 5));
3957
+				} else {
3958
+					$k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
3959
+					$k = strtolower($k);
3960
+				}
3961
+				if ($k == 'soapaction') {
3962
+					// get SOAPAction header
3963
+					$k = 'SOAPAction';
3964
+					$v = str_replace('"', '', $v);
3965
+					$v = str_replace('\\', '', $v);
3966
+					$this->SOAPAction = $v;
3967
+				} elseif ($k == 'content-type') {
3968
+					// get the character encoding of the incoming request
3969
+					if (strpos($v, '=')) {
3970
+						$enc = substr(strstr($v, '='), 1);
3971
+						$enc = str_replace('"', '', $enc);
3972
+						$enc = str_replace('\\', '', $enc);
3973
+						if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
3974
+							$this->xml_encoding = strtoupper($enc);
3975
+						} else {
3976
+							$this->xml_encoding = 'US-ASCII';
3977
+						}
3978
+					} else {
3979
+						// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
3980
+						$this->xml_encoding = 'ISO-8859-1';
3981
+					}
3982
+				}
3983
+				$this->headers[$k] = $v;
3984
+				$this->request .= "$k: $v\r\n";
3985
+				$this->debug("$k: $v");
3986
+			}
3987
+		} else {
3988
+			$this->debug("In parse_http_headers, HTTP headers not accessible");
3989
+			$this->setError("HTTP headers not accessible");
3990
+		}
3991
+	}
3992
+
3993
+	/**
3994
+	 * parses a request
3995
+	 *
3996
+	 * The following fields are set by this function (when successful)
3997
+	 *
3998
+	 * headers
3999
+	 * request
4000
+	 * xml_encoding
4001
+	 * SOAPAction
4002
+	 * request
4003
+	 * requestSOAP
4004
+	 * methodURI
4005
+	 * methodname
4006
+	 * methodparams
4007
+	 * requestHeaders
4008
+	 * document
4009
+	 *
4010
+	 * This sets the fault field on error
4011
+	 *
4012
+	 * @param    string $data XML string
4013
+	 * @access   private
4014
+	 */
4015
+	function parse_request($data = '')
4016
+	{
4017
+		$this->debug('entering parse_request()');
4018
+		$this->parse_http_headers();
4019
+		$this->debug('got character encoding: ' . $this->xml_encoding);
4020
+		// uncompress if necessary
4021
+		if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
4022
+			$this->debug('got content encoding: ' . $this->headers['content-encoding']);
4023
+			if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
4024
+				// if decoding works, use it. else assume data wasn't gzencoded
4025
+				if (function_exists('gzuncompress')) {
4026
+					if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
4027
+						$data = $degzdata;
4028
+					} elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
4029
+						$data = $degzdata;
4030
+					} else {
4031
+						$this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
4032
+						return;
4033
+					}
4034
+				} else {
4035
+					$this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
4036
+					return;
4037
+				}
4038
+			}
4039
+		}
4040
+		$this->request .= "\r\n" . $data;
4041
+		$data = $this->parseRequest($this->headers, $data);
4042
+		$this->requestSOAP = $data;
4043
+		$this->debug('leaving parse_request');
4044
+	}
4045
+
4046
+	/**
4047
+	 * invokes a PHP function for the requested SOAP method
4048
+	 *
4049
+	 * The following fields are set by this function (when successful)
4050
+	 *
4051
+	 * methodreturn
4052
+	 *
4053
+	 * Note that the PHP function that is called may also set the following
4054
+	 * fields to affect the response sent to the client
4055
+	 *
4056
+	 * responseHeaders
4057
+	 * outgoing_headers
4058
+	 *
4059
+	 * This sets the fault field on error
4060
+	 *
4061
+	 * @access   private
4062
+	 */
4063
+	function invoke_method()
4064
+	{
4065
+		$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
4066
+
4067
+		//
4068
+		// if you are debugging in this area of the code, your service uses a class to implement methods,
4069
+		// you use SOAP RPC, and the client is .NET, please be aware of the following...
4070
+		// when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
4071
+		// method name.  that is fine for naming the .NET methods.  it is not fine for properly constructing
4072
+		// the XML request and reading the XML response.  you need to add the RequestElementName and
4073
+		// ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
4074
+		// generates for the method.  these parameters are used to specify the correct XML element names
4075
+		// for .NET to use, i.e. the names with the '.' in them.
4076
+		//
4077
+		$orig_methodname = $this->methodname;
4078
+		if ($this->wsdl) {
4079
+			if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
4080
+				$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
4081
+				$this->appendDebug('opData=' . $this->varDump($this->opData));
4082
+			} elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
4083
+				// Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
4084
+				$this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
4085
+				$this->appendDebug('opData=' . $this->varDump($this->opData));
4086
+				$this->methodname = $this->opData['name'];
4087
+			} else {
4088
+				$this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
4089
+				$this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
4090
+				return;
4091
+			}
4092
+		} else {
4093
+			$this->debug('in invoke_method, no WSDL to validate method');
4094
+		}
4095
+
4096
+		// if a . is present in $this->methodname, we see if there is a class in scope,
4097
+		// which could be referred to. We will also distinguish between two deliminators,
4098
+		// to allow methods to be called a the class or an instance
4099
+		if (strpos($this->methodname, '..') > 0) {
4100
+			$delim = '..';
4101
+		} elseif (strpos($this->methodname, '.') > 0) {
4102
+			$delim = '.';
4103
+		} else {
4104
+			$delim = '';
4105
+		}
4106
+		$this->debug("in invoke_method, delim=$delim");
4107
+
4108
+		$class = '';
4109
+		$method = '';
4110
+		$try_class = '';
4111
+		if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
4112
+			$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
4113
+			if (class_exists($try_class)) {
4114
+				// get the class and method name
4115
+				$class = $try_class;
4116
+				$method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
4117
+				$this->debug("in invoke_method, class=$class method=$method delim=$delim");
4118
+			} else {
4119
+				$this->debug("in invoke_method, class=$try_class not found");
4120
+			}
4121
+		} elseif (strlen($delim) > 0 && substr_count($this->methodname, $delim) > 1) {
4122
+			$split = explode($delim, $this->methodname);
4123
+			$method = array_pop($split);
4124
+			$class = implode('\\', $split);
4125
+		} else {
4126
+			$this->debug("in invoke_method, no class to try");
4127
+		}
4128
+
4129
+		// does method exist?
4130
+		if ($class == '') {
4131
+			if (!function_exists($this->methodname)) {
4132
+				$this->debug("in invoke_method, function '$this->methodname' not found!");
4133
+				$this->result = 'fault: method not found';
4134
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
4135
+				return;
4136
+			}
4137
+		} else {
4138
+			$method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method;
4139
+			if (!in_array($method_to_compare, get_class_methods($class))) {
4140
+				$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
4141
+				$this->result = 'fault: method not found';
4142
+				$this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
4143
+				return;
4144
+			}
4145
+		}
4146
+
4147
+		// evaluate message, getting back parameters
4148
+		// verify that request parameters match the method's signature
4149
+		if (!$this->verify_method($this->methodname, $this->methodparams)) {
4150
+			// debug
4151
+			$this->debug('ERROR: request not verified against method signature');
4152
+			$this->result = 'fault: request failed validation against method signature';
4153
+			// return fault
4154
+			$this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service.");
4155
+			return;
4156
+		}
4157
+
4158
+		// if there are parameters to pass
4159
+		$this->debug('in invoke_method, params:');
4160
+		$this->appendDebug($this->varDump($this->methodparams));
4161
+		$this->debug("in invoke_method, calling '$this->methodname'");
4162
+		if (!function_exists('call_user_func_array')) {
4163
+			if ($class == '') {
4164
+				$this->debug('in invoke_method, calling function using eval()');
4165
+				$funcCall = "\$this->methodreturn = $this->methodname(";
4166
+			} else {
4167
+				if ($delim == '..') {
4168
+					$this->debug('in invoke_method, calling class method using eval()');
4169
+					$funcCall = "\$this->methodreturn = " . $class . "::" . $method . "(";
4170
+				} else {
4171
+					$this->debug('in invoke_method, calling instance method using eval()');
4172
+					// generate unique instance name
4173
+					$instname = "\$inst_" . time();
4174
+					$funcCall = $instname . " = new " . $class . "(); ";
4175
+					$funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "(";
4176
+				}
4177
+			}
4178
+			if ($this->methodparams) {
4179
+				foreach ($this->methodparams as $param) {
4180
+					if (is_array($param) || is_object($param)) {
4181
+						$this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
4182
+						return;
4183
+					}
4184
+					$funcCall .= "\"$param\",";
4185
+				}
4186
+				$funcCall = substr($funcCall, 0, -1);
4187
+			}
4188
+			$funcCall .= ');';
4189
+			$this->debug('in invoke_method, function call: ' . $funcCall);
4190
+			@eval($funcCall);
4191
+		} else {
4192
+			if ($class == '') {
4193
+				$this->debug('in invoke_method, calling function using call_user_func_array()');
4194
+				$call_arg = "$this->methodname";    // straight assignment changes $this->methodname to lower case after call_user_func_array()
4195
+			} elseif ($delim == '..') {
4196
+				$this->debug('in invoke_method, calling class method using call_user_func_array()');
4197
+				$call_arg = array($class, $method);
4198
+			} else {
4199
+				$this->debug('in invoke_method, calling instance method using call_user_func_array()');
4200
+				$instance = new $class ();
4201
+				$call_arg = array(&$instance, $method);
4202
+			}
4203
+			if (is_array($this->methodparams)) {
4204
+				$this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams));
4205
+			} else {
4206
+				$this->methodreturn = call_user_func_array($call_arg, array());
4207
+			}
4208
+		}
4209
+		$this->debug('in invoke_method, methodreturn:');
4210
+		$this->appendDebug($this->varDump($this->methodreturn));
4211
+		$this->debug("in invoke_method, called method $this->methodname, received data of type " . gettype($this->methodreturn));
4212
+	}
4213
+
4214
+	/**
4215
+	 * serializes the return value from a PHP function into a full SOAP Envelope
4216
+	 *
4217
+	 * The following fields are set by this function (when successful)
4218
+	 *
4219
+	 * responseSOAP
4220
+	 *
4221
+	 * This sets the fault field on error
4222
+	 *
4223
+	 * @access   private
4224
+	 */
4225
+	function serialize_return()
4226
+	{
4227
+		$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4228
+		// if fault
4229
+		if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
4230
+			$this->debug('got a fault object from method');
4231
+			$this->fault = $this->methodreturn;
4232
+			return;
4233
+		} elseif ($this->methodreturnisliteralxml) {
4234
+			$return_val = $this->methodreturn;
4235
+			// returned value(s)
4236
+		} else {
4237
+			$this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method');
4238
+			$this->debug('serializing return value');
4239
+			if ($this->wsdl) {
4240
+				if (sizeof($this->opData['output']['parts']) > 1) {
4241
+					$this->debug('more than one output part, so use the method return unchanged');
4242
+					$opParams = $this->methodreturn;
4243
+				} elseif (sizeof($this->opData['output']['parts']) == 1) {
4244
+					$this->debug('exactly one output part, so wrap the method return in a simple array');
4245
+					// TODO: verify that it is not already wrapped!
4246
+					//foreach ($this->opData['output']['parts'] as $name => $type) {
4247
+					//	$this->debug('wrap in element named ' . $name);
4248
+					//}
4249
+					$opParams = array($this->methodreturn);
4250
+				}
4251
+				$opParams = isset($opParams) ? $opParams : [];
4252
+				$return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams);
4253
+				$this->appendDebug($this->wsdl->getDebug());
4254
+				$this->wsdl->clearDebug();
4255
+				if ($errstr = $this->wsdl->getError()) {
4256
+					$this->debug('got wsdl error: ' . $errstr);
4257
+					$this->fault('SOAP-ENV:Server', 'unable to serialize result');
4258
+					return;
4259
+				}
4260
+			} else {
4261
+				if (isset($this->methodreturn)) {
4262
+					$return_val = $this->serialize_val($this->methodreturn, 'return');
4263
+				} else {
4264
+					$return_val = '';
4265
+					$this->debug('in absence of WSDL, assume void return for backward compatibility');
4266
+				}
4267
+			}
4268
+		}
4269
+		$this->debug('return value:');
4270
+		$this->appendDebug($this->varDump($return_val));
4271
+
4272
+		$this->debug('serializing response');
4273
+		if ($this->wsdl) {
4274
+			$this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
4275
+			if ($this->opData['style'] == 'rpc') {
4276
+				$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
4277
+				if ($this->opData['output']['use'] == 'literal') {
4278
+					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
4279
+					if ($this->methodURI) {
4280
+						$payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4281
+					} else {
4282
+						$payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . 'Response>';
4283
+					}
4284
+				} else {
4285
+					if ($this->methodURI) {
4286
+						$payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4287
+					} else {
4288
+						$payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . '>';
4289
+					}
4290
+				}
4291
+			} else {
4292
+				$this->debug('style is not rpc for serialization: assume document');
4293
+				$payload = $return_val;
4294
+			}
4295
+		} else {
4296
+			$this->debug('do not have WSDL for serialization: assume rpc/encoded');
4297
+			$payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4298
+		}
4299
+		$this->result = 'successful';
4300
+		if ($this->wsdl) {
4301
+			//if($this->debug_flag){
4302
+			$this->appendDebug($this->wsdl->getDebug());
4303
+			//	}
4304
+			if (isset($this->opData['output']['encodingStyle'])) {
4305
+				$encodingStyle = $this->opData['output']['encodingStyle'];
4306
+			} else {
4307
+				$encodingStyle = '';
4308
+			}
4309
+			// Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
4310
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle);
4311
+		} else {
4312
+			$this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders);
4313
+		}
4314
+		$this->debug("Leaving serialize_return");
4315
+	}
4316
+
4317
+	/**
4318
+	 * sends an HTTP response
4319
+	 *
4320
+	 * The following fields are set by this function (when successful)
4321
+	 *
4322
+	 * outgoing_headers
4323
+	 * response
4324
+	 *
4325
+	 * @access   private
4326
+	 */
4327
+	function send_response()
4328
+	{
4329
+		$this->debug('Enter send_response');
4330
+		if ($this->fault) {
4331
+			$payload = $this->fault->serialize();
4332
+			$this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error";
4333
+			$this->outgoing_headers[] = "Status: 500 Internal Server Error";
4334
+		} else {
4335
+			$payload = $this->responseSOAP;
4336
+			// Some combinations of PHP+Web server allow the Status
4337
+			// to come through as a header.  Since OK is the default
4338
+			// just do nothing.
4339
+			// $this->outgoing_headers[] = "HTTP/1.0 200 OK";
4340
+			// $this->outgoing_headers[] = "Status: 200 OK";
4341
+		}
4342
+		// add debug data if in debug mode
4343
+		if (isset($this->debug_flag) && $this->debug_flag) {
4344
+			$payload .= $this->getDebugAsXMLComment();
4345
+		}
4346
+		$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
4347
+		$rev = array();
4348
+		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
4349
+		$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . (isset($rev[1]) ? $rev[1] : '') . ")";
4350
+		// Let the Web server decide about this
4351
+		//$this->outgoing_headers[] = "Connection: Close\r\n";
4352
+		$payload = $this->getHTTPBody($payload);
4353
+		$type = $this->getHTTPContentType();
4354
+		$charset = $this->getHTTPContentTypeCharset();
4355
+		$this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
4356
+		//begin code to compress payload - by John
4357
+		// NOTE: there is no way to know whether the Web server will also compress
4358
+		// this data.
4359
+		if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
4360
+			if (strstr($this->headers['accept-encoding'], 'gzip')) {
4361
+				if (function_exists('gzencode')) {
4362
+					if (isset($this->debug_flag) && $this->debug_flag) {
4363
+						$payload .= "<!-- Content being gzipped -->";
4364
+					}
4365
+					$this->outgoing_headers[] = "Content-Encoding: gzip";
4366
+					$payload = gzencode($payload);
4367
+				} else {
4368
+					if (isset($this->debug_flag) && $this->debug_flag) {
4369
+						$payload .= "<!-- Content will not be gzipped: no gzencode -->";
4370
+					}
4371
+				}
4372
+			} elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
4373
+				// Note: MSIE requires gzdeflate output (no Zlib header and checksum),
4374
+				// instead of gzcompress output,
4375
+				// which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5)
4376
+				if (function_exists('gzdeflate')) {
4377
+					if (isset($this->debug_flag) && $this->debug_flag) {
4378
+						$payload .= "<!-- Content being deflated -->";
4379
+					}
4380
+					$this->outgoing_headers[] = "Content-Encoding: deflate";
4381
+					$payload = gzdeflate($payload);
4382
+				} else {
4383
+					if (isset($this->debug_flag) && $this->debug_flag) {
4384
+						$payload .= "<!-- Content will not be deflated: no gzcompress -->";
4385
+					}
4386
+				}
4387
+			}
4388
+		}
4389
+		//end code
4390
+		$this->outgoing_headers[] = "Content-Length: " . strlen($payload);
4391
+		reset($this->outgoing_headers);
4392
+		foreach ($this->outgoing_headers as $hdr) {
4393
+			header($hdr, false);
4394
+		}
4395
+		print $payload;
4396
+		$this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload;
4397
+	}
4398
+
4399
+	/**
4400
+	 * takes the value that was created by parsing the request
4401
+	 * and compares to the method's signature, if available.
4402
+	 *
4403
+	 * @param    string $operation The operation to be invoked
4404
+	 * @param    array $request The array of parameter values
4405
+	 * @return    boolean    Whether the operation was found
4406
+	 * @access   private
4407
+	 */
4408
+	function verify_method($operation, $request)
4409
+	{
4410
+		if (isset($this->wsdl) && is_object($this->wsdl)) {
4411
+			if ($this->wsdl->getOperationData($operation)) {
4412
+				return true;
4413
+			}
4414
+		} elseif (isset($this->operations[$operation])) {
4415
+			return true;
4416
+		}
4417
+		return false;
4418
+	}
4419
+
4420
+	/**
4421
+	 * processes SOAP message received from client
4422
+	 *
4423
+	 * @param    array $headers The HTTP headers
4424
+	 * @param    string $data unprocessed request data from client
4425
+	 * @return   false|void void or false on error
4426
+	 * @access   private
4427
+	 */
4428
+	function parseRequest($headers, $data)
4429
+	{
4430
+		$this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
4431
+		$this->appendDebug($this->varDump($headers));
4432
+		if (!isset($headers['content-type'])) {
4433
+			$this->setError('Request not of type '.$this->contentType.' (no content-type header)');
4434
+			return false;
4435
+		}
4436
+		if (!strstr($headers['content-type'], $this->contentType)) {
4437
+			$this->setError('Request not of type '.$this->contentType.': ' . $headers['content-type']);
4438
+			return false;
4439
+		}
4440
+		if (strpos($headers['content-type'], '=')) {
4441
+			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
4442
+			$this->debug('Got response encoding: ' . $enc);
4443
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
4444
+				$this->xml_encoding = strtoupper($enc);
4445
+			} else {
4446
+				$this->xml_encoding = 'US-ASCII';
4447
+			}
4448
+		} else {
4449
+			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
4450
+			$this->xml_encoding = 'ISO-8859-1';
4451
+		}
4452
+		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
4453
+		// parse response, get soap parser obj
4454
+		$parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
4455
+		// parser debug
4456
+		$this->debug("parser debug: \n" . $parser->getDebug());
4457
+		// if fault occurred during message parsing
4458
+		if ($err = $parser->getError()) {
4459
+			$this->result = 'fault: error in msg parsing: ' . $err;
4460
+			$this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err);
4461
+			// else successfully parsed request into soapval object
4462
+		} else {
4463
+			// get/set methodname
4464
+			$this->methodURI = $parser->root_struct_namespace;
4465
+			$this->methodname = $parser->root_struct_name;
4466
+			$this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4467
+
4468
+			// get/set custom response tag name
4469
+			$outputMessage = $this->wsdl->getOperationData($this->methodname)['output']['message'];
4470
+			$this->responseTagName = $outputMessage;
4471
+			$this->debug('responseTagName: ' . $this->responseTagName . ' methodURI: ' . $this->methodURI);
4472
+
4473
+			$this->debug('calling parser->get_soapbody()');
4474
+			$this->methodparams = $parser->get_soapbody();
4475
+			// get SOAP headers
4476
+			$this->requestHeaders = $parser->getHeaders();
4477
+			// get SOAP Header
4478
+			$this->requestHeader = $parser->get_soapheader();
4479
+			// add document for doclit support
4480
+			$this->document = $parser->document;
4481
+		}
4482
+	}
4483
+
4484
+	/**
4485
+	 * gets the HTTP body for the current response.
4486
+	 *
4487
+	 * @param string $soapmsg The SOAP payload
4488
+	 * @return string The HTTP body, which includes the SOAP payload
4489
+	 * @access private
4490
+	 */
4491
+	function getHTTPBody($soapmsg)
4492
+	{
4493
+		return $soapmsg;
4494
+	}
4495
+
4496
+	/**
4497
+	 * gets the HTTP content type for the current response.
4498
+	 *
4499
+	 * Note: getHTTPBody must be called before this.
4500
+	 *
4501
+	 * @return string the HTTP content type for the current response.
4502
+	 * @access private
4503
+	 */
4504
+	function getHTTPContentType()
4505
+	{
4506
+		return 'text/xml';
4507
+	}
4508
+
4509
+	/**
4510
+	 * gets the HTTP content type charset for the current response.
4511
+	 * returns false for non-text content types.
4512
+	 *
4513
+	 * Note: getHTTPBody must be called before this.
4514
+	 *
4515
+	 * @return string the HTTP content type charset for the current response.
4516
+	 * @access private
4517
+	 */
4518
+	function getHTTPContentTypeCharset()
4519
+	{
4520
+		return $this->soap_defencoding;
4521
+	}
4522
+
4523
+	/**
4524
+	 * add a method to the dispatch map (this has been replaced by the register method)
4525
+	 *
4526
+	 * @param    string $methodname
4527
+	 * @param    string $in array of input values
4528
+	 * @param    string $out array of output values
4529
+	 * @access   public
4530
+	 * @deprecated
4531
+	 */
4532
+	function add_to_map($methodname, $in, $out)
4533
+	{
4534
+		$this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out);
4535
+	}
4536
+
4537
+	/**
4538
+	 * register a service function with the server
4539
+	 *
4540
+	 * @param    string $name the name of the PHP function, class.method or class..method
4541
+	 * @param    array $in assoc array of input values: key = param name, value = param type
4542
+	 * @param    array $out assoc array of output values: key = param name, value = param type
4543
+	 * @param    mixed $namespace the element namespace for the method or false
4544
+	 * @param    mixed $soapaction the soapaction for the method or false
4545
+	 * @param    mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically
4546
+	 * @param    mixed $use optional (encoded|literal) or false
4547
+	 * @param    string $documentation optional Description to include in WSDL
4548
+	 * @param    string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
4549
+	 * @param    string $customResponseTagName optional Name of the outgoing response, default $name . 'Response'
4550
+	 * @access   public
4551
+	 */
4552
+	function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '', $customResponseTagName = '')
4553
+	{
4554
+		global $HTTP_SERVER_VARS;
4555
+
4556
+		if ($this->externalWSDLURL) {
4557
+			die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
4558
+		}
4559
+		if (!$name) {
4560
+			die('You must specify a name when you register an operation');
4561
+		}
4562
+		if (!is_array($in)) {
4563
+			die('You must provide an array for operation inputs');
4564
+		}
4565
+		if (!is_array($out)) {
4566
+			die('You must provide an array for operation outputs');
4567
+		}
4568
+		if (!$soapaction) {
4569
+			if (isset($_SERVER)) {
4570
+				$SERVER_NAME = $_SERVER['SERVER_NAME'];
4571
+				$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
4572
+				$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
4573
+			} elseif (isset($HTTP_SERVER_VARS)) {
4574
+				$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4575
+				$SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
4576
+				$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4577
+			} else {
4578
+				$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4579
+				$HTTPS = '';
4580
+				$SERVER_NAME = '';
4581
+				$SCRIPT_NAME = '';
4582
+			}
4583
+			if ($HTTPS == '1' || $HTTPS == 'on') {
4584
+				$SCHEME = 'https';
4585
+			} else {
4586
+				$SCHEME = 'http';
4587
+			}
4588
+			$soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name";
4589
+		}
4590
+		if (!$style) {
4591
+			$style = "rpc";
4592
+		}
4593
+		if (!$use) {
4594
+			$use = "encoded";
4595
+		}
4596
+		if ($use == 'encoded' && $encodingStyle == '') {
4597
+			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
4598
+		}
4599
+		if (!$customResponseTagName) {
4600
+			$customResponseTagName = $name . 'Response';
4601
+		}
4602
+
4603
+		$this->operations[$name] = array(
4604
+			'name' => $name,
4605
+			'in' => $in,
4606
+			'out' => $out,
4607
+			'namespace' => $namespace,
4608
+			'soapaction' => $soapaction,
4609
+			'style' => $style,
4610
+			'outputMessage' => $customResponseTagName,
4611
+		);
4612
+		if ($this->wsdl) {
4613
+			$this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle, $customResponseTagName);
4614
+		}
4615
+		return true;
4616
+	}
4617
+
4618
+	/**
4619
+	 * Specify a fault to be returned to the client.
4620
+	 * This also acts as a flag to the server that a fault has occured.
4621
+	 *
4622
+	 * @param    string $faultcode
4623
+	 * @param    string $faultstring
4624
+	 * @param    string $faultactor
4625
+	 * @param    string $faultdetail
4626
+	 * @access   public
4627
+	 */
4628
+	function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '')
4629
+	{
4630
+		if ($faultdetail == '' && $this->debug_flag) {
4631
+			$faultdetail = $this->getDebug();
4632
+		}
4633
+		$this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail);
4634
+		$this->fault->soap_defencoding = $this->soap_defencoding;
4635
+	}
4636
+
4637
+	/**
4638
+	 * Sets up wsdl object.
4639
+	 * Acts as a flag to enable internal WSDL generation
4640
+	 *
4641
+	 * @param string $serviceName , name of the service
4642
+	 * @param mixed $namespace optional 'tns' service namespace or false
4643
+	 * @param mixed $endpoint optional URL of service endpoint or false
4644
+	 * @param string $style optional (rpc|document) WSDL style (also specified by operation)
4645
+	 * @param string $transport optional SOAP transport
4646
+	 * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false
4647
+	 */
4648
+	function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false)
4649
+	{
4650
+		global $HTTP_SERVER_VARS;
4651
+
4652
+		if (isset($_SERVER)) {
4653
+			$SERVER_NAME = $_SERVER['SERVER_NAME'];
4654
+			$SERVER_PORT = $_SERVER['SERVER_PORT'];
4655
+			$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
4656
+			$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
4657
+		} elseif (isset($HTTP_SERVER_VARS)) {
4658
+			$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
4659
+			$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
4660
+			$SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
4661
+			$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
4662
+		} else {
4663
+			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
4664
+			$SERVER_PORT = '';
4665
+			$SERVER_NAME = '';
4666
+			$SCRIPT_NAME = '';
4667
+			$HTTPS = '';
4668
+		}
4669
+		// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
4670
+		$colon = strpos($SERVER_NAME, ":");
4671
+		if ($colon) {
4672
+			$SERVER_NAME = substr($SERVER_NAME, 0, $colon);
4673
+		}
4674
+		if ($SERVER_PORT == 80) {
4675
+			$SERVER_PORT = '';
4676
+		} else {
4677
+			$SERVER_PORT = ':' . $SERVER_PORT;
4678
+		}
4679
+		if (!$namespace) {
4680
+			$namespace = "http://$SERVER_NAME/soap/$serviceName";
4681
+		}
4682
+
4683
+		if (!$endpoint) {
4684
+			if ($HTTPS == '1' || $HTTPS == 'on') {
4685
+				$SCHEME = 'https';
4686
+			} else {
4687
+				$SCHEME = 'http';
4688
+			}
4689
+			$endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME";
4690
+		}
4691
+
4692
+		if (!$schemaTargetNamespace) {
4693
+			$schemaTargetNamespace = $namespace;
4694
+		}
4695
+
4696
+		$this->wsdl = new wsdl;
4697
+		$this->wsdl->serviceName = $serviceName;
4698
+		$this->wsdl->endpoint = $endpoint;
4699
+		$this->wsdl->namespaces['tns'] = $namespace;
4700
+		$this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/';
4701
+		$this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
4702
+		if ($schemaTargetNamespace != $namespace) {
4703
+			$this->wsdl->namespaces['types'] = $schemaTargetNamespace;
4704
+		}
4705
+		$this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
4706
+		if ($style == 'document') {
4707
+			$this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified';
4708
+		}
4709
+		$this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4710
+		$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
4711
+		$this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
4712
+		$this->wsdl->bindings[$serviceName . 'Binding'] = array(
4713
+			'name' => $serviceName . 'Binding',
4714
+			'style' => $style,
4715
+			'transport' => $transport,
4716
+			'portType' => $serviceName . 'PortType');
4717
+		$this->wsdl->ports[$serviceName . 'Port'] = array(
4718
+			'binding' => $serviceName . 'Binding',
4719
+			'location' => $endpoint,
4720
+			'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/');
4721
+	}
4722
+}
4723
+
4724
+/**
4725
+ * Backward compatibility
4726
+ */
4727
+class soap_server extends nusoap_server
4728
+{
4729
+}
4730
+
4731
+
4732
+/**
4733
+ * parses a WSDL file, allows access to it's data, other utility methods.
4734
+ * also builds WSDL structures programmatically.
4735
+ *
4736
+ * @author   Dietrich Ayala <[email protected]>
4737
+ * @author   Scott Nichol <[email protected]>
4738
+ * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
4739
+ * @access public
4740
+ */
4741
+class wsdl extends nusoap_base
4742
+{
4743
+	// URL or filename of the root of this WSDL
4744
+	var $wsdl;
4745
+	// define internal arrays of bindings, ports, operations, messages, etc.
4746
+	var $schemas = array();
4747
+	var $currentSchema;
4748
+	var $message = array();
4749
+	var $complexTypes = array();
4750
+	var $messages = array();
4751
+	var $currentMessage;
4752
+	var $currentOperation;
4753
+	var $portTypes = array();
4754
+	var $currentPortType;
4755
+	var $bindings = array();
4756
+	var $currentBinding;
4757
+	var $ports = array();
4758
+	var $currentPort;
4759
+	var $opData = array();
4760
+	var $status = '';
4761
+	var $documentation = false;
4762
+	var $endpoint = '';
4763
+	// array of wsdl docs to import
4764
+	var $import = array();
4765
+	// parser vars
4766
+	var $parser;
4767
+	var $position = 0;
4768
+	var $depth = 0;
4769
+	var $depth_array = array();
4770
+	// for getting wsdl
4771
+	var $proxyhost = '';
4772
+	var $proxyport = '';
4773
+	var $proxyusername = '';
4774
+	var $proxypassword = '';
4775
+	var $timeout = 0;
4776
+	var $response_timeout = 30;
4777
+	var $curl_options = array();    // User-specified cURL options
4778
+	var $use_curl = false;            // whether to always try to use cURL
4779
+	// for HTTP authentication
4780
+	var $username = '';                // Username for HTTP authentication
4781
+	var $password = '';                // Password for HTTP authentication
4782
+	var $authtype = '';                // Type of HTTP authentication
4783
+	var $certRequest = array();        // Certificate for HTTP SSL authentication
4784
+
4785
+	/** @var mixed */
4786
+	var $currentPortOperation;
4787
+	/** @var string */
4788
+	var $opStatus;
4789
+	/** @var mixed */
4790
+	var $serviceName;
4791
+	var $wsdl_info;
4792
+
4793
+	/**
4794
+	 * constructor
4795
+	 *
4796
+	 * @param string $wsdl WSDL document URL
4797
+	 * @param string $proxyhost
4798
+	 * @param string $proxyport
4799
+	 * @param string $proxyusername
4800
+	 * @param string $proxypassword
4801
+	 * @param integer $timeout set the connection timeout
4802
+	 * @param integer $response_timeout set the response timeout
4803
+	 * @param array $curl_options user-specified cURL options
4804
+	 * @param boolean $use_curl try to use cURL
4805
+	 * @access public
4806
+	 */
4807
+	function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false)
4808
+	{
4809
+		parent::__construct();
4810
+		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
4811
+		$this->proxyhost = $proxyhost;
4812
+		$this->proxyport = $proxyport;
4813
+		$this->proxyusername = $proxyusername;
4814
+		$this->proxypassword = $proxypassword;
4815
+		$this->timeout = $timeout;
4816
+		$this->response_timeout = $response_timeout;
4817
+		if (is_array($curl_options)) {
4818
+			$this->curl_options = $curl_options;
4819
+		}
4820
+		$this->use_curl = $use_curl;
4821
+		$this->fetchWSDL($wsdl);
4822
+	}
4823
+
4824
+	/**
4825
+	 * fetches the WSDL document and parses it
4826
+	 *
4827
+	 * @access public
4828
+	 */
4829
+	function fetchWSDL($wsdl)
4830
+	{
4831
+		$this->debug("parse and process WSDL path=$wsdl");
4832
+		$this->wsdl = $wsdl;
4833
+		// parse wsdl file
4834
+		if ($this->wsdl != "") {
4835
+			$this->parseWSDL($this->wsdl);
4836
+		}
4837
+		// imports
4838
+		// TODO: handle imports more properly, grabbing them in-line and nesting them
4839
+		$imported_urls = array();
4840
+		$imported = 1;
4841
+		while ($imported > 0) {
4842
+			$imported = 0;
4843
+			// Schema imports
4844
+			foreach ($this->schemas as $ns => $list) {
4845
+				foreach ($list as $xsKey => $xs) {
4846
+					$wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4847
+					foreach ($xs->imports as $ns2 => $list2) {
4848
+						for ($ii = 0; $ii < count($list2); $ii++) {
4849
+							if (array_key_exists($ii, $list2) && (!isset($list2[$ii]['loaded']) || !$list2[$ii]['loaded'])) {
4850
+								@$this->schemas[$ns][$xsKey]->imports[$ns2][$ii]['loaded'] = true;
4851
+								$url = $list2[$ii]['location'];
4852
+								if ($url != '') {
4853
+									$urlparts = parse_url($url);
4854
+									if (!isset($urlparts['host'])) {
4855
+										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4856
+											substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4857
+									}
4858
+									if (!in_array($url, $imported_urls)) {
4859
+										$this->parseWSDL($url);
4860
+										$imported++;
4861
+										$imported_urls[] = $url;
4862
+									}
4863
+								} else {
4864
+									$this->debug("Unexpected scenario: empty URL for unloaded import");
4865
+								}
4866
+							}
4867
+						}
4868
+					}
4869
+				}
4870
+			}
4871
+			// WSDL imports
4872
+			$wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4873
+			foreach ($this->import as $ns => $list) {
4874
+				for ($ii = 0; $ii < count($list); $ii++) {
4875
+					if (!$list[$ii]['loaded']) {
4876
+						$this->import[$ns][$ii]['loaded'] = true;
4877
+						$url = $list[$ii]['location'];
4878
+						if ($url != '') {
4879
+							$urlparts = parse_url($url);
4880
+							if (!isset($urlparts['host'])) {
4881
+								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4882
+									substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4883
+							}
4884
+							if (!in_array($url, $imported_urls)) {
4885
+								$this->parseWSDL($url);
4886
+								$imported++;
4887
+								$imported_urls[] = $url;
4888
+							}
4889
+						} else {
4890
+							$this->debug("Unexpected scenario: empty URL for unloaded import");
4891
+						}
4892
+					}
4893
+				}
4894
+			}
4895
+		}
4896
+		// add new data to operation data
4897
+		foreach ($this->bindings as $binding => $bindingData) {
4898
+			if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
4899
+				foreach ($bindingData['operations'] as $operation => $data) {
4900
+					$this->debug('post-parse data gathering for ' . $operation);
4901
+					$this->bindings[$binding]['operations'][$operation]['input'] =
4902
+						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4903
+							array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) :
4904
+							$this->portTypes[$bindingData['portType']][$operation]['input'];
4905
+					$this->bindings[$binding]['operations'][$operation]['output'] =
4906
+						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4907
+							array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) :
4908
+							$this->portTypes[$bindingData['portType']][$operation]['output'];
4909
+					if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
4910
+						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
4911
+					}
4912
+					if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
4913
+						$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']];
4914
+					}
4915
+					// Set operation style if necessary, but do not override one already provided
4916
+					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
4917
+						$this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
4918
+					}
4919
+					$this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
4920
+					$this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : '';
4921
+					$this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
4922
+				}
4923
+			}
4924
+		}
4925
+	}
4926
+
4927
+	/**
4928
+	 * parses the wsdl document
4929
+	 *
4930
+	 * @param string $wsdl path or URL
4931
+	 * @access private
4932
+	 */
4933
+	function parseWSDL($wsdl = '')
4934
+	{
4935
+		$this->debug("parse WSDL at path=$wsdl");
4936
+
4937
+		if ($wsdl == '') {
4938
+			$this->debug('no wsdl passed to parseWSDL()!!');
4939
+			$this->setError('no wsdl passed to parseWSDL()!!');
4940
+			return false;
4941
+		}
4942
+
4943
+		// parse $wsdl for url format
4944
+		$wsdl_props = parse_url($wsdl);
4945
+
4946
+		if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
4947
+			$this->debug('getting WSDL http(s) URL ' . $wsdl);
4948
+			// get wsdl
4949
+			$tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
4950
+			$tr->request_method = 'GET';
4951
+			$tr->useSOAPAction = false;
4952
+			if ($this->proxyhost && $this->proxyport) {
4953
+				$tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
4954
+			}
4955
+			if ($this->authtype != '') {
4956
+				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
4957
+			}
4958
+			$tr->setEncoding();
4959
+			$wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
4960
+			//$this->debug("WSDL request\n" . $tr->outgoing_payload);
4961
+			//$this->debug("WSDL response\n" . $tr->incoming_payload);
4962
+			$this->appendDebug($tr->getDebug());
4963
+			// catch errors
4964
+			if ($err = $tr->getError()) {
4965
+				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err;
4966
+				$this->debug($errstr);
4967
+				$this->setError($errstr);
4968
+				unset($tr);
4969
+				return false;
4970
+			}
4971
+			unset($tr);
4972
+			$this->debug("got WSDL URL");
4973
+		} else {
4974
+			// $wsdl is not http(s), so treat it as a file URL or plain file path
4975
+			if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
4976
+				$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
4977
+			} else {
4978
+				$path = $wsdl;
4979
+			}
4980
+			$this->debug('getting WSDL file ' . $path);
4981
+			if ($fp = @fopen($path, 'r')) {
4982
+				$wsdl_string = '';
4983
+				while ($data = fread($fp, 32768)) {
4984
+					$wsdl_string .= $data;
4985
+				}
4986
+				fclose($fp);
4987
+			} else {
4988
+				$errstr = "Bad path to WSDL file $path";
4989
+				$this->debug($errstr);
4990
+				$this->setError($errstr);
4991
+				return false;
4992
+			}
4993
+		}
4994
+		$this->debug('Parse WSDL');
4995
+		// end new code added
4996
+		// Create an XML parser.
4997
+		$this->parser = xml_parser_create();
4998
+		// Set the options for parsing the XML data.
4999
+		// xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
5000
+		xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
5001
+		// Set the object for the parser.
5002
+		xml_set_object($this->parser, $this);
5003
+		// Set the element handlers for the parser.
5004
+		xml_set_element_handler($this->parser, 'start_element', 'end_element');
5005
+		xml_set_character_data_handler($this->parser, 'character_data');
5006
+		// Parse the XML file.
5007
+		if (!xml_parse($this->parser, $wsdl_string, true)) {
5008
+			// Display an error message.
5009
+			$errstr = sprintf(
5010
+				'XML error parsing WSDL from %s on line %d: %s',
5011
+				$wsdl,
5012
+				xml_get_current_line_number($this->parser),
5013
+				xml_error_string(xml_get_error_code($this->parser))
5014
+			);
5015
+			$this->debug($errstr);
5016
+			$this->debug("XML payload:\n" . $wsdl_string);
5017
+			$this->setError($errstr);
5018
+			xml_parser_free($this->parser);
5019
+			unset($this->parser);
5020
+			return false;
5021
+		}
5022
+		// free the parser
5023
+		xml_parser_free($this->parser);
5024
+		unset($this->parser);
5025
+		$this->debug('Parsing WSDL done');
5026
+		// catch wsdl parse errors
5027
+		if ($this->getError()) {
5028
+			return false;
5029
+		}
5030
+		return true;
5031
+	}
5032
+
5033
+	/**
5034
+	 * start-element handler
5035
+	 *
5036
+	 * @param string $parser XML parser object
5037
+	 * @param string $name element name
5038
+	 * @param array $attrs associative array of attributes
5039
+	 * @access private
5040
+	 */
5041
+	function start_element($parser, $name, $attrs)
5042
+	{
5043
+		if ($this->status == 'schema') {
5044
+			$this->currentSchema->schemaStartElement($parser, $name, $attrs);
5045
+			$this->appendDebug($this->currentSchema->getDebug());
5046
+			$this->currentSchema->clearDebug();
5047
+		} elseif (preg_match('/schema$/', $name)) {
5048
+			$this->debug('Parsing WSDL schema');
5049
+			// $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
5050
+			$this->status = 'schema';
5051
+			$this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
5052
+			$this->currentSchema->schemaStartElement($parser, $name, $attrs);
5053
+			$this->appendDebug($this->currentSchema->getDebug());
5054
+			$this->currentSchema->clearDebug();
5055
+		} else {
5056
+			// position in the total number of elements, starting from 0
5057
+			$pos = $this->position++;
5058
+			$depth = $this->depth++;
5059
+			// set self as current value for this depth
5060
+			$this->depth_array[$depth] = $pos;
5061
+			$this->message[$pos] = array('cdata' => '');
5062
+			// process attributes
5063
+			if (count($attrs) > 0) {
5064
+				// register namespace declarations
5065
+				foreach ($attrs as $k => $v) {
5066
+					if (preg_match('/^xmlns/', $k)) {
5067
+						if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
5068
+							$this->namespaces[$ns_prefix] = $v;
5069
+						} else {
5070
+							$this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
5071
+						}
5072
+						if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
5073
+							$this->XMLSchemaVersion = $v;
5074
+							$this->namespaces['xsi'] = $v . '-instance';
5075
+						}
5076
+					}
5077
+				}
5078
+				// expand each attribute prefix to its namespace
5079
+				$eAttrs = array ();
5080
+				foreach ($attrs as $k => $v) {
5081
+					$k = strpos($k, ':') ? $this->expandQname($k) : $k;
5082
+					if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
5083
+						$v = strpos($v, ':') ? $this->expandQname($v) : $v;
5084
+					}
5085
+					$eAttrs[$k] = $v;
5086
+				}
5087
+				$attrs = $eAttrs;
5088
+			} else {
5089
+				$attrs = array();
5090
+			}
5091
+		// Set default prefix and namespace
5092
+		// to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE
5093
+		$prefix = '';
5094
+		$namespace = '';
5095
+			// get element prefix, namespace and name
5096
+			if (preg_match('/:/', $name)) {
5097
+				// get ns prefix
5098
+				$prefix = substr($name, 0, strpos($name, ':'));
5099
+				// get ns
5100
+				$namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
5101
+				// get unqualified name
5102
+				$name = substr(strstr($name, ':'), 1);
5103
+			}
5104
+			// process attributes, expanding any prefixes to namespaces
5105
+			// find status, register data
5106
+			switch ($this->status) {
5107
+				case 'message':
5108
+					if ($name == 'part') {
5109
+						if (isset($attrs['type'])) {
5110
+							$this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
5111
+							$this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
5112
+						}
5113
+						if (isset($attrs['element'])) {
5114
+							$this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
5115
+							$this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
5116
+						}
5117
+					}
5118
+					break;
5119
+				case 'portType':
5120
+					switch ($name) {
5121
+						case 'operation':
5122
+							$this->currentPortOperation = $attrs['name'];
5123
+							$this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
5124
+							if (isset($attrs['parameterOrder'])) {
5125
+								$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
5126
+							}
5127
+							break;
5128
+						case 'documentation':
5129
+							$this->documentation = true;
5130
+							break;
5131
+						// merge input/output data
5132
+						default:
5133
+							$m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
5134
+							$this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
5135
+							break;
5136
+					}
5137
+					break;
5138
+				case 'binding':
5139
+					switch ($name) {
5140
+						case 'binding':
5141
+							// get ns prefix
5142
+							if (isset($attrs['style'])) {
5143
+								$this->bindings[$this->currentBinding]['prefix'] = $prefix;
5144
+							}
5145
+							$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
5146
+							break;
5147
+						case 'header':
5148
+							$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
5149
+							break;
5150
+						case 'operation':
5151
+							if (isset($attrs['soapAction'])) {
5152
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
5153
+							}
5154
+							if (isset($attrs['style'])) {
5155
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
5156
+							}
5157
+							if (isset($attrs['name'])) {
5158
+								$this->currentOperation = $attrs['name'];
5159
+								$this->debug("current binding operation: $this->currentOperation");
5160
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
5161
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
5162
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
5163
+							}
5164
+							break;
5165
+						case 'input':
5166
+							$this->opStatus = 'input';
5167
+							break;
5168
+						case 'output':
5169
+							$this->opStatus = 'output';
5170
+							break;
5171
+						case 'body':
5172
+							if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
5173
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
5174
+							} else {
5175
+								$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
5176
+							}
5177
+							break;
5178
+					}
5179
+					break;
5180
+				case 'service':
5181
+					switch ($name) {
5182
+						case 'port':
5183
+							$this->currentPort = $attrs['name'];
5184
+							$this->debug('current port: ' . $this->currentPort);
5185
+							$this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
5186
+
5187
+							break;
5188
+						case 'address':
5189
+							$this->ports[$this->currentPort]['location'] = $attrs['location'];
5190
+							$this->ports[$this->currentPort]['bindingType'] = $namespace;
5191
+							$this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace;
5192
+							$this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location'];
5193
+							break;
5194
+					}
5195
+					break;
5196
+			}
5197
+			// set status
5198
+			switch ($name) {
5199
+				case 'import':
5200
+					if (isset($attrs['location'])) {
5201
+						$this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
5202
+						$this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')');
5203
+					} else {
5204
+						$this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
5205
+						if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
5206
+							$this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
5207
+						}
5208
+						$this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')');
5209
+					}
5210
+					break;
5211
+				//wait for schema
5212
+				//case 'types':
5213
+				//	$this->status = 'schema';
5214
+				//	break;
5215
+				case 'message':
5216
+					$this->status = 'message';
5217
+					$this->messages[$attrs['name']] = array();
5218
+					$this->currentMessage = $attrs['name'];
5219
+					break;
5220
+				case 'portType':
5221
+					$this->status = 'portType';
5222
+					$this->portTypes[$attrs['name']] = array();
5223
+					$this->currentPortType = $attrs['name'];
5224
+					break;
5225
+				case "binding":
5226
+					if (isset($attrs['name'])) {
5227
+						// get binding name
5228
+						if (strpos($attrs['name'], ':')) {
5229
+							$this->currentBinding = $this->getLocalPart($attrs['name']);
5230
+						} else {
5231
+							$this->currentBinding = $attrs['name'];
5232
+						}
5233
+						$this->status = 'binding';
5234
+						$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
5235
+						$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
5236
+					}
5237
+					break;
5238
+				case 'service':
5239
+					$this->serviceName = $attrs['name'];
5240
+					$this->status = 'service';
5241
+					$this->debug('current service: ' . $this->serviceName);
5242
+					break;
5243
+				case 'definitions':
5244
+					foreach ($attrs as $name => $value) {
5245
+						$this->wsdl_info[$name] = $value;
5246
+					}
5247
+					break;
5248
+			}
5249
+		}
5250
+	}
5251
+
5252
+	/**
5253
+	 * end-element handler
5254
+	 *
5255
+	 * @param string $parser XML parser object
5256
+	 * @param string $name element name
5257
+	 * @access private
5258
+	 */
5259
+	function end_element($parser, $name)
5260
+	{
5261
+		// unset schema status
5262
+		if (/*preg_match('/types$/', $name) ||*/
5263
+		preg_match('/schema$/', $name)
5264
+		) {
5265
+			$this->status = "";
5266
+			$this->appendDebug($this->currentSchema->getDebug());
5267
+			$this->currentSchema->clearDebug();
5268
+			$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
5269
+			$this->debug('Parsing WSDL schema done');
5270
+		}
5271
+		if ($this->status == 'schema') {
5272
+			$this->currentSchema->schemaEndElement($parser, $name);
5273
+		} else {
5274
+			// bring depth down a notch
5275
+			$this->depth--;
5276
+		}
5277
+		// end documentation
5278
+		if ($this->documentation) {
5279
+			//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
5280
+			//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
5281
+			$this->documentation = false;
5282
+		}
5283
+	}
5284
+
5285
+	/**
5286
+	 * element content handler
5287
+	 *
5288
+	 * @param string $parser XML parser object
5289
+	 * @param string $data element content
5290
+	 * @access private
5291
+	 */
5292
+	function character_data($parser, $data)
5293
+	{
5294
+		$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
5295
+		if (isset($this->message[$pos]['cdata'])) {
5296
+			$this->message[$pos]['cdata'] .= $data;
5297
+		}
5298
+		if ($this->documentation) {
5299
+			$this->documentation .= $data;
5300
+		}
5301
+	}
5302
+
5303
+	/**
5304
+	 * if authenticating, set user credentials here
5305
+	 *
5306
+	 * @param    string $username
5307
+	 * @param    string $password
5308
+	 * @param    string $authtype (basic|digest|certificate|ntlm)
5309
+	 * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
5310
+	 * @access   public
5311
+	 */
5312
+	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array())
5313
+	{
5314
+		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
5315
+		$this->appendDebug($this->varDump($certRequest));
5316
+		$this->username = $username;
5317
+		$this->password = $password;
5318
+		$this->authtype = $authtype;
5319
+		$this->certRequest = $certRequest;
5320
+	}
5321
+
5322
+	function getBindingData($binding)
5323
+	{
5324
+		if (is_array($this->bindings[$binding])) {
5325
+			return $this->bindings[$binding];
5326
+		}
5327
+		return false;
5328
+	}
5329
+
5330
+	/**
5331
+	 * returns an assoc array of operation names => operation data
5332
+	 *
5333
+	 * @param string $portName WSDL port name
5334
+	 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
5335
+	 * @return array
5336
+	 * @access public
5337
+	 */
5338
+	function getOperations($portName = '', $bindingType = 'soap')
5339
+	{
5340
+		$ops = array();
5341
+		if ($bindingType == 'soap') {
5342
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5343
+		} elseif ($bindingType == 'soap12') {
5344
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5345
+		} else {
5346
+			$this->debug("getOperations bindingType $bindingType may not be supported");
5347
+		}
5348
+		$this->debug("getOperations for port '$portName' bindingType $bindingType");
5349
+		// loop thru ports
5350
+		foreach ($this->ports as $port => $portData) {
5351
+			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
5352
+			if ($portName == '' || $port == $portName) {
5353
+				// binding type of port matches parameter
5354
+				if ($portData['bindingType'] == $bindingType) {
5355
+					$this->debug("getOperations found port $port bindingType $bindingType");
5356
+					//$this->debug("port data: " . $this->varDump($portData));
5357
+					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
5358
+					// merge bindings
5359
+					if (isset($this->bindings[$portData['binding']]['operations'])) {
5360
+						$ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']);
5361
+					}
5362
+				}
5363
+			}
5364
+		}
5365
+		if (count($ops) == 0) {
5366
+			$this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
5367
+		}
5368
+		return $ops;
5369
+	}
5370
+
5371
+	/**
5372
+	 * returns an associative array of data necessary for calling an operation
5373
+	 *
5374
+	 * @param string $operation name of operation
5375
+	 * @param string $bindingType type of binding eg: soap, soap12
5376
+	 * @return array
5377
+	 * @access public
5378
+	 */
5379
+	function getOperationData($operation, $bindingType = 'soap')
5380
+	{
5381
+		if ($bindingType == 'soap') {
5382
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5383
+		} elseif ($bindingType == 'soap12') {
5384
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5385
+		}
5386
+		// loop thru ports
5387
+		foreach ($this->ports as $portData) {
5388
+			// binding type of port matches parameter
5389
+			if ($portData['bindingType'] == $bindingType) {
5390
+				// get binding
5391
+				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
5392
+				// note that we could/should also check the namespace here
5393
+				if (in_array ($operation, array_keys ($this->bindings[$portData['binding']]['operations'])))
5394
+				{
5395
+					return $this->bindings[$portData['binding']]['operations'][$operation];
5396
+				}
5397
+			}
5398
+		}
5399
+		return array ();
5400
+	}
5401
+
5402
+	/**
5403
+	 * returns an associative array of data necessary for calling an operation
5404
+	 *
5405
+	 * @param string $soapAction soapAction for operation
5406
+	 * @param string $bindingType type of binding eg: soap, soap12
5407
+	 * @return array
5408
+	 * @access public
5409
+	 */
5410
+	function getOperationDataForSoapAction($soapAction, $bindingType = 'soap')
5411
+	{
5412
+		if ($bindingType == 'soap') {
5413
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5414
+		} elseif ($bindingType == 'soap12') {
5415
+			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5416
+		}
5417
+		// loop thru ports
5418
+		foreach ($this->ports as $portData) {
5419
+			// binding type of port matches parameter
5420
+			if ($portData['bindingType'] == $bindingType) {
5421
+				// loop through operations for the binding
5422
+				foreach ($this->bindings[$portData['binding']]['operations'] as $opData) {
5423
+					if ($opData['soapAction'] == $soapAction) {
5424
+						return $opData;
5425
+					}
5426
+				}
5427
+			}
5428
+		}
5429
+		return array ();
5430
+	}
5431
+
5432
+	/**
5433
+	 * returns an array of information about a given type
5434
+	 * returns false if no type exists by the given name
5435
+	 *     typeDef = array(
5436
+	 *     'elements' => array(), // refs to elements array
5437
+	 *    'restrictionBase' => '',
5438
+	 *    'phpType' => '',
5439
+	 *    'order' => '(sequence|all)',
5440
+	 *    'attrs' => array() // refs to attributes array
5441
+	 *    )
5442
+	 *
5443
+	 * @param string $type the type
5444
+	 * @param string $ns namespace (not prefix) of the type
5445
+	 * @return false
5446
+	 * @access public
5447
+	 * @see nusoap_xmlschema
5448
+	 */
5449
+	function getTypeDef($type, $ns)
5450
+	{
5451
+		$this->debug("in getTypeDef: type=$type, ns=$ns");
5452
+		if ((!$ns) && isset($this->namespaces['tns'])) {
5453
+			$ns = $this->namespaces['tns'];
5454
+			$this->debug("in getTypeDef: type namespace forced to $ns");
5455
+		}
5456
+		if (!isset($this->schemas[$ns])) {
5457
+			foreach ($this->schemas as $ns0 => $schema0) {
5458
+				if (strcasecmp($ns, $ns0) == 0) {
5459
+					$this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
5460
+					$ns = $ns0;
5461
+					break;
5462
+				}
5463
+			}
5464
+		}
5465
+		if (isset($this->schemas[$ns])) {
5466
+			$this->debug("in getTypeDef: have schema for namespace $ns");
5467
+			for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
5468
+				$xs = &$this->schemas[$ns][$i];
5469
+				$t = $xs->getTypeDef($type);
5470
+				$this->appendDebug($xs->getDebug());
5471
+				$xs->clearDebug();
5472
+				if ($t) {
5473
+					$this->debug("in getTypeDef: found type $type");
5474
+					if (!isset($t['phpType'])) {
5475
+						// get info for type to tack onto the element
5476
+						$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
5477
+						$ns = substr($t['type'], 0, strrpos($t['type'], ':'));
5478
+						$etype = $this->getTypeDef($uqType, $ns);
5479
+						if ($etype) {
5480
+							$this->debug("found type for [element] $type:");
5481
+							$this->debug($this->varDump($etype));
5482
+							if (isset($etype['phpType'])) {
5483
+								$t['phpType'] = $etype['phpType'];
5484
+							}
5485
+							if (isset($etype['elements'])) {
5486
+								$t['elements'] = $etype['elements'];
5487
+							}
5488
+							if (isset($etype['attrs'])) {
5489
+								$t['attrs'] = $etype['attrs'];
5490
+							}
5491
+						} else {
5492
+							$this->debug("did not find type for [element] $type");
5493
+						}
5494
+					}
5495
+					return $t;
5496
+				}
5497
+			}
5498
+			$this->debug("in getTypeDef: did not find type $type");
5499
+		} else {
5500
+			$this->debug("in getTypeDef: do not have schema for namespace $ns");
5501
+		}
5502
+		return false;
5503
+	}
5504
+
5505
+	/**
5506
+	 * prints html description of services
5507
+	 *
5508
+	 * @access private
5509
+	 */
5510
+	function webDescription()
5511
+	{
5512
+		global $HTTP_SERVER_VARS;
5513
+
5514
+		if (isset($_SERVER)) {
5515
+			$PHP_SELF = $_SERVER['PHP_SELF'];
5516
+		} elseif (isset($HTTP_SERVER_VARS)) {
5517
+			$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
5518
+		} else {
5519
+			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
5520
+			$PHP_SELF = '';
5521
+		}
5522
+
5523
+		$b = '
5524
+		<html><head><title>NuSOAP: ' . $this->serviceName . '</title>
5525
+		<style type="text/css">
5526
+		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5527
+		    p       { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
5528
+		    pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
5529
+		    ul      { margin-top: 10px; margin-left: 20px; }
5530
+		    li      { list-style-type: none; margin-top: 10px; color: #000000; }
5531
+		    .content{
5532
+			margin-left: 0px; padding-bottom: 2em; }
5533
+		    .nav {
5534
+			padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
5535
+			margin-top: 10px; margin-left: 0px; color: #000000;
5536
+			background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
5537
+		    .title {
5538
+			font-family: arial; font-size: 26px; color: #ffffff;
5539
+			background-color: #999999; width: 100%;
5540
+			margin-left: 0px; margin-right: 0px;
5541
+			padding-top: 10px; padding-bottom: 10px;}
5542
+		    .hidden {
5543
+			position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
5544
+			font-family: arial; overflow: hidden; width: 600;
5545
+			padding: 20px; font-size: 10px; background-color: #999999;
5546
+			layer-background-color:#FFFFFF; }
5547
+		    a,a:active  { color: charcoal; font-weight: bold; }
5548
+		    a:visited   { color: #666666; font-weight: bold; }
5549
+		    a:hover     { color: cc3300; font-weight: bold; }
5550
+		</style>
5551
+		<script language="JavaScript" type="text/javascript">
5552
+		<!--
5553
+		// POP-UP CAPTIONS...
5554
+		function lib_bwcheck(){ //Browsercheck (needed)
5555
+		    this.ver=navigator.appVersion
5556
+		    this.agent=navigator.userAgent
5557
+		    this.dom=document.getElementById?1:0
5558
+		    this.opera5=this.agent.indexOf("Opera 5")>-1
5559
+		    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
5560
+		    this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
5561
+		    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
5562
+		    this.ie=this.ie4||this.ie5||this.ie6
5563
+		    this.mac=this.agent.indexOf("Mac")>-1
5564
+		    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
5565
+		    this.ns4=(document.layers && !this.dom)?1:0;
5566
+		    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
5567
+		    return this
5568
+		}
5569
+		var bw = new lib_bwcheck()
5570
+		//Makes crossbrowser object.
5571
+		function makeObj(obj){
5572
+		    this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
5573
+		    if(!this.evnt) return false
5574
+		    this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
5575
+		    this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
5576
+		    this.writeIt=b_writeIt;
5577
+		    return this
5578
+		}
5579
+		// A unit of measure that will be added when setting the position of a layer.
5580
+		//var px = bw.ns4||window.opera?"":"px";
5581
+		function b_writeIt(text){
5582
+		    if (bw.ns4){this.wref.write(text);this.wref.close()}
5583
+		    else this.wref.innerHTML = text
5584
+		}
5585
+		//Shows the messages
5586
+		var oDesc;
5587
+		function popup(divid){
5588
+		    if(oDesc = new makeObj(divid)){
5589
+			oDesc.css.visibility = "visible"
5590
+		    }
5591
+		}
5592
+		function popout(){ // Hides message
5593
+		    if(oDesc) oDesc.css.visibility = "hidden"
5594
+		}
5595
+		//-->
5596
+		</script>
5597
+		</head>
5598
+		<body>
5599
+		<div class=content>
5600
+			<br><br>
5601
+			<div class=title>' . $this->serviceName . '</div>
5602
+			<div class=nav>
5603
+				<p>View the <a href="?wsdl">WSDL</a> for the service.
5604
+				Click on an operation name to view it&apos;s details.</p>
5605
+				<ul>';
5606
+		foreach ($this->getOperations() as $op => $data) {
5607
+			$b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
5608
+			// create hidden div
5609
+			$b .= "<div id='$op' class='hidden'>
5610
+				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
5611
+			foreach ($data as $donnie => $marie) { // loop through opdata
5612
+				if ($donnie == 'input' || $donnie == 'output') { // show input/output data
5613
+					$b .= "<font color='white'>" . ucfirst($donnie) . ':</font><br>';
5614
+					foreach ($marie as $captain => $tenille) { // loop through data
5615
+						if ($captain == 'parts') { // loop thru parts
5616
+							$b .= "&nbsp;&nbsp;$captain:<br>";
5617
+							//if(is_array($tenille)){
5618
+							foreach ($tenille as $joanie => $chachi) {
5619
+								$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
5620
+							}
5621
+							//}
5622
+						} else {
5623
+							$b .= "&nbsp;&nbsp;$captain: $tenille<br>";
5624
+						}
5625
+					}
5626
+				} else {
5627
+					$b .= "<font color='white'>" . ucfirst($donnie) . ":</font> $marie<br>";
5628
+				}
5629
+			}
5630
+			$b .= '</div>';
5631
+		}
5632
+		$b .= '
5633
+				<ul>
5634
+			</div>
5635
+		</div></body></html>';
5636
+		return $b;
5637
+	}
5638
+
5639
+	/**
5640
+	 * serialize the parsed wsdl
5641
+	 *
5642
+	 * @param mixed $debug whether to put debug=1 in endpoint URL
5643
+	 * @return string serialization of WSDL
5644
+	 * @access public
5645
+	 */
5646
+	function serialize($debug = 0)
5647
+	{
5648
+		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
5649
+		$xml .= "\n<definitions";
5650
+		foreach ($this->namespaces as $k => $v) {
5651
+			$xml .= " xmlns:$k=\"$v\"";
5652
+		}
5653
+		// 10.9.02 - add poulter fix for wsdl and tns declarations
5654
+		if (isset($this->namespaces['wsdl'])) {
5655
+			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
5656
+		}
5657
+		if (isset($this->namespaces['tns'])) {
5658
+			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
5659
+		}
5660
+		$xml .= '>';
5661
+		// imports
5662
+		if (sizeof($this->import) > 0) {
5663
+			foreach ($this->import as $ns => $list) {
5664
+				foreach ($list as $ii) {
5665
+					if ($ii['location'] != '') {
5666
+						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
5667
+					} else {
5668
+						$xml .= '<import namespace="' . $ns . '" />';
5669
+					}
5670
+				}
5671
+			}
5672
+		}
5673
+		// types
5674
+		if (count($this->schemas) >= 1) {
5675
+			$xml .= "\n<types>\n";
5676
+			foreach ($this->schemas as $list) {
5677
+				foreach ($list as $xs) {
5678
+					$xml .= $xs->serializeSchema();
5679
+				}
5680
+			}
5681
+			$xml .= '</types>';
5682
+		}
5683
+		// messages
5684
+		if (count($this->messages) >= 1) {
5685
+			foreach ($this->messages as $msgName => $msgParts) {
5686
+				$xml .= "\n<message name=\"" . $msgName . '">';
5687
+				if (is_array($msgParts)) {
5688
+					foreach ($msgParts as $partName => $partType) {
5689
+						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
5690
+						if (strpos($partType, ':')) {
5691
+							$typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
5692
+						} elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
5693
+							// print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
5694
+							$typePrefix = 'xsd';
5695
+						} else {
5696
+							foreach ($this->typemap as $ns => $types) {
5697
+								if (isset($types[$partType])) {
5698
+									$typePrefix = $this->getPrefixFromNamespace($ns);
5699
+								}
5700
+							}
5701
+							if (!isset($typePrefix)) {
5702
+								die("$partType has no namespace!");
5703
+							}
5704
+						}
5705
+						$ns = $this->getNamespaceFromPrefix($typePrefix);
5706
+						$localPart = $this->getLocalPart($partType);
5707
+						$typeDef = $this->getTypeDef($localPart, $ns);
5708
+						if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
5709
+							$elementortype = 'element';
5710
+							if (substr($localPart, -1) == '^') {
5711
+								$localPart = substr($localPart, 0, -1);
5712
+							}
5713
+						} else {
5714
+							$elementortype = 'type';
5715
+						}
5716
+						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
5717
+					}
5718
+				}
5719
+				$xml .= '</message>';
5720
+			}
5721
+		}
5722
+		// bindings & porttypes
5723
+		if (count($this->bindings) >= 1) {
5724
+			$binding_xml = '';
5725
+			$portType_xml = '';
5726
+			foreach ($this->bindings as $bindingName => $attrs) {
5727
+				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
5728
+				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
5729
+				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
5730
+				foreach ($attrs['operations'] as $opName => $opParts) {
5731
+					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
5732
+					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="' . $opParts['style'] . '"/>';
5733
+					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
5734
+						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
5735
+					} else {
5736
+						$enc_style = '';
5737
+					}
5738
+					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
5739
+					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
5740
+						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
5741
+					} else {
5742
+						$enc_style = '';
5743
+					}
5744
+					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
5745
+					$binding_xml .= "\n" . '  </operation>';
5746
+					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
5747
+					if (isset($opParts['parameterOrder'])) {
5748
+						$portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
5749
+					}
5750
+					$portType_xml .= '>';
5751
+					if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
5752
+						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
5753
+					}
5754
+					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
5755
+					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
5756
+					$portType_xml .= "\n" . '  </operation>';
5757
+				}
5758
+				$portType_xml .= "\n" . '</portType>';
5759
+				$binding_xml .= "\n" . '</binding>';
5760
+			}
5761
+			$xml .= $portType_xml . $binding_xml;
5762
+		}
5763
+		// services
5764
+		$xml .= "\n<service name=\"" . $this->serviceName . '">';
5765
+		if (count($this->ports) >= 1) {
5766
+			foreach ($this->ports as $pName => $attrs) {
5767
+				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
5768
+				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
5769
+				$xml .= "\n" . '  </port>';
5770
+			}
5771
+		}
5772
+		$xml .= "\n" . '</service>';
5773
+		return $xml . "\n</definitions>";
5774
+	}
5775
+
5776
+	/**
5777
+	 * determine whether a set of parameters are unwrapped
5778
+	 * when they are expect to be wrapped, Microsoft-style.
5779
+	 *
5780
+	 * @param string $type the type (element name) of the wrapper
5781
+	 * @param array $parameters the parameter values for the SOAP call
5782
+	 * @return boolean whether they parameters are unwrapped (and should be wrapped)
5783
+	 * @access private
5784
+	 */
5785
+	function parametersMatchWrapped($type, $parameters)
5786
+	{
5787
+		$this->debug("in parametersMatchWrapped type=$type, parameters=");
5788
+		$this->appendDebug($this->varDump($parameters));
5789
+
5790
+		// split type into namespace:unqualified-type
5791
+		if (strpos($type, ':')) {
5792
+			$uqType = substr($type, strrpos($type, ':') + 1);
5793
+			$ns = substr($type, 0, strrpos($type, ':'));
5794
+			$this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
5795
+			if ($this->getNamespaceFromPrefix($ns)) {
5796
+				$ns = $this->getNamespaceFromPrefix($ns);
5797
+				$this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
5798
+			}
5799
+		} else {
5800
+			// TODO: should the type be compared to types in XSD, and the namespace
5801
+			// set to XSD if the type matches?
5802
+			$this->debug("in parametersMatchWrapped: No namespace for type $type");
5803
+			$ns = '';
5804
+			$uqType = $type;
5805
+		}
5806
+
5807
+		// get the type information
5808
+		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
5809
+			$this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
5810
+			return false;
5811
+		}
5812
+		$this->debug("in parametersMatchWrapped: found typeDef=");
5813
+		$this->appendDebug($this->varDump($typeDef));
5814
+		if (substr($uqType, -1) == '^') {
5815
+			$uqType = substr($uqType, 0, -1);
5816
+		}
5817
+		$phpType = $typeDef['phpType'];
5818
+		$arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
5819
+		$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
5820
+
5821
+		// we expect a complexType or element of complexType
5822
+		if ($phpType != 'struct') {
5823
+			$this->debug("in parametersMatchWrapped: not a struct");
5824
+			return false;
5825
+		}
5826
+
5827
+		// see whether the parameter names match the elements
5828
+		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
5829
+			$elements = 0;
5830
+			$matches = 0;
5831
+			foreach ($typeDef['elements'] as $name => $attrs) {
5832
+				if (isset($parameters[$name])) {
5833
+					$this->debug("in parametersMatchWrapped: have parameter named $name");
5834
+					$matches++;
5835
+				} else {
5836
+					$this->debug("in parametersMatchWrapped: do not have parameter named $name");
5837
+				}
5838
+				$elements++;
5839
+			}
5840
+
5841
+			$this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
5842
+			if ($matches == 0) {
5843
+				return false;
5844
+			}
5845
+			return true;
5846
+		}
5847
+
5848
+		// since there are no elements for the type, if the user passed no
5849
+		// parameters, the parameters match wrapped.
5850
+		$this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
5851
+		return count($parameters) == 0;
5852
+	}
5853
+
5854
+	/**
5855
+	 * serialize PHP values according to a WSDL message definition
5856
+	 * contrary to the method name, this is not limited to RPC
5857
+	 *
5858
+	 * TODO
5859
+	 * - multi-ref serialization
5860
+	 * - validate PHP values against type definitions, return errors if invalid
5861
+	 *
5862
+	 * @param string $operation operation name
5863
+	 * @param string $direction (input|output)
5864
+	 * @param mixed $parameters parameter value(s)
5865
+	 * @param string $bindingType (soap|soap12)
5866
+	 * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
5867
+	 * @access public
5868
+	 */
5869
+	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap')
5870
+	{
5871
+		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
5872
+		$this->appendDebug('parameters=' . $this->varDump($parameters));
5873
+
5874
+		if ($direction != 'input' && $direction != 'output') {
5875
+			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5876
+			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5877
+			return false;
5878
+		}
5879
+		if (!$opData = $this->getOperationData($operation, $bindingType)) {
5880
+			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5881
+			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5882
+			return false;
5883
+		}
5884
+		$this->debug('in serializeRPCParameters: opData:');
5885
+		$this->appendDebug($this->varDump($opData));
5886
+
5887
+		// Get encoding style for output and set to current
5888
+		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5889
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
5890
+			$encodingStyle = $opData['output']['encodingStyle'];
5891
+		}
5892
+
5893
+		// set input params
5894
+		$xml = '';
5895
+		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
5896
+			$parts = &$opData[$direction]['parts'];
5897
+			$part_count = sizeof($parts);
5898
+			$style = $opData['style'];
5899
+			$use = $opData[$direction]['use'];
5900
+			$this->debug("have $part_count part(s) to serialize using $style/$use");
5901
+			if (is_array($parameters)) {
5902
+				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
5903
+				$parameter_count = count($parameters);
5904
+				$this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
5905
+				// check for Microsoft-style wrapped parameters
5906
+				if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
5907
+					$this->debug('check whether the caller has wrapped the parameters');
5908
+					if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
5909
+						// TODO: consider checking here for double-wrapping, when
5910
+						// service function wraps, then NuSOAP wraps again
5911
+						$this->debug("change simple array to associative with 'parameters' element");
5912
+						$parameters['parameters'] = $parameters[0];
5913
+						unset($parameters[0]);
5914
+					}
5915
+					if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
5916
+						$this->debug('check whether caller\'s parameters match the wrapped ones');
5917
+						if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
5918
+							$this->debug('wrap the parameters for the caller');
5919
+							$parameters = array('parameters' => $parameters);
5920
+						}
5921
+					}
5922
+				}
5923
+				foreach ($parts as $name => $type) {
5924
+					$this->debug("serializing part $name of type $type");
5925
+					// Track encoding style
5926
+					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
5927
+						$encodingStyle = $opData[$direction]['encodingStyle'];
5928
+						$enc_style = $encodingStyle;
5929
+					} else {
5930
+						$enc_style = false;
5931
+					}
5932
+					// NOTE: add error handling here
5933
+					// if serializeType returns false, then catch global error and fault
5934
+					if ($parametersArrayType == 'arraySimple') {
5935
+						$p = array_shift($parameters);
5936
+						$this->debug('calling serializeType w/indexed param');
5937
+						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
5938
+					} elseif (isset($parameters[$name])) {
5939
+						$this->debug('calling serializeType w/named param');
5940
+						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
5941
+					} else {
5942
+						// TODO: only send nillable
5943
+						$this->debug('calling serializeType w/null param');
5944
+						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
5945
+					}
5946
+				}
5947
+			} else {
5948
+				$this->debug('no parameters passed.');
5949
+			}
5950
+		}
5951
+		$this->debug("serializeRPCParameters returning: $xml");
5952
+		return $xml;
5953
+	}
5954
+
5955
+	/**
5956
+	 * serialize a PHP value according to a WSDL message definition
5957
+	 *
5958
+	 * TODO
5959
+	 * - multi-ref serialization
5960
+	 * - validate PHP values against type definitions, return errors if invalid
5961
+	 *
5962
+	 * @param string $operation operation name
5963
+	 * @param string $direction (input|output)
5964
+	 * @param mixed $parameters parameter value(s)
5965
+	 * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
5966
+	 * @access public
5967
+	 * @deprecated
5968
+	 */
5969
+	function serializeParameters($operation, $direction, $parameters)
5970
+	{
5971
+		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
5972
+		$this->appendDebug('parameters=' . $this->varDump($parameters));
5973
+
5974
+		if ($direction != 'input' && $direction != 'output') {
5975
+			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5976
+			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5977
+			return false;
5978
+		}
5979
+		if (!$opData = $this->getOperationData($operation)) {
5980
+			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5981
+			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5982
+			return false;
5983
+		}
5984
+		$this->debug('opData:');
5985
+		$this->appendDebug($this->varDump($opData));
5986
+
5987
+		// Get encoding style for output and set to current
5988
+		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5989
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
5990
+			$encodingStyle = $opData['output']['encodingStyle'];
5991
+		}
5992
+
5993
+		// set input params
5994
+		$xml = '';
5995
+		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
5996
+
5997
+			$use = $opData[$direction]['use'];
5998
+			$this->debug("use=$use");
5999
+			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
6000
+			if (is_array($parameters)) {
6001
+				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
6002
+				$this->debug('have ' . $parametersArrayType . ' parameters');
6003
+				foreach ($opData[$direction]['parts'] as $name => $type) {
6004
+					$this->debug('serializing part "' . $name . '" of type "' . $type . '"');
6005
+					// Track encoding style
6006
+					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
6007
+						$encodingStyle = $opData[$direction]['encodingStyle'];
6008
+						$enc_style = $encodingStyle;
6009
+					} else {
6010
+						$enc_style = false;
6011
+					}
6012
+					// NOTE: add error handling here
6013
+					// if serializeType returns false, then catch global error and fault
6014
+					if ($parametersArrayType == 'arraySimple') {
6015
+						$p = array_shift($parameters);
6016
+						$this->debug('calling serializeType w/indexed param');
6017
+						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
6018
+					} elseif (isset($parameters[$name])) {
6019
+						$this->debug('calling serializeType w/named param');
6020
+						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
6021
+					} else {
6022
+						// TODO: only send nillable
6023
+						$this->debug('calling serializeType w/null param');
6024
+						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
6025
+					}
6026
+				}
6027
+			} else {
6028
+				$this->debug('no parameters passed.');
6029
+			}
6030
+		}
6031
+		$this->debug("serializeParameters returning: $xml");
6032
+		return $xml;
6033
+	}
6034
+
6035
+	/**
6036
+	 * serializes a PHP value according a given type definition
6037
+	 *
6038
+	 * @param string $name name of value (part or element)
6039
+	 * @param string $type XML schema type of value (type or element)
6040
+	 * @param mixed $value a native PHP value (parameter value)
6041
+	 * @param string $use use for part (encoded|literal)
6042
+	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
6043
+	 * @param boolean $unqualified a kludge for what should be XML namespace form handling
6044
+	 * @return string value serialized as an XML string
6045
+	 * @access private
6046
+	 */
6047
+	function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false)
6048
+	{
6049
+		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
6050
+		$this->appendDebug("value=" . $this->varDump($value));
6051
+		if ($use == 'encoded' && $encodingStyle) {
6052
+			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
6053
+		}
6054
+
6055
+		// if a soapval has been supplied, let its type override the WSDL
6056
+		if (is_object($value) && get_class($value) == 'soapval') {
6057
+			if ($value->type_ns) {
6058
+				$type = $value->type_ns . ':' . $value->type;
6059
+				$forceType = true;
6060
+				$this->debug("in serializeType: soapval overrides type to $type");
6061
+			} elseif ($value->type) {
6062
+				$type = $value->type;
6063
+				$forceType = true;
6064
+				$this->debug("in serializeType: soapval overrides type to $type");
6065
+			} else {
6066
+				$forceType = false;
6067
+				$this->debug("in serializeType: soapval does not override type");
6068
+			}
6069
+			$attrs = $value->attributes;
6070
+			$value = $value->value;
6071
+			$this->debug("in serializeType: soapval overrides value to $value");
6072
+			if ($attrs) {
6073
+				if (!is_array($value)) {
6074
+					$value['!'] = $value;
6075
+				}
6076
+				foreach ($attrs as $n => $v) {
6077
+					$value['!' . $n] = $v;
6078
+				}
6079
+				$this->debug("in serializeType: soapval provides attributes");
6080
+			}
6081
+		} else {
6082
+			$forceType = false;
6083
+		}
6084
+
6085
+		$xml = '';
6086
+		if (strpos($type, ':')) {
6087
+			$uqType = substr($type, strrpos($type, ':') + 1);
6088
+			$ns = substr($type, 0, strrpos($type, ':'));
6089
+			$this->debug("in serializeType: got a prefixed type: $uqType, $ns");
6090
+			if ($this->getNamespaceFromPrefix($ns)) {
6091
+				$ns = $this->getNamespaceFromPrefix($ns);
6092
+				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
6093
+			}
6094
+
6095
+			if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
6096
+				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
6097
+				if ($unqualified && $use == 'literal') {
6098
+					$elementNS = " xmlns=\"\"";
6099
+				} else {
6100
+					$elementNS = '';
6101
+				}
6102
+				if (is_null($value)) {
6103
+					if ($use == 'literal') {
6104
+						// TODO: depends on minOccurs
6105
+						$xml = "<$name$elementNS/>";
6106
+					} else {
6107
+						// TODO: depends on nillable, which should be checked before calling this method
6108
+						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6109
+					}
6110
+					$this->debug("in serializeType: returning: $xml");
6111
+					return $xml;
6112
+				}
6113
+				if ($uqType == 'Array') {
6114
+					// JBoss/Axis does this sometimes
6115
+					return $this->serialize_val($value, $name, false, false, false, false, $use);
6116
+				}
6117
+				if ($uqType == 'boolean') {
6118
+					if ((is_string($value) && $value == 'false') || (!$value)) {
6119
+						$value = 'false';
6120
+					} else {
6121
+						$value = 'true';
6122
+					}
6123
+				}
6124
+				if ($uqType == 'string' && gettype($value) == 'string') {
6125
+					$value = $this->expandEntities($value);
6126
+				}
6127
+				if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
6128
+					$value = sprintf("%.0lf", $value);
6129
+				}
6130
+				// it's a scalar
6131
+				// TODO: what about null/nil values?
6132
+				// check type isn't a custom type extending xmlschema namespace
6133
+				if (!$this->getTypeDef($uqType, $ns)) {
6134
+					if ($use == 'literal') {
6135
+						if ($forceType) {
6136
+							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6137
+						} else {
6138
+							$xml = "<$name$elementNS>$value</$name>";
6139
+						}
6140
+					} else {
6141
+						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6142
+					}
6143
+					$this->debug("in serializeType: returning: $xml");
6144
+					return $xml;
6145
+				}
6146
+				$this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
6147
+			} elseif ($ns == 'http://xml.apache.org/xml-soap') {
6148
+				$this->debug('in serializeType: appears to be Apache SOAP type');
6149
+				if ($uqType == 'Map') {
6150
+					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
6151
+					if (!$tt_prefix) {
6152
+						$this->debug('in serializeType: Add namespace for Apache SOAP type');
6153
+						$tt_prefix = 'ns' . rand(1000, 9999);
6154
+						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
6155
+						// force this to be added to usedNamespaces
6156
+						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
6157
+					}
6158
+					$contents = '';
6159
+					foreach ($value as $k => $v) {
6160
+						$this->debug("serializing map element: key $k, value $v");
6161
+						$contents .= '<item>';
6162
+						$contents .= $this->serialize_val($k, 'key', false, false, false, false, $use);
6163
+						$contents .= $this->serialize_val($v, 'value', false, false, false, false, $use);
6164
+						$contents .= '</item>';
6165
+					}
6166
+					if ($use == 'literal') {
6167
+						if ($forceType) {
6168
+							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
6169
+						} else {
6170
+							$xml = "<$name>$contents</$name>";
6171
+						}
6172
+					} else {
6173
+						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
6174
+					}
6175
+					$this->debug("in serializeType: returning: $xml");
6176
+					return $xml;
6177
+				}
6178
+				$this->debug('in serializeType: Apache SOAP type, but only support Map');
6179
+			}
6180
+		} else {
6181
+			// TODO: should the type be compared to types in XSD, and the namespace
6182
+			// set to XSD if the type matches?
6183
+			$this->debug("in serializeType: No namespace for type $type");
6184
+			$ns = '';
6185
+			$uqType = $type;
6186
+		}
6187
+		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
6188
+			$this->setError("$type ($uqType) is not a supported type.");
6189
+			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
6190
+			return false;
6191
+		} else {
6192
+			$this->debug("in serializeType: found typeDef");
6193
+			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
6194
+			if (substr($uqType, -1) == '^') {
6195
+				$uqType = substr($uqType, 0, -1);
6196
+			}
6197
+		}
6198
+		if (!isset($typeDef['phpType'])) {
6199
+			$this->setError("$type ($uqType) has no phpType.");
6200
+			$this->debug("in serializeType: $type ($uqType) has no phpType.");
6201
+			return false;
6202
+		}
6203
+		$phpType = $typeDef['phpType'];
6204
+		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
6205
+		// if php type == struct, map value to the <all> element names
6206
+		if ($phpType == 'struct') {
6207
+			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
6208
+				$elementName = $uqType;
6209
+				if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6210
+					$elementNS = " xmlns=\"$ns\"";
6211
+				} else {
6212
+					$elementNS = " xmlns=\"\"";
6213
+				}
6214
+			} else {
6215
+				$elementName = $name;
6216
+				if ($unqualified) {
6217
+					$elementNS = " xmlns=\"\"";
6218
+				} else {
6219
+					$elementNS = '';
6220
+				}
6221
+			}
6222
+			if (is_null($value)) {
6223
+				if ($use == 'literal') {
6224
+					// TODO: depends on minOccurs and nillable
6225
+					$xml = "<$elementName$elementNS/>";
6226
+				} else {
6227
+					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6228
+				}
6229
+				$this->debug("in serializeType: returning: $xml");
6230
+				return $xml;
6231
+			}
6232
+			if (is_object($value)) {
6233
+				$value = get_object_vars($value);
6234
+			}
6235
+			if (is_array($value)) {
6236
+				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
6237
+				if ($use == 'literal') {
6238
+					if ($forceType) {
6239
+						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
6240
+					} else {
6241
+						$xml = "<$elementName$elementNS$elementAttrs>";
6242
+					}
6243
+				} else {
6244
+					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
6245
+				}
6246
+
6247
+				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
6248
+					if (isset($value['!'])) {
6249
+						$xml .= $value['!'];
6250
+						$this->debug("in serializeType: serialized simpleContent for type $type");
6251
+					} else {
6252
+						$this->debug("in serializeType: no simpleContent to serialize for type $type");
6253
+					}
6254
+				} else {
6255
+					// complexContent
6256
+					$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
6257
+				}
6258
+				$xml .= "</$elementName>";
6259
+			} else {
6260
+				$this->debug("in serializeType: phpType is struct, but value is not an array");
6261
+				$this->setError("phpType is struct, but value is not an array: see debug output for details");
6262
+			}
6263
+		} elseif ($phpType == 'array') {
6264
+			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6265
+				$elementNS = " xmlns=\"$ns\"";
6266
+			} else {
6267
+				if ($unqualified) {
6268
+					$elementNS = " xmlns=\"\"";
6269
+				} else {
6270
+					$elementNS = '';
6271
+				}
6272
+			}
6273
+			if (is_null($value)) {
6274
+				if ($use == 'literal') {
6275
+					// TODO: depends on minOccurs
6276
+					$xml = "<$name$elementNS/>";
6277
+				} else {
6278
+					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
6279
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6280
+						":Array\" " .
6281
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6282
+						':arrayType="' .
6283
+						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
6284
+						':' .
6285
+						$this->getLocalPart($typeDef['arrayType']) . "[0]\"/>";
6286
+				}
6287
+				$this->debug("in serializeType: returning: $xml");
6288
+				return $xml;
6289
+			}
6290
+			$cols = '';
6291
+			if (isset($typeDef['multidimensional'])) {
6292
+				$nv = array();
6293
+				foreach ($value as $v) {
6294
+					$cols = ',' . sizeof($v);
6295
+					$nv = array_merge($nv, $v);
6296
+				}
6297
+				$value = $nv;
6298
+			}
6299
+			if (is_array($value) && sizeof($value) >= 1) {
6300
+				$rows = sizeof($value);
6301
+				$contents = '';
6302
+				foreach ($value as $v) {
6303
+					//$this->debug breaks when serializing ArrayOfComplexType
6304
+					//Error: Object of class [COMPLEX-TYPE] could not be converted to string
6305
+					//$this->debug("serializing array element: $k, " . (is_array($v) ? "array" : $v) . " of type: $typeDef[arrayType]");
6306
+					//if (strpos($typeDef['arrayType'], ':') ) {
6307
+					if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
6308
+						$contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
6309
+					} else {
6310
+						$contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
6311
+					}
6312
+				}
6313
+			} else {
6314
+				$rows = 0;
6315
+				$contents = null;
6316
+			}
6317
+			// TODO: for now, an empty value will be serialized as a zero element
6318
+			// array.  Revisit this when coding the handling of null/nil values.
6319
+			if ($use == 'literal') {
6320
+				$xml = "<$name$elementNS>"
6321
+					. $contents
6322
+					. "</$name>";
6323
+			} else {
6324
+				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':Array" ' .
6325
+					$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
6326
+					. ':arrayType="'
6327
+					. $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
6328
+					. ":" . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">"
6329
+					. $contents
6330
+					. "</$name>";
6331
+			}
6332
+		} elseif ($phpType == 'scalar') {
6333
+			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6334
+				$elementNS = " xmlns=\"$ns\"";
6335
+			} else {
6336
+				if ($unqualified) {
6337
+					$elementNS = " xmlns=\"\"";
6338
+				} else {
6339
+					$elementNS = '';
6340
+				}
6341
+			}
6342
+			if ($use == 'literal') {
6343
+				if ($forceType) {
6344
+					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6345
+				} else {
6346
+					$xml = "<$name$elementNS>$value</$name>";
6347
+				}
6348
+			} else {
6349
+				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6350
+			}
6351
+		}
6352
+		$this->debug("in serializeType: returning: $xml");
6353
+		return $xml;
6354
+	}
6355
+
6356
+	/**
6357
+	 * serializes the attributes for a complexType
6358
+	 *
6359
+	 * @param array $typeDef our internal representation of an XML schema type (or element)
6360
+	 * @param mixed $value a native PHP value (parameter value)
6361
+	 * @param string $ns the namespace of the type
6362
+	 * @param string $uqType the local part of the type
6363
+	 * @return string value serialized as an XML string
6364
+	 * @access private
6365
+	 */
6366
+	function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType)
6367
+	{
6368
+		$this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
6369
+		$xml = '';
6370
+		if (isset($typeDef['extensionBase'])) {
6371
+			$nsx = $this->getPrefix($typeDef['extensionBase']);
6372
+			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
6373
+			if ($this->getNamespaceFromPrefix($nsx)) {
6374
+				$nsx = $this->getNamespaceFromPrefix($nsx);
6375
+			}
6376
+			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
6377
+				$this->debug("serialize attributes for extension base $nsx:$uqTypex");
6378
+				$xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
6379
+			} else {
6380
+				$this->debug("extension base $nsx:$uqTypex is not a supported type");
6381
+			}
6382
+		}
6383
+		if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
6384
+			$this->debug("serialize attributes for XML Schema type $ns:$uqType");
6385
+			if (is_array($value)) {
6386
+				$xvalue = $value;
6387
+			} elseif (is_object($value)) {
6388
+				$xvalue = get_object_vars($value);
6389
+			} else {
6390
+				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6391
+				$xvalue = array();
6392
+			}
6393
+			foreach ($typeDef['attrs'] as $aName => $attrs) {
6394
+				if (isset($xvalue['!' . $aName])) {
6395
+					$xname = '!' . $aName;
6396
+					$this->debug("value provided for attribute $aName with key $xname");
6397
+				} elseif (isset($xvalue[$aName])) {
6398
+					$xname = $aName;
6399
+					$this->debug("value provided for attribute $aName with key $xname");
6400
+				} elseif (isset($attrs['default'])) {
6401
+					$xname = '!' . $aName;
6402
+					$xvalue[$xname] = $attrs['default'];
6403
+					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
6404
+				} else {
6405
+					$xname = '';
6406
+					$this->debug("no value provided for attribute $aName");
6407
+				}
6408
+				if ($xname) {
6409
+					$xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
6410
+				}
6411
+			}
6412
+		} else {
6413
+			$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
6414
+		}
6415
+		return $xml;
6416
+	}
6417
+
6418
+	/**
6419
+	 * serializes the elements for a complexType
6420
+	 *
6421
+	 * @param array $typeDef our internal representation of an XML schema type (or element)
6422
+	 * @param mixed $value a native PHP value (parameter value)
6423
+	 * @param string $ns the namespace of the type
6424
+	 * @param string $uqType the local part of the type
6425
+	 * @param string $use use for part (encoded|literal)
6426
+	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
6427
+	 * @return string value serialized as an XML string
6428
+	 * @access private
6429
+	 */
6430
+	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false)
6431
+	{
6432
+		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
6433
+		$xml = '';
6434
+		if (isset($typeDef['extensionBase'])) {
6435
+			$nsx = $this->getPrefix($typeDef['extensionBase']);
6436
+			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
6437
+			if ($this->getNamespaceFromPrefix($nsx)) {
6438
+				$nsx = $this->getNamespaceFromPrefix($nsx);
6439
+			}
6440
+			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
6441
+				$this->debug("serialize elements for extension base $nsx:$uqTypex");
6442
+				$xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
6443
+			} else {
6444
+				$this->debug("extension base $nsx:$uqTypex is not a supported type");
6445
+			}
6446
+		}
6447
+		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
6448
+			$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
6449
+			if (is_array($value)) {
6450
+				$xvalue = $value;
6451
+			} elseif (is_object($value)) {
6452
+				$xvalue = get_object_vars($value);
6453
+			} else {
6454
+				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6455
+				$xvalue = array();
6456
+			}
6457
+			// toggle whether all elements are present - ideally should validate against schema
6458
+			if (count($typeDef['elements']) != count($xvalue)) {
6459
+				$optionals = true;
6460
+			}
6461
+			foreach ($typeDef['elements'] as $eName => $attrs) {
6462
+				if (!isset($xvalue[$eName])) {
6463
+					if (isset($attrs['default'])) {
6464
+						$xvalue[$eName] = $attrs['default'];
6465
+						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
6466
+					}
6467
+				}
6468
+				// if user took advantage of a minOccurs=0, then only serialize named parameters
6469
+				if (isset($optionals)
6470
+					&& (!isset($xvalue[$eName]))
6471
+					&& ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
6472
+				) {
6473
+					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
6474
+						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
6475
+					}
6476
+					// do nothing
6477
+					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
6478
+				} else {
6479
+					// get value
6480
+					if (isset($xvalue[$eName])) {
6481
+						$v = $xvalue[$eName];
6482
+					} else {
6483
+						$v = null;
6484
+					}
6485
+					if (isset($attrs['form'])) {
6486
+						$unqualified = ($attrs['form'] == 'unqualified');
6487
+					} else {
6488
+						$unqualified = false;
6489
+					}
6490
+					if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
6491
+						$vv = $v;
6492
+						foreach ($vv as $v) {
6493
+							if (isset($attrs['type']) || isset($attrs['ref'])) {
6494
+								// serialize schema-defined type
6495
+								$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
6496
+							} else {
6497
+								// serialize generic type (can this ever really happen?)
6498
+								$this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6499
+								$xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
6500
+							}
6501
+						}
6502
+					} else {
6503
+						if (!is_null ($v) || !isset($attrs['minOccurs']) || $attrs['minOccurs'] != '0')
6504
+						{
6505
+							if (is_null ($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true')
6506
+							{
6507
+								// TODO: serialize a nil correctly, but for now serialize schema-defined type
6508
+								$xml .= $this->serializeType ($eName,
6509
+															  isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6510
+															  $v, $use, $encodingStyle, $unqualified);
6511
+							}
6512
+							elseif (isset($attrs['type']) || isset($attrs['ref']))
6513
+							{
6514
+								// serialize schema-defined type
6515
+								$xml .= $this->serializeType ($eName,
6516
+															  isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6517
+															  $v, $use, $encodingStyle, $unqualified);
6518
+							}
6519
+							else
6520
+							{
6521
+								// serialize generic type (can this ever really happen?)
6522
+								$this->debug ("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6523
+								$xml .= $this->serialize_val ($v, $eName, false, false, false, false, $use);
6524
+							}
6525
+						}
6526
+					}
6527
+				}
6528
+			}
6529
+		} else {
6530
+			$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
6531
+		}
6532
+		return $xml;
6533
+	}
6534
+
6535
+	/**
6536
+	 * adds an XML Schema complex type to the WSDL types
6537
+	 *
6538
+	 * @param string $name
6539
+	 * @param string $typeClass (complexType|simpleType|attribute)
6540
+	 * @param string $phpType currently supported are array and struct (php assoc array)
6541
+	 * @param string $compositor (all|sequence|choice)
6542
+	 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
6543
+	 * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
6544
+	 * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
6545
+	 * @param string $arrayType as namespace:name (xsd:string)
6546
+	 * @see nusoap_xmlschema
6547
+	 * @access public
6548
+	 */
6549
+	function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '')
6550
+	{
6551
+		if (count($elements) > 0) {
6552
+			$eElements = array();
6553
+			foreach ($elements as $n => $e) {
6554
+				// expand each element
6555
+				$ee = array();
6556
+				foreach ($e as $k => $v) {
6557
+					$k = strpos($k, ':') ? $this->expandQname($k) : $k;
6558
+					$v = strpos($v, ':') ? $this->expandQname($v) : $v;
6559
+					$ee[$k] = $v;
6560
+				}
6561
+				$eElements[$n] = $ee;
6562
+			}
6563
+			$elements = $eElements;
6564
+		}
4731 6565
 
4732
-/**
4733
- * parses a WSDL file, allows access to it's data, other utility methods.
4734
- * also builds WSDL structures programmatically.
4735
- *
4736
- * @author   Dietrich Ayala <[email protected]>
4737
- * @author   Scott Nichol <[email protected]>
4738
- * @version  $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
4739
- * @access public
4740
- */
4741
-class wsdl extends nusoap_base
4742
-{
4743
-    // URL or filename of the root of this WSDL
4744
-    var $wsdl;
4745
-    // define internal arrays of bindings, ports, operations, messages, etc.
4746
-    var $schemas = array();
4747
-    var $currentSchema;
4748
-    var $message = array();
4749
-    var $complexTypes = array();
4750
-    var $messages = array();
4751
-    var $currentMessage;
4752
-    var $currentOperation;
4753
-    var $portTypes = array();
4754
-    var $currentPortType;
4755
-    var $bindings = array();
4756
-    var $currentBinding;
4757
-    var $ports = array();
4758
-    var $currentPort;
4759
-    var $opData = array();
4760
-    var $status = '';
4761
-    var $documentation = false;
4762
-    var $endpoint = '';
4763
-    // array of wsdl docs to import
4764
-    var $import = array();
4765
-    // parser vars
4766
-    var $parser;
4767
-    var $position = 0;
4768
-    var $depth = 0;
4769
-    var $depth_array = array();
4770
-    // for getting wsdl
4771
-    var $proxyhost = '';
4772
-    var $proxyport = '';
4773
-    var $proxyusername = '';
4774
-    var $proxypassword = '';
4775
-    var $timeout = 0;
4776
-    var $response_timeout = 30;
4777
-    var $curl_options = array();    // User-specified cURL options
4778
-    var $use_curl = false;            // whether to always try to use cURL
4779
-    // for HTTP authentication
4780
-    var $username = '';                // Username for HTTP authentication
4781
-    var $password = '';                // Password for HTTP authentication
4782
-    var $authtype = '';                // Type of HTTP authentication
4783
-    var $certRequest = array();        // Certificate for HTTP SSL authentication
4784
-
4785
-    /** @var mixed */
4786
-    var $currentPortOperation;
4787
-    /** @var string */
4788
-    var $opStatus;
4789
-    /** @var mixed */
4790
-    var $serviceName;
4791
-    var $wsdl_info;
4792
-
4793
-    /**
4794
-     * constructor
4795
-     *
4796
-     * @param string $wsdl WSDL document URL
4797
-     * @param string $proxyhost
4798
-     * @param string $proxyport
4799
-     * @param string $proxyusername
4800
-     * @param string $proxypassword
4801
-     * @param integer $timeout set the connection timeout
4802
-     * @param integer $response_timeout set the response timeout
4803
-     * @param array $curl_options user-specified cURL options
4804
-     * @param boolean $use_curl try to use cURL
4805
-     * @access public
4806
-     */
4807
-    function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false)
4808
-    {
4809
-        parent::__construct();
4810
-        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
4811
-        $this->proxyhost = $proxyhost;
4812
-        $this->proxyport = $proxyport;
4813
-        $this->proxyusername = $proxyusername;
4814
-        $this->proxypassword = $proxypassword;
4815
-        $this->timeout = $timeout;
4816
-        $this->response_timeout = $response_timeout;
4817
-        if (is_array($curl_options)) {
4818
-            $this->curl_options = $curl_options;
4819
-        }
4820
-        $this->use_curl = $use_curl;
4821
-        $this->fetchWSDL($wsdl);
4822
-    }
4823
-
4824
-    /**
4825
-     * fetches the WSDL document and parses it
4826
-     *
4827
-     * @access public
4828
-     */
4829
-    function fetchWSDL($wsdl)
4830
-    {
4831
-        $this->debug("parse and process WSDL path=$wsdl");
4832
-        $this->wsdl = $wsdl;
4833
-        // parse wsdl file
4834
-        if ($this->wsdl != "") {
4835
-            $this->parseWSDL($this->wsdl);
4836
-        }
4837
-        // imports
4838
-        // TODO: handle imports more properly, grabbing them in-line and nesting them
4839
-        $imported_urls = array();
4840
-        $imported = 1;
4841
-        while ($imported > 0) {
4842
-            $imported = 0;
4843
-            // Schema imports
4844
-            foreach ($this->schemas as $ns => $list) {
4845
-                foreach ($list as $xsKey => $xs) {
4846
-                    $wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4847
-                    foreach ($xs->imports as $ns2 => $list2) {
4848
-                        for ($ii = 0; $ii < count($list2); $ii++) {
4849
-                            if (array_key_exists($ii, $list2) && (!isset($list2[$ii]['loaded']) || !$list2[$ii]['loaded'])) {
4850
-                                @$this->schemas[$ns][$xsKey]->imports[$ns2][$ii]['loaded'] = true;
4851
-                                $url = $list2[$ii]['location'];
4852
-                                if ($url != '') {
4853
-                                    $urlparts = parse_url($url);
4854
-                                    if (!isset($urlparts['host'])) {
4855
-                                        $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4856
-                                            substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4857
-                                    }
4858
-                                    if (!in_array($url, $imported_urls)) {
4859
-                                        $this->parseWSDL($url);
4860
-                                        $imported++;
4861
-                                        $imported_urls[] = $url;
4862
-                                    }
4863
-                                } else {
4864
-                                    $this->debug("Unexpected scenario: empty URL for unloaded import");
4865
-                                }
4866
-                            }
4867
-                        }
4868
-                    }
4869
-                }
4870
-            }
4871
-            // WSDL imports
4872
-            $wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4873
-            foreach ($this->import as $ns => $list) {
4874
-                for ($ii = 0; $ii < count($list); $ii++) {
4875
-                    if (!$list[$ii]['loaded']) {
4876
-                        $this->import[$ns][$ii]['loaded'] = true;
4877
-                        $url = $list[$ii]['location'];
4878
-                        if ($url != '') {
4879
-                            $urlparts = parse_url($url);
4880
-                            if (!isset($urlparts['host'])) {
4881
-                                $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4882
-                                    substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4883
-                            }
4884
-                            if (!in_array($url, $imported_urls)) {
4885
-                                $this->parseWSDL($url);
4886
-                                $imported++;
4887
-                                $imported_urls[] = $url;
4888
-                            }
4889
-                        } else {
4890
-                            $this->debug("Unexpected scenario: empty URL for unloaded import");
4891
-                        }
4892
-                    }
4893
-                }
4894
-            }
4895
-        }
4896
-        // add new data to operation data
4897
-        foreach ($this->bindings as $binding => $bindingData) {
4898
-            if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
4899
-                foreach ($bindingData['operations'] as $operation => $data) {
4900
-                    $this->debug('post-parse data gathering for ' . $operation);
4901
-                    $this->bindings[$binding]['operations'][$operation]['input'] =
4902
-                        isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4903
-                            array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) :
4904
-                            $this->portTypes[$bindingData['portType']][$operation]['input'];
4905
-                    $this->bindings[$binding]['operations'][$operation]['output'] =
4906
-                        isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4907
-                            array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) :
4908
-                            $this->portTypes[$bindingData['portType']][$operation]['output'];
4909
-                    if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
4910
-                        $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
4911
-                    }
4912
-                    if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
4913
-                        $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']];
4914
-                    }
4915
-                    // Set operation style if necessary, but do not override one already provided
4916
-                    if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
4917
-                        $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
4918
-                    }
4919
-                    $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
4920
-                    $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : '';
4921
-                    $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
4922
-                }
4923
-            }
4924
-        }
4925
-    }
4926
-
4927
-    /**
4928
-     * parses the wsdl document
4929
-     *
4930
-     * @param string $wsdl path or URL
4931
-     * @access private
4932
-     */
4933
-    function parseWSDL($wsdl = '')
4934
-    {
4935
-        $this->debug("parse WSDL at path=$wsdl");
4936
-
4937
-        if ($wsdl == '') {
4938
-            $this->debug('no wsdl passed to parseWSDL()!!');
4939
-            $this->setError('no wsdl passed to parseWSDL()!!');
4940
-            return false;
4941
-        }
4942
-
4943
-        // parse $wsdl for url format
4944
-        $wsdl_props = parse_url($wsdl);
4945
-
4946
-        if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
4947
-            $this->debug('getting WSDL http(s) URL ' . $wsdl);
4948
-            // get wsdl
4949
-            $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
4950
-            $tr->request_method = 'GET';
4951
-            $tr->useSOAPAction = false;
4952
-            if ($this->proxyhost && $this->proxyport) {
4953
-                $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
4954
-            }
4955
-            if ($this->authtype != '') {
4956
-                $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
4957
-            }
4958
-            $tr->setEncoding();
4959
-            $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
4960
-            //$this->debug("WSDL request\n" . $tr->outgoing_payload);
4961
-            //$this->debug("WSDL response\n" . $tr->incoming_payload);
4962
-            $this->appendDebug($tr->getDebug());
4963
-            // catch errors
4964
-            if ($err = $tr->getError()) {
4965
-                $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err;
4966
-                $this->debug($errstr);
4967
-                $this->setError($errstr);
4968
-                unset($tr);
4969
-                return false;
4970
-            }
4971
-            unset($tr);
4972
-            $this->debug("got WSDL URL");
4973
-        } else {
4974
-            // $wsdl is not http(s), so treat it as a file URL or plain file path
4975
-            if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
4976
-                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
4977
-            } else {
4978
-                $path = $wsdl;
4979
-            }
4980
-            $this->debug('getting WSDL file ' . $path);
4981
-            if ($fp = @fopen($path, 'r')) {
4982
-                $wsdl_string = '';
4983
-                while ($data = fread($fp, 32768)) {
4984
-                    $wsdl_string .= $data;
4985
-                }
4986
-                fclose($fp);
4987
-            } else {
4988
-                $errstr = "Bad path to WSDL file $path";
4989
-                $this->debug($errstr);
4990
-                $this->setError($errstr);
4991
-                return false;
4992
-            }
4993
-        }
4994
-        $this->debug('Parse WSDL');
4995
-        // end new code added
4996
-        // Create an XML parser.
4997
-        $this->parser = xml_parser_create();
4998
-        // Set the options for parsing the XML data.
4999
-        // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
5000
-        xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
5001
-        // Set the object for the parser.
5002
-        xml_set_object($this->parser, $this);
5003
-        // Set the element handlers for the parser.
5004
-        xml_set_element_handler($this->parser, 'start_element', 'end_element');
5005
-        xml_set_character_data_handler($this->parser, 'character_data');
5006
-        // Parse the XML file.
5007
-        if (!xml_parse($this->parser, $wsdl_string, true)) {
5008
-            // Display an error message.
5009
-            $errstr = sprintf(
5010
-                'XML error parsing WSDL from %s on line %d: %s',
5011
-                $wsdl,
5012
-                xml_get_current_line_number($this->parser),
5013
-                xml_error_string(xml_get_error_code($this->parser))
5014
-            );
5015
-            $this->debug($errstr);
5016
-            $this->debug("XML payload:\n" . $wsdl_string);
5017
-            $this->setError($errstr);
5018
-            xml_parser_free($this->parser);
5019
-            unset($this->parser);
5020
-            return false;
5021
-        }
5022
-        // free the parser
5023
-        xml_parser_free($this->parser);
5024
-        unset($this->parser);
5025
-        $this->debug('Parsing WSDL done');
5026
-        // catch wsdl parse errors
5027
-        if ($this->getError()) {
5028
-            return false;
5029
-        }
5030
-        return true;
5031
-    }
5032
-
5033
-    /**
5034
-     * start-element handler
5035
-     *
5036
-     * @param string $parser XML parser object
5037
-     * @param string $name element name
5038
-     * @param array $attrs associative array of attributes
5039
-     * @access private
5040
-     */
5041
-    function start_element($parser, $name, $attrs)
5042
-    {
5043
-        if ($this->status == 'schema') {
5044
-            $this->currentSchema->schemaStartElement($parser, $name, $attrs);
5045
-            $this->appendDebug($this->currentSchema->getDebug());
5046
-            $this->currentSchema->clearDebug();
5047
-        } elseif (preg_match('/schema$/', $name)) {
5048
-            $this->debug('Parsing WSDL schema');
5049
-            // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
5050
-            $this->status = 'schema';
5051
-            $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
5052
-            $this->currentSchema->schemaStartElement($parser, $name, $attrs);
5053
-            $this->appendDebug($this->currentSchema->getDebug());
5054
-            $this->currentSchema->clearDebug();
5055
-        } else {
5056
-            // position in the total number of elements, starting from 0
5057
-            $pos = $this->position++;
5058
-            $depth = $this->depth++;
5059
-            // set self as current value for this depth
5060
-            $this->depth_array[$depth] = $pos;
5061
-            $this->message[$pos] = array('cdata' => '');
5062
-            // process attributes
5063
-            if (count($attrs) > 0) {
5064
-                // register namespace declarations
5065
-                foreach ($attrs as $k => $v) {
5066
-                    if (preg_match('/^xmlns/', $k)) {
5067
-                        if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
5068
-                            $this->namespaces[$ns_prefix] = $v;
5069
-                        } else {
5070
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
5071
-                        }
5072
-                        if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
5073
-                            $this->XMLSchemaVersion = $v;
5074
-                            $this->namespaces['xsi'] = $v . '-instance';
5075
-                        }
5076
-                    }
5077
-                }
5078
-                // expand each attribute prefix to its namespace
5079
-                $eAttrs = array ();
5080
-                foreach ($attrs as $k => $v) {
5081
-                    $k = strpos($k, ':') ? $this->expandQname($k) : $k;
5082
-                    if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
5083
-                        $v = strpos($v, ':') ? $this->expandQname($v) : $v;
5084
-                    }
5085
-                    $eAttrs[$k] = $v;
5086
-                }
5087
-                $attrs = $eAttrs;
5088
-            } else {
5089
-                $attrs = array();
5090
-            }
5091
-		// Set default prefix and namespace
5092
-		// to prevent error Undefined variable $prefix and $namespace if (preg_match('/:/', $name)) return 0 or FALSE
5093
-		$prefix = '';
5094
-		$namespace = '';
5095
-            // get element prefix, namespace and name
5096
-            if (preg_match('/:/', $name)) {
5097
-                // get ns prefix
5098
-                $prefix = substr($name, 0, strpos($name, ':'));
5099
-                // get ns
5100
-                $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : '';
5101
-                // get unqualified name
5102
-                $name = substr(strstr($name, ':'), 1);
5103
-            }
5104
-            // process attributes, expanding any prefixes to namespaces
5105
-            // find status, register data
5106
-            switch ($this->status) {
5107
-                case 'message':
5108
-                    if ($name == 'part') {
5109
-                        if (isset($attrs['type'])) {
5110
-                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
5111
-                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
5112
-                        }
5113
-                        if (isset($attrs['element'])) {
5114
-                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
5115
-                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
5116
-                        }
5117
-                    }
5118
-                    break;
5119
-                case 'portType':
5120
-                    switch ($name) {
5121
-                        case 'operation':
5122
-                            $this->currentPortOperation = $attrs['name'];
5123
-                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
5124
-                            if (isset($attrs['parameterOrder'])) {
5125
-                                $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
5126
-                            }
5127
-                            break;
5128
-                        case 'documentation':
5129
-                            $this->documentation = true;
5130
-                            break;
5131
-                        // merge input/output data
5132
-                        default:
5133
-                            $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
5134
-                            $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
5135
-                            break;
5136
-                    }
5137
-                    break;
5138
-                case 'binding':
5139
-                    switch ($name) {
5140
-                        case 'binding':
5141
-                            // get ns prefix
5142
-                            if (isset($attrs['style'])) {
5143
-                                $this->bindings[$this->currentBinding]['prefix'] = $prefix;
5144
-                            }
5145
-                            $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
5146
-                            break;
5147
-                        case 'header':
5148
-                            $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
5149
-                            break;
5150
-                        case 'operation':
5151
-                            if (isset($attrs['soapAction'])) {
5152
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
5153
-                            }
5154
-                            if (isset($attrs['style'])) {
5155
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
5156
-                            }
5157
-                            if (isset($attrs['name'])) {
5158
-                                $this->currentOperation = $attrs['name'];
5159
-                                $this->debug("current binding operation: $this->currentOperation");
5160
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
5161
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
5162
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
5163
-                            }
5164
-                            break;
5165
-                        case 'input':
5166
-                            $this->opStatus = 'input';
5167
-                            break;
5168
-                        case 'output':
5169
-                            $this->opStatus = 'output';
5170
-                            break;
5171
-                        case 'body':
5172
-                            if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
5173
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
5174
-                            } else {
5175
-                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
5176
-                            }
5177
-                            break;
5178
-                    }
5179
-                    break;
5180
-                case 'service':
5181
-                    switch ($name) {
5182
-                        case 'port':
5183
-                            $this->currentPort = $attrs['name'];
5184
-                            $this->debug('current port: ' . $this->currentPort);
5185
-                            $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
5186
-
5187
-                            break;
5188
-                        case 'address':
5189
-                            $this->ports[$this->currentPort]['location'] = $attrs['location'];
5190
-                            $this->ports[$this->currentPort]['bindingType'] = $namespace;
5191
-                            $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace;
5192
-                            $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location'];
5193
-                            break;
5194
-                    }
5195
-                    break;
5196
-            }
5197
-            // set status
5198
-            switch ($name) {
5199
-                case 'import':
5200
-                    if (isset($attrs['location'])) {
5201
-                        $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
5202
-                        $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')');
5203
-                    } else {
5204
-                        $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
5205
-                        if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
5206
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
5207
-                        }
5208
-                        $this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')');
5209
-                    }
5210
-                    break;
5211
-                //wait for schema
5212
-                //case 'types':
5213
-                //	$this->status = 'schema';
5214
-                //	break;
5215
-                case 'message':
5216
-                    $this->status = 'message';
5217
-                    $this->messages[$attrs['name']] = array();
5218
-                    $this->currentMessage = $attrs['name'];
5219
-                    break;
5220
-                case 'portType':
5221
-                    $this->status = 'portType';
5222
-                    $this->portTypes[$attrs['name']] = array();
5223
-                    $this->currentPortType = $attrs['name'];
5224
-                    break;
5225
-                case "binding":
5226
-                    if (isset($attrs['name'])) {
5227
-                        // get binding name
5228
-                        if (strpos($attrs['name'], ':')) {
5229
-                            $this->currentBinding = $this->getLocalPart($attrs['name']);
5230
-                        } else {
5231
-                            $this->currentBinding = $attrs['name'];
5232
-                        }
5233
-                        $this->status = 'binding';
5234
-                        $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
5235
-                        $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
5236
-                    }
5237
-                    break;
5238
-                case 'service':
5239
-                    $this->serviceName = $attrs['name'];
5240
-                    $this->status = 'service';
5241
-                    $this->debug('current service: ' . $this->serviceName);
5242
-                    break;
5243
-                case 'definitions':
5244
-                    foreach ($attrs as $name => $value) {
5245
-                        $this->wsdl_info[$name] = $value;
5246
-                    }
5247
-                    break;
5248
-            }
5249
-        }
5250
-    }
5251
-
5252
-    /**
5253
-     * end-element handler
5254
-     *
5255
-     * @param string $parser XML parser object
5256
-     * @param string $name element name
5257
-     * @access private
5258
-     */
5259
-    function end_element($parser, $name)
5260
-    {
5261
-        // unset schema status
5262
-        if (/*preg_match('/types$/', $name) ||*/
5263
-        preg_match('/schema$/', $name)
5264
-        ) {
5265
-            $this->status = "";
5266
-            $this->appendDebug($this->currentSchema->getDebug());
5267
-            $this->currentSchema->clearDebug();
5268
-            $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
5269
-            $this->debug('Parsing WSDL schema done');
5270
-        }
5271
-        if ($this->status == 'schema') {
5272
-            $this->currentSchema->schemaEndElement($parser, $name);
5273
-        } else {
5274
-            // bring depth down a notch
5275
-            $this->depth--;
5276
-        }
5277
-        // end documentation
5278
-        if ($this->documentation) {
5279
-            //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
5280
-            //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
5281
-            $this->documentation = false;
5282
-        }
5283
-    }
5284
-
5285
-    /**
5286
-     * element content handler
5287
-     *
5288
-     * @param string $parser XML parser object
5289
-     * @param string $data element content
5290
-     * @access private
5291
-     */
5292
-    function character_data($parser, $data)
5293
-    {
5294
-        $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
5295
-        if (isset($this->message[$pos]['cdata'])) {
5296
-            $this->message[$pos]['cdata'] .= $data;
5297
-        }
5298
-        if ($this->documentation) {
5299
-            $this->documentation .= $data;
5300
-        }
5301
-    }
5302
-
5303
-    /**
5304
-     * if authenticating, set user credentials here
5305
-     *
5306
-     * @param    string $username
5307
-     * @param    string $password
5308
-     * @param    string $authtype (basic|digest|certificate|ntlm)
5309
-     * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
5310
-     * @access   public
5311
-     */
5312
-    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array())
5313
-    {
5314
-        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
5315
-        $this->appendDebug($this->varDump($certRequest));
5316
-        $this->username = $username;
5317
-        $this->password = $password;
5318
-        $this->authtype = $authtype;
5319
-        $this->certRequest = $certRequest;
5320
-    }
5321
-
5322
-    function getBindingData($binding)
5323
-    {
5324
-        if (is_array($this->bindings[$binding])) {
5325
-            return $this->bindings[$binding];
5326
-        }
5327
-        return false;
5328
-    }
5329
-
5330
-    /**
5331
-     * returns an assoc array of operation names => operation data
5332
-     *
5333
-     * @param string $portName WSDL port name
5334
-     * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
5335
-     * @return array
5336
-     * @access public
5337
-     */
5338
-    function getOperations($portName = '', $bindingType = 'soap')
5339
-    {
5340
-        $ops = array();
5341
-        if ($bindingType == 'soap') {
5342
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5343
-        } elseif ($bindingType == 'soap12') {
5344
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5345
-        } else {
5346
-            $this->debug("getOperations bindingType $bindingType may not be supported");
5347
-        }
5348
-        $this->debug("getOperations for port '$portName' bindingType $bindingType");
5349
-        // loop thru ports
5350
-        foreach ($this->ports as $port => $portData) {
5351
-            $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
5352
-            if ($portName == '' || $port == $portName) {
5353
-                // binding type of port matches parameter
5354
-                if ($portData['bindingType'] == $bindingType) {
5355
-                    $this->debug("getOperations found port $port bindingType $bindingType");
5356
-                    //$this->debug("port data: " . $this->varDump($portData));
5357
-                    //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
5358
-                    // merge bindings
5359
-                    if (isset($this->bindings[$portData['binding']]['operations'])) {
5360
-                        $ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']);
5361
-                    }
5362
-                }
5363
-            }
5364
-        }
5365
-        if (count($ops) == 0) {
5366
-            $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
5367
-        }
5368
-        return $ops;
5369
-    }
5370
-
5371
-    /**
5372
-     * returns an associative array of data necessary for calling an operation
5373
-     *
5374
-     * @param string $operation name of operation
5375
-     * @param string $bindingType type of binding eg: soap, soap12
5376
-     * @return array
5377
-     * @access public
5378
-     */
5379
-    function getOperationData($operation, $bindingType = 'soap')
5380
-    {
5381
-        if ($bindingType == 'soap') {
5382
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5383
-        } elseif ($bindingType == 'soap12') {
5384
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5385
-        }
5386
-        // loop thru ports
5387
-        foreach ($this->ports as $portData) {
5388
-            // binding type of port matches parameter
5389
-            if ($portData['bindingType'] == $bindingType) {
5390
-                // get binding
5391
-                //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
5392
-                // note that we could/should also check the namespace here
5393
-                if (in_array ($operation, array_keys ($this->bindings[$portData['binding']]['operations'])))
5394
-                {
5395
-                    return $this->bindings[$portData['binding']]['operations'][$operation];
5396
-                }
5397
-            }
5398
-        }
5399
-        return array ();
5400
-    }
5401
-
5402
-    /**
5403
-     * returns an associative array of data necessary for calling an operation
5404
-     *
5405
-     * @param string $soapAction soapAction for operation
5406
-     * @param string $bindingType type of binding eg: soap, soap12
5407
-     * @return array
5408
-     * @access public
5409
-     */
5410
-    function getOperationDataForSoapAction($soapAction, $bindingType = 'soap')
5411
-    {
5412
-        if ($bindingType == 'soap') {
5413
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
5414
-        } elseif ($bindingType == 'soap12') {
5415
-            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
5416
-        }
5417
-        // loop thru ports
5418
-        foreach ($this->ports as $portData) {
5419
-            // binding type of port matches parameter
5420
-            if ($portData['bindingType'] == $bindingType) {
5421
-                // loop through operations for the binding
5422
-                foreach ($this->bindings[$portData['binding']]['operations'] as $opData) {
5423
-                    if ($opData['soapAction'] == $soapAction) {
5424
-                        return $opData;
5425
-                    }
5426
-                }
5427
-            }
5428
-        }
5429
-        return array ();
5430
-    }
5431
-
5432
-    /**
5433
-     * returns an array of information about a given type
5434
-     * returns false if no type exists by the given name
5435
-     *     typeDef = array(
5436
-     *     'elements' => array(), // refs to elements array
5437
-     *    'restrictionBase' => '',
5438
-     *    'phpType' => '',
5439
-     *    'order' => '(sequence|all)',
5440
-     *    'attrs' => array() // refs to attributes array
5441
-     *    )
5442
-     *
5443
-     * @param string $type the type
5444
-     * @param string $ns namespace (not prefix) of the type
5445
-     * @return false
5446
-     * @access public
5447
-     * @see nusoap_xmlschema
5448
-     */
5449
-    function getTypeDef($type, $ns)
5450
-    {
5451
-        $this->debug("in getTypeDef: type=$type, ns=$ns");
5452
-        if ((!$ns) && isset($this->namespaces['tns'])) {
5453
-            $ns = $this->namespaces['tns'];
5454
-            $this->debug("in getTypeDef: type namespace forced to $ns");
5455
-        }
5456
-        if (!isset($this->schemas[$ns])) {
5457
-            foreach ($this->schemas as $ns0 => $schema0) {
5458
-                if (strcasecmp($ns, $ns0) == 0) {
5459
-                    $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
5460
-                    $ns = $ns0;
5461
-                    break;
5462
-                }
5463
-            }
5464
-        }
5465
-        if (isset($this->schemas[$ns])) {
5466
-            $this->debug("in getTypeDef: have schema for namespace $ns");
5467
-            for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
5468
-                $xs = &$this->schemas[$ns][$i];
5469
-                $t = $xs->getTypeDef($type);
5470
-                $this->appendDebug($xs->getDebug());
5471
-                $xs->clearDebug();
5472
-                if ($t) {
5473
-                    $this->debug("in getTypeDef: found type $type");
5474
-                    if (!isset($t['phpType'])) {
5475
-                        // get info for type to tack onto the element
5476
-                        $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
5477
-                        $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
5478
-                        $etype = $this->getTypeDef($uqType, $ns);
5479
-                        if ($etype) {
5480
-                            $this->debug("found type for [element] $type:");
5481
-                            $this->debug($this->varDump($etype));
5482
-                            if (isset($etype['phpType'])) {
5483
-                                $t['phpType'] = $etype['phpType'];
5484
-                            }
5485
-                            if (isset($etype['elements'])) {
5486
-                                $t['elements'] = $etype['elements'];
5487
-                            }
5488
-                            if (isset($etype['attrs'])) {
5489
-                                $t['attrs'] = $etype['attrs'];
5490
-                            }
5491
-                        } else {
5492
-                            $this->debug("did not find type for [element] $type");
5493
-                        }
5494
-                    }
5495
-                    return $t;
5496
-                }
5497
-            }
5498
-            $this->debug("in getTypeDef: did not find type $type");
5499
-        } else {
5500
-            $this->debug("in getTypeDef: do not have schema for namespace $ns");
5501
-        }
5502
-        return false;
5503
-    }
5504
-
5505
-    /**
5506
-     * prints html description of services
5507
-     *
5508
-     * @access private
5509
-     */
5510
-    function webDescription()
5511
-    {
5512
-        global $HTTP_SERVER_VARS;
5513
-
5514
-        if (isset($_SERVER)) {
5515
-            $PHP_SELF = $_SERVER['PHP_SELF'];
5516
-        } elseif (isset($HTTP_SERVER_VARS)) {
5517
-            $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
5518
-        } else {
5519
-            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
5520
-            $PHP_SELF = '';
5521
-        }
5522
-
5523
-        $b = '
5524
-		<html><head><title>NuSOAP: ' . $this->serviceName . '</title>
5525
-		<style type="text/css">
5526
-		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5527
-		    p       { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
5528
-		    pre { background-color: silver; padding: 5px; font-family: Courier New; font-size: x-small; color: #000000;}
5529
-		    ul      { margin-top: 10px; margin-left: 20px; }
5530
-		    li      { list-style-type: none; margin-top: 10px; color: #000000; }
5531
-		    .content{
5532
-			margin-left: 0px; padding-bottom: 2em; }
5533
-		    .nav {
5534
-			padding-top: 10px; padding-bottom: 10px; padding-left: 15px; font-size: .70em;
5535
-			margin-top: 10px; margin-left: 0px; color: #000000;
5536
-			background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
5537
-		    .title {
5538
-			font-family: arial; font-size: 26px; color: #ffffff;
5539
-			background-color: #999999; width: 100%;
5540
-			margin-left: 0px; margin-right: 0px;
5541
-			padding-top: 10px; padding-bottom: 10px;}
5542
-		    .hidden {
5543
-			position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
5544
-			font-family: arial; overflow: hidden; width: 600;
5545
-			padding: 20px; font-size: 10px; background-color: #999999;
5546
-			layer-background-color:#FFFFFF; }
5547
-		    a,a:active  { color: charcoal; font-weight: bold; }
5548
-		    a:visited   { color: #666666; font-weight: bold; }
5549
-		    a:hover     { color: cc3300; font-weight: bold; }
5550
-		</style>
5551
-		<script language="JavaScript" type="text/javascript">
5552
-		<!--
5553
-		// POP-UP CAPTIONS...
5554
-		function lib_bwcheck(){ //Browsercheck (needed)
5555
-		    this.ver=navigator.appVersion
5556
-		    this.agent=navigator.userAgent
5557
-		    this.dom=document.getElementById?1:0
5558
-		    this.opera5=this.agent.indexOf("Opera 5")>-1
5559
-		    this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
5560
-		    this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
5561
-		    this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
5562
-		    this.ie=this.ie4||this.ie5||this.ie6
5563
-		    this.mac=this.agent.indexOf("Mac")>-1
5564
-		    this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
5565
-		    this.ns4=(document.layers && !this.dom)?1:0;
5566
-		    this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
5567
-		    return this
6566
+		if (is_array($attrs) && count($attrs) > 0) {
6567
+			$eAttrs = array ();
6568
+			foreach ($attrs as $n => $a) {
6569
+				$aa = array ();
6570
+				// expand each attribute
6571
+				foreach ($a as $k => $v) {
6572
+					$k = strpos($k, ':') ? $this->expandQname($k) : $k;
6573
+					$v = strpos($v, ':') ? $this->expandQname($v) : $v;
6574
+					$aa[$k] = $v;
6575
+				}
6576
+				$eAttrs[$n] = $aa;
6577
+			}
6578
+			$attrs = $eAttrs;
5568 6579
 		}
5569
-		var bw = new lib_bwcheck()
5570
-		//Makes crossbrowser object.
5571
-		function makeObj(obj){
5572
-		    this.evnt=bw.dom? document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?document.layers[obj]:0;
5573
-		    if(!this.evnt) return false
5574
-		    this.css=bw.dom||bw.ie4?this.evnt.style:bw.ns4?this.evnt:0;
5575
-		    this.wref=bw.dom||bw.ie4?this.evnt:bw.ns4?this.css.document:0;
5576
-		    this.writeIt=b_writeIt;
5577
-		    return this
6580
+
6581
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
6582
+		$arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType;
6583
+
6584
+		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6585
+		$this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType);
6586
+	}
6587
+
6588
+	/**
6589
+	 * adds an XML Schema simple type to the WSDL types
6590
+	 *
6591
+	 * @param string $name
6592
+	 * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
6593
+	 * @param string $typeClass (should always be simpleType)
6594
+	 * @param string $phpType (should always be scalar)
6595
+	 * @param array $enumeration array of values
6596
+	 * @see nusoap_xmlschema
6597
+	 * @access public
6598
+	 */
6599
+	function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array())
6600
+	{
6601
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
6602
+
6603
+		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6604
+		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
6605
+	}
6606
+
6607
+	/**
6608
+	 * adds an element to the WSDL types
6609
+	 *
6610
+	 * @param array $attrs attributes that must include name and type
6611
+	 * @see nusoap_xmlschema
6612
+	 * @access public
6613
+	 */
6614
+	function addElement($attrs)
6615
+	{
6616
+		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6617
+		$this->schemas[$typens][0]->addElement($attrs);
6618
+	}
6619
+
6620
+	/**
6621
+	 * register an operation with the server
6622
+	 *
6623
+	 * @param string $name operation (method) name
6624
+	 * @param array $in assoc array of input values: key = param name, value = param type
6625
+	 * @param array $out assoc array of output values: key = param name, value = param type
6626
+	 * @param string $namespace optional The namespace for the operation
6627
+	 * @param string $soapaction optional The soapaction for the operation
6628
+	 * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
6629
+	 * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
6630
+	 * @param string $documentation optional The description to include in the WSDL
6631
+	 * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
6632
+	 * @param string $customResponseTagName optional Name of the outgoing response
6633
+	 * @access public
6634
+	 */
6635
+	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '', $customResponseTagName = '')
6636
+	{
6637
+		if ($use == 'encoded' && $encodingStyle == '') {
6638
+			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5578 6639
 		}
5579
-		// A unit of measure that will be added when setting the position of a layer.
5580
-		//var px = bw.ns4||window.opera?"":"px";
5581
-		function b_writeIt(text){
5582
-		    if (bw.ns4){this.wref.write(text);this.wref.close()}
5583
-		    else this.wref.innerHTML = text
6640
+
6641
+		if ($style == 'document') {
6642
+			$elements = array();
6643
+			foreach ($in as $n => $t) {
6644
+				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6645
+			}
6646
+			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
6647
+			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
6648
+			$in = array('parameters' => 'tns:' . $name . '^');
6649
+
6650
+			$elements = array();
6651
+			foreach ($out as $n => $t) {
6652
+				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6653
+			}
6654
+			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
6655
+			$this->addElement(array('name' => $customResponseTagName, 'type' => $name . 'ResponseType', 'form' => 'qualified'));
6656
+			$out = array('parameters' => 'tns:' . $customResponseTagName . '^');
5584 6657
 		}
5585
-		//Shows the messages
5586
-		var oDesc;
5587
-		function popup(divid){
5588
-		    if(oDesc = new makeObj(divid)){
5589
-			oDesc.css.visibility = "visible"
5590
-		    }
6658
+
6659
+		// get binding
6660
+		$this->bindings[$this->serviceName . 'Binding']['operations'][$name] =
6661
+			array(
6662
+				'name' => $name,
6663
+				'binding' => $this->serviceName . 'Binding',
6664
+				'endpoint' => $this->endpoint,
6665
+				'soapAction' => $soapaction,
6666
+				'style' => $style,
6667
+				'input' => array(
6668
+					'use' => $use,
6669
+					'namespace' => $namespace,
6670
+					'encodingStyle' => $encodingStyle,
6671
+					'message' => $name,
6672
+					'parts' => $in),
6673
+				'output' => array(
6674
+					'use' => $use,
6675
+					'namespace' => $namespace,
6676
+					'encodingStyle' => $encodingStyle,
6677
+					'message' => $customResponseTagName,
6678
+					'parts' => $out),
6679
+				'namespace' => $namespace,
6680
+				'transport' => 'http://schemas.xmlsoap.org/soap/http',
6681
+				'documentation' => $documentation);
6682
+		// add portTypes
6683
+		// add messages
6684
+		if ($in) {
6685
+			foreach ($in as $pName => $pType) {
6686
+				if (strpos($pType, ':')) {
6687
+					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6688
+				}
6689
+				$this->messages[$name][$pName] = $pType;
6690
+			}
6691
+		} else {
6692
+			$this->messages[$name] = '0';
5591 6693
 		}
5592
-		function popout(){ // Hides message
5593
-		    if(oDesc) oDesc.css.visibility = "hidden"
6694
+		if ($out) {
6695
+			foreach ($out as $pName => $pType) {
6696
+				if (strpos($pType, ':')) {
6697
+					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6698
+				}
6699
+				$this->messages[$customResponseTagName][$pName] = $pType;
6700
+			}
6701
+		} else {
6702
+			$this->messages[$customResponseTagName] = '0';
5594 6703
 		}
5595
-		//-->
5596
-		</script>
5597
-		</head>
5598
-		<body>
5599
-		<div class=content>
5600
-			<br><br>
5601
-			<div class=title>' . $this->serviceName . '</div>
5602
-			<div class=nav>
5603
-				<p>View the <a href="?wsdl">WSDL</a> for the service.
5604
-				Click on an operation name to view it&apos;s details.</p>
5605
-				<ul>';
5606
-        foreach ($this->getOperations() as $op => $data) {
5607
-            $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
5608
-            // create hidden div
5609
-            $b .= "<div id='$op' class='hidden'>
5610
-				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
5611
-            foreach ($data as $donnie => $marie) { // loop through opdata
5612
-                if ($donnie == 'input' || $donnie == 'output') { // show input/output data
5613
-                    $b .= "<font color='white'>" . ucfirst($donnie) . ':</font><br>';
5614
-                    foreach ($marie as $captain => $tenille) { // loop through data
5615
-                        if ($captain == 'parts') { // loop thru parts
5616
-                            $b .= "&nbsp;&nbsp;$captain:<br>";
5617
-                            //if(is_array($tenille)){
5618
-                            foreach ($tenille as $joanie => $chachi) {
5619
-                                $b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
5620
-                            }
5621
-                            //}
5622
-                        } else {
5623
-                            $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
5624
-                        }
5625
-                    }
5626
-                } else {
5627
-                    $b .= "<font color='white'>" . ucfirst($donnie) . ":</font> $marie<br>";
5628
-                }
5629
-            }
5630
-            $b .= '</div>';
5631
-        }
5632
-        $b .= '
5633
-				<ul>
5634
-			</div>
5635
-		</div></body></html>';
5636
-        return $b;
5637
-    }
5638
-
5639
-    /**
5640
-     * serialize the parsed wsdl
5641
-     *
5642
-     * @param mixed $debug whether to put debug=1 in endpoint URL
5643
-     * @return string serialization of WSDL
5644
-     * @access public
5645
-     */
5646
-    function serialize($debug = 0)
5647
-    {
5648
-        $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
5649
-        $xml .= "\n<definitions";
5650
-        foreach ($this->namespaces as $k => $v) {
5651
-            $xml .= " xmlns:$k=\"$v\"";
5652
-        }
5653
-        // 10.9.02 - add poulter fix for wsdl and tns declarations
5654
-        if (isset($this->namespaces['wsdl'])) {
5655
-            $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
5656
-        }
5657
-        if (isset($this->namespaces['tns'])) {
5658
-            $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
5659
-        }
5660
-        $xml .= '>';
5661
-        // imports
5662
-        if (sizeof($this->import) > 0) {
5663
-            foreach ($this->import as $ns => $list) {
5664
-                foreach ($list as $ii) {
5665
-                    if ($ii['location'] != '') {
5666
-                        $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
5667
-                    } else {
5668
-                        $xml .= '<import namespace="' . $ns . '" />';
5669
-                    }
5670
-                }
5671
-            }
5672
-        }
5673
-        // types
5674
-        if (count($this->schemas) >= 1) {
5675
-            $xml .= "\n<types>\n";
5676
-            foreach ($this->schemas as $list) {
5677
-                foreach ($list as $xs) {
5678
-                    $xml .= $xs->serializeSchema();
5679
-                }
5680
-            }
5681
-            $xml .= '</types>';
5682
-        }
5683
-        // messages
5684
-        if (count($this->messages) >= 1) {
5685
-            foreach ($this->messages as $msgName => $msgParts) {
5686
-                $xml .= "\n<message name=\"" . $msgName . '">';
5687
-                if (is_array($msgParts)) {
5688
-                    foreach ($msgParts as $partName => $partType) {
5689
-                        // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
5690
-                        if (strpos($partType, ':')) {
5691
-                            $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
5692
-                        } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
5693
-                            // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
5694
-                            $typePrefix = 'xsd';
5695
-                        } else {
5696
-                            foreach ($this->typemap as $ns => $types) {
5697
-                                if (isset($types[$partType])) {
5698
-                                    $typePrefix = $this->getPrefixFromNamespace($ns);
5699
-                                }
5700
-                            }
5701
-                            if (!isset($typePrefix)) {
5702
-                                die("$partType has no namespace!");
5703
-                            }
5704
-                        }
5705
-                        $ns = $this->getNamespaceFromPrefix($typePrefix);
5706
-                        $localPart = $this->getLocalPart($partType);
5707
-                        $typeDef = $this->getTypeDef($localPart, $ns);
5708
-                        if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
5709
-                            $elementortype = 'element';
5710
-                            if (substr($localPart, -1) == '^') {
5711
-                                $localPart = substr($localPart, 0, -1);
5712
-                            }
5713
-                        } else {
5714
-                            $elementortype = 'type';
5715
-                        }
5716
-                        $xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
5717
-                    }
5718
-                }
5719
-                $xml .= '</message>';
5720
-            }
5721
-        }
5722
-        // bindings & porttypes
5723
-        if (count($this->bindings) >= 1) {
5724
-            $binding_xml = '';
5725
-            $portType_xml = '';
5726
-            foreach ($this->bindings as $bindingName => $attrs) {
5727
-                $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
5728
-                $binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
5729
-                $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
5730
-                foreach ($attrs['operations'] as $opName => $opParts) {
5731
-                    $binding_xml .= "\n" . '  <operation name="' . $opName . '">';
5732
-                    $binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="' . $opParts['style'] . '"/>';
5733
-                    if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
5734
-                        $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
5735
-                    } else {
5736
-                        $enc_style = '';
5737
-                    }
5738
-                    $binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
5739
-                    if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
5740
-                        $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
5741
-                    } else {
5742
-                        $enc_style = '';
5743
-                    }
5744
-                    $binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
5745
-                    $binding_xml .= "\n" . '  </operation>';
5746
-                    $portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
5747
-                    if (isset($opParts['parameterOrder'])) {
5748
-                        $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
5749
-                    }
5750
-                    $portType_xml .= '>';
5751
-                    if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
5752
-                        $portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
5753
-                    }
5754
-                    $portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
5755
-                    $portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
5756
-                    $portType_xml .= "\n" . '  </operation>';
5757
-                }
5758
-                $portType_xml .= "\n" . '</portType>';
5759
-                $binding_xml .= "\n" . '</binding>';
5760
-            }
5761
-            $xml .= $portType_xml . $binding_xml;
5762
-        }
5763
-        // services
5764
-        $xml .= "\n<service name=\"" . $this->serviceName . '">';
5765
-        if (count($this->ports) >= 1) {
5766
-            foreach ($this->ports as $pName => $attrs) {
5767
-                $xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
5768
-                $xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
5769
-                $xml .= "\n" . '  </port>';
5770
-            }
5771
-        }
5772
-        $xml .= "\n" . '</service>';
5773
-        return $xml . "\n</definitions>";
5774
-    }
5775
-
5776
-    /**
5777
-     * determine whether a set of parameters are unwrapped
5778
-     * when they are expect to be wrapped, Microsoft-style.
5779
-     *
5780
-     * @param string $type the type (element name) of the wrapper
5781
-     * @param array $parameters the parameter values for the SOAP call
5782
-     * @return boolean whether they parameters are unwrapped (and should be wrapped)
5783
-     * @access private
5784
-     */
5785
-    function parametersMatchWrapped($type, $parameters)
5786
-    {
5787
-        $this->debug("in parametersMatchWrapped type=$type, parameters=");
5788
-        $this->appendDebug($this->varDump($parameters));
5789
-
5790
-        // split type into namespace:unqualified-type
5791
-        if (strpos($type, ':')) {
5792
-            $uqType = substr($type, strrpos($type, ':') + 1);
5793
-            $ns = substr($type, 0, strrpos($type, ':'));
5794
-            $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
5795
-            if ($this->getNamespaceFromPrefix($ns)) {
5796
-                $ns = $this->getNamespaceFromPrefix($ns);
5797
-                $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
5798
-            }
5799
-        } else {
5800
-            // TODO: should the type be compared to types in XSD, and the namespace
5801
-            // set to XSD if the type matches?
5802
-            $this->debug("in parametersMatchWrapped: No namespace for type $type");
5803
-            $ns = '';
5804
-            $uqType = $type;
5805
-        }
5806
-
5807
-        // get the type information
5808
-        if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
5809
-            $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
5810
-            return false;
5811
-        }
5812
-        $this->debug("in parametersMatchWrapped: found typeDef=");
5813
-        $this->appendDebug($this->varDump($typeDef));
5814
-        if (substr($uqType, -1) == '^') {
5815
-            $uqType = substr($uqType, 0, -1);
5816
-        }
5817
-        $phpType = $typeDef['phpType'];
5818
-        $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
5819
-        $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
5820
-
5821
-        // we expect a complexType or element of complexType
5822
-        if ($phpType != 'struct') {
5823
-            $this->debug("in parametersMatchWrapped: not a struct");
5824
-            return false;
5825
-        }
5826
-
5827
-        // see whether the parameter names match the elements
5828
-        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
5829
-            $elements = 0;
5830
-            $matches = 0;
5831
-            foreach ($typeDef['elements'] as $name => $attrs) {
5832
-                if (isset($parameters[$name])) {
5833
-                    $this->debug("in parametersMatchWrapped: have parameter named $name");
5834
-                    $matches++;
5835
-                } else {
5836
-                    $this->debug("in parametersMatchWrapped: do not have parameter named $name");
5837
-                }
5838
-                $elements++;
5839
-            }
5840
-
5841
-            $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
5842
-            if ($matches == 0) {
5843
-                return false;
5844
-            }
5845
-            return true;
5846
-        }
5847
-
5848
-        // since there are no elements for the type, if the user passed no
5849
-        // parameters, the parameters match wrapped.
5850
-        $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
5851
-        return count($parameters) == 0;
5852
-    }
5853
-
5854
-    /**
5855
-     * serialize PHP values according to a WSDL message definition
5856
-     * contrary to the method name, this is not limited to RPC
5857
-     *
5858
-     * TODO
5859
-     * - multi-ref serialization
5860
-     * - validate PHP values against type definitions, return errors if invalid
5861
-     *
5862
-     * @param string $operation operation name
5863
-     * @param string $direction (input|output)
5864
-     * @param mixed $parameters parameter value(s)
5865
-     * @param string $bindingType (soap|soap12)
5866
-     * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
5867
-     * @access public
5868
-     */
5869
-    function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap')
5870
-    {
5871
-        $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
5872
-        $this->appendDebug('parameters=' . $this->varDump($parameters));
5873
-
5874
-        if ($direction != 'input' && $direction != 'output') {
5875
-            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5876
-            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5877
-            return false;
5878
-        }
5879
-        if (!$opData = $this->getOperationData($operation, $bindingType)) {
5880
-            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5881
-            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5882
-            return false;
5883
-        }
5884
-        $this->debug('in serializeRPCParameters: opData:');
5885
-        $this->appendDebug($this->varDump($opData));
5886
-
5887
-        // Get encoding style for output and set to current
5888
-        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5889
-        if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
5890
-            $encodingStyle = $opData['output']['encodingStyle'];
5891
-        }
5892
-
5893
-        // set input params
5894
-        $xml = '';
5895
-        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
5896
-            $parts = &$opData[$direction]['parts'];
5897
-            $part_count = sizeof($parts);
5898
-            $style = $opData['style'];
5899
-            $use = $opData[$direction]['use'];
5900
-            $this->debug("have $part_count part(s) to serialize using $style/$use");
5901
-            if (is_array($parameters)) {
5902
-                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
5903
-                $parameter_count = count($parameters);
5904
-                $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
5905
-                // check for Microsoft-style wrapped parameters
5906
-                if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
5907
-                    $this->debug('check whether the caller has wrapped the parameters');
5908
-                    if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
5909
-                        // TODO: consider checking here for double-wrapping, when
5910
-                        // service function wraps, then NuSOAP wraps again
5911
-                        $this->debug("change simple array to associative with 'parameters' element");
5912
-                        $parameters['parameters'] = $parameters[0];
5913
-                        unset($parameters[0]);
5914
-                    }
5915
-                    if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
5916
-                        $this->debug('check whether caller\'s parameters match the wrapped ones');
5917
-                        if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
5918
-                            $this->debug('wrap the parameters for the caller');
5919
-                            $parameters = array('parameters' => $parameters);
5920
-                        }
5921
-                    }
5922
-                }
5923
-                foreach ($parts as $name => $type) {
5924
-                    $this->debug("serializing part $name of type $type");
5925
-                    // Track encoding style
5926
-                    if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
5927
-                        $encodingStyle = $opData[$direction]['encodingStyle'];
5928
-                        $enc_style = $encodingStyle;
5929
-                    } else {
5930
-                        $enc_style = false;
5931
-                    }
5932
-                    // NOTE: add error handling here
5933
-                    // if serializeType returns false, then catch global error and fault
5934
-                    if ($parametersArrayType == 'arraySimple') {
5935
-                        $p = array_shift($parameters);
5936
-                        $this->debug('calling serializeType w/indexed param');
5937
-                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
5938
-                    } elseif (isset($parameters[$name])) {
5939
-                        $this->debug('calling serializeType w/named param');
5940
-                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
5941
-                    } else {
5942
-                        // TODO: only send nillable
5943
-                        $this->debug('calling serializeType w/null param');
5944
-                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
5945
-                    }
5946
-                }
5947
-            } else {
5948
-                $this->debug('no parameters passed.');
5949
-            }
5950
-        }
5951
-        $this->debug("serializeRPCParameters returning: $xml");
5952
-        return $xml;
5953
-    }
5954
-
5955
-    /**
5956
-     * serialize a PHP value according to a WSDL message definition
5957
-     *
5958
-     * TODO
5959
-     * - multi-ref serialization
5960
-     * - validate PHP values against type definitions, return errors if invalid
5961
-     *
5962
-     * @param string $operation operation name
5963
-     * @param string $direction (input|output)
5964
-     * @param mixed $parameters parameter value(s)
5965
-     * @return false|string parameters serialized as XML or false on error (e.g. operation not found)
5966
-     * @access public
5967
-     * @deprecated
5968
-     */
5969
-    function serializeParameters($operation, $direction, $parameters)
5970
-    {
5971
-        $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
5972
-        $this->appendDebug('parameters=' . $this->varDump($parameters));
5973
-
5974
-        if ($direction != 'input' && $direction != 'output') {
5975
-            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
5976
-            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
5977
-            return false;
5978
-        }
5979
-        if (!$opData = $this->getOperationData($operation)) {
5980
-            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5981
-            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5982
-            return false;
5983
-        }
5984
-        $this->debug('opData:');
5985
-        $this->appendDebug($this->varDump($opData));
5986
-
5987
-        // Get encoding style for output and set to current
5988
-        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
5989
-        if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
5990
-            $encodingStyle = $opData['output']['encodingStyle'];
5991
-        }
5992
-
5993
-        // set input params
5994
-        $xml = '';
5995
-        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
5996
-
5997
-            $use = $opData[$direction]['use'];
5998
-            $this->debug("use=$use");
5999
-            $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
6000
-            if (is_array($parameters)) {
6001
-                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
6002
-                $this->debug('have ' . $parametersArrayType . ' parameters');
6003
-                foreach ($opData[$direction]['parts'] as $name => $type) {
6004
-                    $this->debug('serializing part "' . $name . '" of type "' . $type . '"');
6005
-                    // Track encoding style
6006
-                    if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
6007
-                        $encodingStyle = $opData[$direction]['encodingStyle'];
6008
-                        $enc_style = $encodingStyle;
6009
-                    } else {
6010
-                        $enc_style = false;
6011
-                    }
6012
-                    // NOTE: add error handling here
6013
-                    // if serializeType returns false, then catch global error and fault
6014
-                    if ($parametersArrayType == 'arraySimple') {
6015
-                        $p = array_shift($parameters);
6016
-                        $this->debug('calling serializeType w/indexed param');
6017
-                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
6018
-                    } elseif (isset($parameters[$name])) {
6019
-                        $this->debug('calling serializeType w/named param');
6020
-                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
6021
-                    } else {
6022
-                        // TODO: only send nillable
6023
-                        $this->debug('calling serializeType w/null param');
6024
-                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
6025
-                    }
6026
-                }
6027
-            } else {
6028
-                $this->debug('no parameters passed.');
6029
-            }
6030
-        }
6031
-        $this->debug("serializeParameters returning: $xml");
6032
-        return $xml;
6033
-    }
6034
-
6035
-    /**
6036
-     * serializes a PHP value according a given type definition
6037
-     *
6038
-     * @param string $name name of value (part or element)
6039
-     * @param string $type XML schema type of value (type or element)
6040
-     * @param mixed $value a native PHP value (parameter value)
6041
-     * @param string $use use for part (encoded|literal)
6042
-     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
6043
-     * @param boolean $unqualified a kludge for what should be XML namespace form handling
6044
-     * @return string value serialized as an XML string
6045
-     * @access private
6046
-     */
6047
-    function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false)
6048
-    {
6049
-        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
6050
-        $this->appendDebug("value=" . $this->varDump($value));
6051
-        if ($use == 'encoded' && $encodingStyle) {
6052
-            $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
6053
-        }
6054
-
6055
-        // if a soapval has been supplied, let its type override the WSDL
6056
-        if (is_object($value) && get_class($value) == 'soapval') {
6057
-            if ($value->type_ns) {
6058
-                $type = $value->type_ns . ':' . $value->type;
6059
-                $forceType = true;
6060
-                $this->debug("in serializeType: soapval overrides type to $type");
6061
-            } elseif ($value->type) {
6062
-                $type = $value->type;
6063
-                $forceType = true;
6064
-                $this->debug("in serializeType: soapval overrides type to $type");
6065
-            } else {
6066
-                $forceType = false;
6067
-                $this->debug("in serializeType: soapval does not override type");
6068
-            }
6069
-            $attrs = $value->attributes;
6070
-            $value = $value->value;
6071
-            $this->debug("in serializeType: soapval overrides value to $value");
6072
-            if ($attrs) {
6073
-                if (!is_array($value)) {
6074
-                    $value['!'] = $value;
6075
-                }
6076
-                foreach ($attrs as $n => $v) {
6077
-                    $value['!' . $n] = $v;
6078
-                }
6079
-                $this->debug("in serializeType: soapval provides attributes");
6080
-            }
6081
-        } else {
6082
-            $forceType = false;
6083
-        }
6084
-
6085
-        $xml = '';
6086
-        if (strpos($type, ':')) {
6087
-            $uqType = substr($type, strrpos($type, ':') + 1);
6088
-            $ns = substr($type, 0, strrpos($type, ':'));
6089
-            $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
6090
-            if ($this->getNamespaceFromPrefix($ns)) {
6091
-                $ns = $this->getNamespaceFromPrefix($ns);
6092
-                $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
6093
-            }
6094
-
6095
-            if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
6096
-                $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
6097
-                if ($unqualified && $use == 'literal') {
6098
-                    $elementNS = " xmlns=\"\"";
6099
-                } else {
6100
-                    $elementNS = '';
6101
-                }
6102
-                if (is_null($value)) {
6103
-                    if ($use == 'literal') {
6104
-                        // TODO: depends on minOccurs
6105
-                        $xml = "<$name$elementNS/>";
6106
-                    } else {
6107
-                        // TODO: depends on nillable, which should be checked before calling this method
6108
-                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6109
-                    }
6110
-                    $this->debug("in serializeType: returning: $xml");
6111
-                    return $xml;
6112
-                }
6113
-                if ($uqType == 'Array') {
6114
-                    // JBoss/Axis does this sometimes
6115
-                    return $this->serialize_val($value, $name, false, false, false, false, $use);
6116
-                }
6117
-                if ($uqType == 'boolean') {
6118
-                    if ((is_string($value) && $value == 'false') || (!$value)) {
6119
-                        $value = 'false';
6120
-                    } else {
6121
-                        $value = 'true';
6122
-                    }
6123
-                }
6124
-                if ($uqType == 'string' && gettype($value) == 'string') {
6125
-                    $value = $this->expandEntities($value);
6126
-                }
6127
-                if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
6128
-                    $value = sprintf("%.0lf", $value);
6129
-                }
6130
-                // it's a scalar
6131
-                // TODO: what about null/nil values?
6132
-                // check type isn't a custom type extending xmlschema namespace
6133
-                if (!$this->getTypeDef($uqType, $ns)) {
6134
-                    if ($use == 'literal') {
6135
-                        if ($forceType) {
6136
-                            $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6137
-                        } else {
6138
-                            $xml = "<$name$elementNS>$value</$name>";
6139
-                        }
6140
-                    } else {
6141
-                        $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6142
-                    }
6143
-                    $this->debug("in serializeType: returning: $xml");
6144
-                    return $xml;
6145
-                }
6146
-                $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
6147
-            } elseif ($ns == 'http://xml.apache.org/xml-soap') {
6148
-                $this->debug('in serializeType: appears to be Apache SOAP type');
6149
-                if ($uqType == 'Map') {
6150
-                    $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
6151
-                    if (!$tt_prefix) {
6152
-                        $this->debug('in serializeType: Add namespace for Apache SOAP type');
6153
-                        $tt_prefix = 'ns' . rand(1000, 9999);
6154
-                        $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
6155
-                        // force this to be added to usedNamespaces
6156
-                        $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
6157
-                    }
6158
-                    $contents = '';
6159
-                    foreach ($value as $k => $v) {
6160
-                        $this->debug("serializing map element: key $k, value $v");
6161
-                        $contents .= '<item>';
6162
-                        $contents .= $this->serialize_val($k, 'key', false, false, false, false, $use);
6163
-                        $contents .= $this->serialize_val($v, 'value', false, false, false, false, $use);
6164
-                        $contents .= '</item>';
6165
-                    }
6166
-                    if ($use == 'literal') {
6167
-                        if ($forceType) {
6168
-                            $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
6169
-                        } else {
6170
-                            $xml = "<$name>$contents</$name>";
6171
-                        }
6172
-                    } else {
6173
-                        $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
6174
-                    }
6175
-                    $this->debug("in serializeType: returning: $xml");
6176
-                    return $xml;
6177
-                }
6178
-                $this->debug('in serializeType: Apache SOAP type, but only support Map');
6179
-            }
6180
-        } else {
6181
-            // TODO: should the type be compared to types in XSD, and the namespace
6182
-            // set to XSD if the type matches?
6183
-            $this->debug("in serializeType: No namespace for type $type");
6184
-            $ns = '';
6185
-            $uqType = $type;
6186
-        }
6187
-        if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
6188
-            $this->setError("$type ($uqType) is not a supported type.");
6189
-            $this->debug("in serializeType: $type ($uqType) is not a supported type.");
6190
-            return false;
6191
-        } else {
6192
-            $this->debug("in serializeType: found typeDef");
6193
-            $this->appendDebug('typeDef=' . $this->varDump($typeDef));
6194
-            if (substr($uqType, -1) == '^') {
6195
-                $uqType = substr($uqType, 0, -1);
6196
-            }
6197
-        }
6198
-        if (!isset($typeDef['phpType'])) {
6199
-            $this->setError("$type ($uqType) has no phpType.");
6200
-            $this->debug("in serializeType: $type ($uqType) has no phpType.");
6201
-            return false;
6202
-        }
6203
-        $phpType = $typeDef['phpType'];
6204
-        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
6205
-        // if php type == struct, map value to the <all> element names
6206
-        if ($phpType == 'struct') {
6207
-            if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
6208
-                $elementName = $uqType;
6209
-                if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6210
-                    $elementNS = " xmlns=\"$ns\"";
6211
-                } else {
6212
-                    $elementNS = " xmlns=\"\"";
6213
-                }
6214
-            } else {
6215
-                $elementName = $name;
6216
-                if ($unqualified) {
6217
-                    $elementNS = " xmlns=\"\"";
6218
-                } else {
6219
-                    $elementNS = '';
6220
-                }
6221
-            }
6222
-            if (is_null($value)) {
6223
-                if ($use == 'literal') {
6224
-                    // TODO: depends on minOccurs and nillable
6225
-                    $xml = "<$elementName$elementNS/>";
6226
-                } else {
6227
-                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6228
-                }
6229
-                $this->debug("in serializeType: returning: $xml");
6230
-                return $xml;
6231
-            }
6232
-            if (is_object($value)) {
6233
-                $value = get_object_vars($value);
6234
-            }
6235
-            if (is_array($value)) {
6236
-                $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
6237
-                if ($use == 'literal') {
6238
-                    if ($forceType) {
6239
-                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
6240
-                    } else {
6241
-                        $xml = "<$elementName$elementNS$elementAttrs>";
6242
-                    }
6243
-                } else {
6244
-                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
6245
-                }
6246
-
6247
-                if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
6248
-                    if (isset($value['!'])) {
6249
-                        $xml .= $value['!'];
6250
-                        $this->debug("in serializeType: serialized simpleContent for type $type");
6251
-                    } else {
6252
-                        $this->debug("in serializeType: no simpleContent to serialize for type $type");
6253
-                    }
6254
-                } else {
6255
-                    // complexContent
6256
-                    $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
6257
-                }
6258
-                $xml .= "</$elementName>";
6259
-            } else {
6260
-                $this->debug("in serializeType: phpType is struct, but value is not an array");
6261
-                $this->setError("phpType is struct, but value is not an array: see debug output for details");
6262
-            }
6263
-        } elseif ($phpType == 'array') {
6264
-            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6265
-                $elementNS = " xmlns=\"$ns\"";
6266
-            } else {
6267
-                if ($unqualified) {
6268
-                    $elementNS = " xmlns=\"\"";
6269
-                } else {
6270
-                    $elementNS = '';
6271
-                }
6272
-            }
6273
-            if (is_null($value)) {
6274
-                if ($use == 'literal') {
6275
-                    // TODO: depends on minOccurs
6276
-                    $xml = "<$name$elementNS/>";
6277
-                } else {
6278
-                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
6279
-                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6280
-                        ":Array\" " .
6281
-                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6282
-                        ':arrayType="' .
6283
-                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
6284
-                        ':' .
6285
-                        $this->getLocalPart($typeDef['arrayType']) . "[0]\"/>";
6286
-                }
6287
-                $this->debug("in serializeType: returning: $xml");
6288
-                return $xml;
6289
-            }
6290
-            $cols = '';
6291
-            if (isset($typeDef['multidimensional'])) {
6292
-                $nv = array();
6293
-                foreach ($value as $v) {
6294
-                    $cols = ',' . sizeof($v);
6295
-                    $nv = array_merge($nv, $v);
6296
-                }
6297
-                $value = $nv;
6298
-            }
6299
-            if (is_array($value) && sizeof($value) >= 1) {
6300
-                $rows = sizeof($value);
6301
-                $contents = '';
6302
-                foreach ($value as $v) {
6303
-                    //$this->debug breaks when serializing ArrayOfComplexType
6304
-                    //Error: Object of class [COMPLEX-TYPE] could not be converted to string
6305
-                    //$this->debug("serializing array element: $k, " . (is_array($v) ? "array" : $v) . " of type: $typeDef[arrayType]");
6306
-                    //if (strpos($typeDef['arrayType'], ':') ) {
6307
-                    if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
6308
-                        $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
6309
-                    } else {
6310
-                        $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
6311
-                    }
6312
-                }
6313
-            } else {
6314
-                $rows = 0;
6315
-                $contents = null;
6316
-            }
6317
-            // TODO: for now, an empty value will be serialized as a zero element
6318
-            // array.  Revisit this when coding the handling of null/nil values.
6319
-            if ($use == 'literal') {
6320
-                $xml = "<$name$elementNS>"
6321
-                    . $contents
6322
-                    . "</$name>";
6323
-            } else {
6324
-                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':Array" ' .
6325
-                    $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
6326
-                    . ':arrayType="'
6327
-                    . $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
6328
-                    . ":" . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">"
6329
-                    . $contents
6330
-                    . "</$name>";
6331
-            }
6332
-        } elseif ($phpType == 'scalar') {
6333
-            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
6334
-                $elementNS = " xmlns=\"$ns\"";
6335
-            } else {
6336
-                if ($unqualified) {
6337
-                    $elementNS = " xmlns=\"\"";
6338
-                } else {
6339
-                    $elementNS = '';
6340
-                }
6341
-            }
6342
-            if ($use == 'literal') {
6343
-                if ($forceType) {
6344
-                    $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6345
-                } else {
6346
-                    $xml = "<$name$elementNS>$value</$name>";
6347
-                }
6348
-            } else {
6349
-                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6350
-            }
6351
-        }
6352
-        $this->debug("in serializeType: returning: $xml");
6353
-        return $xml;
6354
-    }
6355
-
6356
-    /**
6357
-     * serializes the attributes for a complexType
6358
-     *
6359
-     * @param array $typeDef our internal representation of an XML schema type (or element)
6360
-     * @param mixed $value a native PHP value (parameter value)
6361
-     * @param string $ns the namespace of the type
6362
-     * @param string $uqType the local part of the type
6363
-     * @return string value serialized as an XML string
6364
-     * @access private
6365
-     */
6366
-    function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType)
6367
-    {
6368
-        $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
6369
-        $xml = '';
6370
-        if (isset($typeDef['extensionBase'])) {
6371
-            $nsx = $this->getPrefix($typeDef['extensionBase']);
6372
-            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
6373
-            if ($this->getNamespaceFromPrefix($nsx)) {
6374
-                $nsx = $this->getNamespaceFromPrefix($nsx);
6375
-            }
6376
-            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
6377
-                $this->debug("serialize attributes for extension base $nsx:$uqTypex");
6378
-                $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
6379
-            } else {
6380
-                $this->debug("extension base $nsx:$uqTypex is not a supported type");
6381
-            }
6382
-        }
6383
-        if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
6384
-            $this->debug("serialize attributes for XML Schema type $ns:$uqType");
6385
-            if (is_array($value)) {
6386
-                $xvalue = $value;
6387
-            } elseif (is_object($value)) {
6388
-                $xvalue = get_object_vars($value);
6389
-            } else {
6390
-                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6391
-                $xvalue = array();
6392
-            }
6393
-            foreach ($typeDef['attrs'] as $aName => $attrs) {
6394
-                if (isset($xvalue['!' . $aName])) {
6395
-                    $xname = '!' . $aName;
6396
-                    $this->debug("value provided for attribute $aName with key $xname");
6397
-                } elseif (isset($xvalue[$aName])) {
6398
-                    $xname = $aName;
6399
-                    $this->debug("value provided for attribute $aName with key $xname");
6400
-                } elseif (isset($attrs['default'])) {
6401
-                    $xname = '!' . $aName;
6402
-                    $xvalue[$xname] = $attrs['default'];
6403
-                    $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
6404
-                } else {
6405
-                    $xname = '';
6406
-                    $this->debug("no value provided for attribute $aName");
6407
-                }
6408
-                if ($xname) {
6409
-                    $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
6410
-                }
6411
-            }
6412
-        } else {
6413
-            $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
6414
-        }
6415
-        return $xml;
6416
-    }
6417
-
6418
-    /**
6419
-     * serializes the elements for a complexType
6420
-     *
6421
-     * @param array $typeDef our internal representation of an XML schema type (or element)
6422
-     * @param mixed $value a native PHP value (parameter value)
6423
-     * @param string $ns the namespace of the type
6424
-     * @param string $uqType the local part of the type
6425
-     * @param string $use use for part (encoded|literal)
6426
-     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
6427
-     * @return string value serialized as an XML string
6428
-     * @access private
6429
-     */
6430
-    function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false)
6431
-    {
6432
-        $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
6433
-        $xml = '';
6434
-        if (isset($typeDef['extensionBase'])) {
6435
-            $nsx = $this->getPrefix($typeDef['extensionBase']);
6436
-            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
6437
-            if ($this->getNamespaceFromPrefix($nsx)) {
6438
-                $nsx = $this->getNamespaceFromPrefix($nsx);
6439
-            }
6440
-            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
6441
-                $this->debug("serialize elements for extension base $nsx:$uqTypex");
6442
-                $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
6443
-            } else {
6444
-                $this->debug("extension base $nsx:$uqTypex is not a supported type");
6445
-            }
6446
-        }
6447
-        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
6448
-            $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
6449
-            if (is_array($value)) {
6450
-                $xvalue = $value;
6451
-            } elseif (is_object($value)) {
6452
-                $xvalue = get_object_vars($value);
6453
-            } else {
6454
-                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
6455
-                $xvalue = array();
6456
-            }
6457
-            // toggle whether all elements are present - ideally should validate against schema
6458
-            if (count($typeDef['elements']) != count($xvalue)) {
6459
-                $optionals = true;
6460
-            }
6461
-            foreach ($typeDef['elements'] as $eName => $attrs) {
6462
-                if (!isset($xvalue[$eName])) {
6463
-                    if (isset($attrs['default'])) {
6464
-                        $xvalue[$eName] = $attrs['default'];
6465
-                        $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
6466
-                    }
6467
-                }
6468
-                // if user took advantage of a minOccurs=0, then only serialize named parameters
6469
-                if (isset($optionals)
6470
-                    && (!isset($xvalue[$eName]))
6471
-                    && ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
6472
-                ) {
6473
-                    if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
6474
-                        $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
6475
-                    }
6476
-                    // do nothing
6477
-                    $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
6478
-                } else {
6479
-                    // get value
6480
-                    if (isset($xvalue[$eName])) {
6481
-                        $v = $xvalue[$eName];
6482
-                    } else {
6483
-                        $v = null;
6484
-                    }
6485
-                    if (isset($attrs['form'])) {
6486
-                        $unqualified = ($attrs['form'] == 'unqualified');
6487
-                    } else {
6488
-                        $unqualified = false;
6489
-                    }
6490
-                    if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
6491
-                        $vv = $v;
6492
-                        foreach ($vv as $v) {
6493
-                            if (isset($attrs['type']) || isset($attrs['ref'])) {
6494
-                                // serialize schema-defined type
6495
-                                $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
6496
-                            } else {
6497
-                                // serialize generic type (can this ever really happen?)
6498
-                                $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6499
-                                $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
6500
-                            }
6501
-                        }
6502
-                    } else {
6503
-                        if (!is_null ($v) || !isset($attrs['minOccurs']) || $attrs['minOccurs'] != '0')
6504
-                        {
6505
-                            if (is_null ($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true')
6506
-                            {
6507
-                                // TODO: serialize a nil correctly, but for now serialize schema-defined type
6508
-                                $xml .= $this->serializeType ($eName,
6509
-                                                              isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6510
-                                                              $v, $use, $encodingStyle, $unqualified);
6511
-                            }
6512
-                            elseif (isset($attrs['type']) || isset($attrs['ref']))
6513
-                            {
6514
-                                // serialize schema-defined type
6515
-                                $xml .= $this->serializeType ($eName,
6516
-                                                              isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6517
-                                                              $v, $use, $encodingStyle, $unqualified);
6518
-                            }
6519
-                            else
6520
-                            {
6521
-                                // serialize generic type (can this ever really happen?)
6522
-                                $this->debug ("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6523
-                                $xml .= $this->serialize_val ($v, $eName, false, false, false, false, $use);
6524
-                            }
6525
-                        }
6526
-                    }
6527
-                }
6528
-            }
6529
-        } else {
6530
-            $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
6531
-        }
6532
-        return $xml;
6533
-    }
6534
-
6535
-    /**
6536
-     * adds an XML Schema complex type to the WSDL types
6537
-     *
6538
-     * @param string $name
6539
-     * @param string $typeClass (complexType|simpleType|attribute)
6540
-     * @param string $phpType currently supported are array and struct (php assoc array)
6541
-     * @param string $compositor (all|sequence|choice)
6542
-     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
6543
-     * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
6544
-     * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
6545
-     * @param string $arrayType as namespace:name (xsd:string)
6546
-     * @see nusoap_xmlschema
6547
-     * @access public
6548
-     */
6549
-    function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '')
6550
-    {
6551
-        if (count($elements) > 0) {
6552
-            $eElements = array();
6553
-            foreach ($elements as $n => $e) {
6554
-                // expand each element
6555
-                $ee = array();
6556
-                foreach ($e as $k => $v) {
6557
-                    $k = strpos($k, ':') ? $this->expandQname($k) : $k;
6558
-                    $v = strpos($v, ':') ? $this->expandQname($v) : $v;
6559
-                    $ee[$k] = $v;
6560
-                }
6561
-                $eElements[$n] = $ee;
6562
-            }
6563
-            $elements = $eElements;
6564
-        }
6565
-
6566
-        if (is_array($attrs) && count($attrs) > 0) {
6567
-            $eAttrs = array ();
6568
-            foreach ($attrs as $n => $a) {
6569
-                $aa = array ();
6570
-                // expand each attribute
6571
-                foreach ($a as $k => $v) {
6572
-                    $k = strpos($k, ':') ? $this->expandQname($k) : $k;
6573
-                    $v = strpos($v, ':') ? $this->expandQname($v) : $v;
6574
-                    $aa[$k] = $v;
6575
-                }
6576
-                $eAttrs[$n] = $aa;
6577
-            }
6578
-            $attrs = $eAttrs;
6579
-        }
6580
-
6581
-        $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
6582
-        $arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType;
6583
-
6584
-        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6585
-        $this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType);
6586
-    }
6587
-
6588
-    /**
6589
-     * adds an XML Schema simple type to the WSDL types
6590
-     *
6591
-     * @param string $name
6592
-     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
6593
-     * @param string $typeClass (should always be simpleType)
6594
-     * @param string $phpType (should always be scalar)
6595
-     * @param array $enumeration array of values
6596
-     * @see nusoap_xmlschema
6597
-     * @access public
6598
-     */
6599
-    function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array())
6600
-    {
6601
-        $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
6602
-
6603
-        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6604
-        $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
6605
-    }
6606
-
6607
-    /**
6608
-     * adds an element to the WSDL types
6609
-     *
6610
-     * @param array $attrs attributes that must include name and type
6611
-     * @see nusoap_xmlschema
6612
-     * @access public
6613
-     */
6614
-    function addElement($attrs)
6615
-    {
6616
-        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
6617
-        $this->schemas[$typens][0]->addElement($attrs);
6618
-    }
6619
-
6620
-    /**
6621
-     * register an operation with the server
6622
-     *
6623
-     * @param string $name operation (method) name
6624
-     * @param array $in assoc array of input values: key = param name, value = param type
6625
-     * @param array $out assoc array of output values: key = param name, value = param type
6626
-     * @param string $namespace optional The namespace for the operation
6627
-     * @param string $soapaction optional The soapaction for the operation
6628
-     * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically
6629
-     * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
6630
-     * @param string $documentation optional The description to include in the WSDL
6631
-     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
6632
-     * @param string $customResponseTagName optional Name of the outgoing response
6633
-     * @access public
6634
-     */
6635
-    function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '', $customResponseTagName = '')
6636
-    {
6637
-        if ($use == 'encoded' && $encodingStyle == '') {
6638
-            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
6639
-        }
6640
-
6641
-        if ($style == 'document') {
6642
-            $elements = array();
6643
-            foreach ($in as $n => $t) {
6644
-                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6645
-            }
6646
-            $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
6647
-            $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
6648
-            $in = array('parameters' => 'tns:' . $name . '^');
6649
-
6650
-            $elements = array();
6651
-            foreach ($out as $n => $t) {
6652
-                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6653
-            }
6654
-            $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
6655
-            $this->addElement(array('name' => $customResponseTagName, 'type' => $name . 'ResponseType', 'form' => 'qualified'));
6656
-            $out = array('parameters' => 'tns:' . $customResponseTagName . '^');
6657
-        }
6658
-
6659
-        // get binding
6660
-        $this->bindings[$this->serviceName . 'Binding']['operations'][$name] =
6661
-            array(
6662
-                'name' => $name,
6663
-                'binding' => $this->serviceName . 'Binding',
6664
-                'endpoint' => $this->endpoint,
6665
-                'soapAction' => $soapaction,
6666
-                'style' => $style,
6667
-                'input' => array(
6668
-                    'use' => $use,
6669
-                    'namespace' => $namespace,
6670
-                    'encodingStyle' => $encodingStyle,
6671
-                    'message' => $name,
6672
-                    'parts' => $in),
6673
-                'output' => array(
6674
-                    'use' => $use,
6675
-                    'namespace' => $namespace,
6676
-                    'encodingStyle' => $encodingStyle,
6677
-                    'message' => $customResponseTagName,
6678
-                    'parts' => $out),
6679
-                'namespace' => $namespace,
6680
-                'transport' => 'http://schemas.xmlsoap.org/soap/http',
6681
-                'documentation' => $documentation);
6682
-        // add portTypes
6683
-        // add messages
6684
-        if ($in) {
6685
-            foreach ($in as $pName => $pType) {
6686
-                if (strpos($pType, ':')) {
6687
-                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6688
-                }
6689
-                $this->messages[$name][$pName] = $pType;
6690
-            }
6691
-        } else {
6692
-            $this->messages[$name] = '0';
6693
-        }
6694
-        if ($out) {
6695
-            foreach ($out as $pName => $pType) {
6696
-                if (strpos($pType, ':')) {
6697
-                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6698
-                }
6699
-                $this->messages[$customResponseTagName][$pName] = $pType;
6700
-            }
6701
-        } else {
6702
-            $this->messages[$customResponseTagName] = '0';
6703
-        }
6704
-        return true;
6705
-    }
6704
+		return true;
6705
+	}
6706 6706
 }
6707 6707
 
6708 6708
 
@@ -6718,316 +6718,316 @@  discard block
 block discarded – undo
6718 6718
 class nusoap_parser extends nusoap_base
6719 6719
 {
6720 6720
 
6721
-    var $parser = null;
6722
-    var $methodNamespace = '';
6723
-    var $xml = '';
6724
-    var $xml_encoding = '';
6725
-    var $method = '';
6726
-    var $root_struct = '';
6727
-    var $root_struct_name = '';
6728
-    var $root_struct_namespace = '';
6729
-    var $root_header = '';
6730
-    var $document = '';            // incoming SOAP body (text)
6731
-    // determines where in the message we are (envelope,header,body,method)
6732
-    var $status = '';
6733
-    var $position = 0;
6734
-    var $depth = 0;
6735
-    var $default_namespace = '';
6736
-    var $namespaces = array();
6737
-    var $message = array();
6738
-    var $parent = '';
6739
-    var $fault = false;
6740
-    var $fault_code = '';
6741
-    var $fault_str = '';
6742
-    var $fault_detail = '';
6743
-    var $depth_array = array();
6744
-    var $debug_flag = true;
6745
-    var $soapresponse = null;    // parsed SOAP Body
6746
-    var $soapheader = null;        // parsed SOAP Header
6747
-    var $responseHeaders = '';    // incoming SOAP headers (text)
6748
-    var $body_position = 0;
6749
-    // for multiref parsing:
6750
-    // array of id => pos
6751
-    var $ids = array();
6752
-    // array of id => hrefs => pos
6753
-    var $multirefs = array();
6754
-    // toggle for auto-decoding element content
6755
-    var $decode_utf8 = true;
6756
-
6757
-    var $attachments = array();
6758
-
6759
-    /**
6760
-     * constructor that actually does the parsing
6761
-     *
6762
-     * @param    string $xml SOAP message
6763
-     * @param    string $encoding character encoding scheme of message
6764
-     * @param    string $method method for which XML is parsed (unused?)
6765
-     * @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
6766
-     * @access   public
6767
-     */
6768
-    function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true)
6769
-    {
6770
-        parent::__construct();
6771
-        $this->xml = $xml;
6772
-        $this->xml_encoding = $encoding;
6773
-        $this->method = $method;
6774
-        $this->decode_utf8 = $decode_utf8;
6775
-        $this->attachments = array();
6776
-
6777
-        // Check whether content has been read.
6778
-        if (!empty($xml)) {
6779
-            // Check XML encoding
6780
-            $pos_xml = strpos($xml, '<?xml');
6781
-            if ($pos_xml !== false) {
6782
-                $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6783
-                if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6784
-                    $xml_encoding = $res[1];
6785
-                    if (strtoupper($xml_encoding) != $encoding) {
6786
-                        $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6787
-                        $this->debug($err);
6788
-                        if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6789
-                            $this->setError($err);
6790
-                            return;
6791
-                        }
6792
-                        // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
6793
-                    } else {
6794
-                        $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6795
-                    }
6796
-                } else {
6797
-                    $this->debug('No encoding specified in XML declaration');
6798
-                }
6799
-            } else {
6800
-                $this->debug('No XML declaration');
6801
-            }
6802
-            $this->debug('Entering nusoap_parser(), length=' . strlen($xml) . ', encoding=' . $encoding);
6803
-            // Create an XML parser - why not xml_parser_create_ns?
6804
-            $this->parser = xml_parser_create($this->xml_encoding);
6805
-            // Set the options for parsing the XML data.
6806
-            //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
6807
-            xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6808
-            xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6809
-            // Set the object for the parser.
6810
-            xml_set_object($this->parser, $this);
6811
-            // Set the element handlers for the parser.
6812
-            xml_set_element_handler($this->parser, 'start_element', 'end_element');
6813
-            xml_set_character_data_handler($this->parser, 'character_data');
6814
-            $parseErrors = array();
6815
-            $chunkSize = 4096;
6816
-            for($pointer = 0; $pointer < strlen($xml) && empty($parseErrors); $pointer += $chunkSize) {
6817
-            	$xmlString = substr($xml, $pointer, $chunkSize);
6818
-            	if(!xml_parse($this->parser, $xmlString)) {
6819
-            		$parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6820
-            		$parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6821
-            	}
6822
-            }
6823
-            //Tell the script that is the end of the parsing (by setting is_final to TRUE)
6824
-            xml_parse($this->parser, '', true);
6825
-
6826
-            // Check if there is any attachment
6827
-            $this->attachments = array();
6828
-            foreach(preg_split("/((\r?\n)|(\r\n?))/", $xml) as $line){
6829
-                if(preg_match(("/^--(.*)/"), $line, $matches)) {
6830
-                    $this->attachments[] = array ();
6831
-                    $this->attachments[count($this->attachments)-1]['boundaryStr'] = $matches[1];
6832
-                } elseif(preg_match(("/Content-Type:(.*)/"), $line, $matches)) {
6833
-                    $this->attachments[count($this->attachments)-1]['Content-Type'] = $matches[1];
6834
-                } elseif(preg_match(("/Content-Id:(.*)/"), $line, $matches)) {
6835
-                    $this->attachments[count($this->attachments)-1]['Content-Id'] = $matches[1];
6836
-                } elseif(preg_match(("/Content-Transfer-Encoding:(.*)/"), $line, $matches)) {
6837
-                    $this->attachments[count($this->attachments)-1]['Content-Transfer-Encoding'] = $matches[1];
6838
-                }
6839
-            }
6840
-
6841
-            if(!empty($this->attachments)) {
6842
-                // Extract the content of each attachments
6843
-                $substrXml = $xml;
6844
-                foreach($this->attachments as $key => $attachment) {
6845
-                    $startPos = max(
6846
-                        stripos($substrXml, $attachment['boundaryStr']),
6847
-                        (array_key_exists('Content-Type', $attachment) ? stripos($substrXml, $attachment['Content-Type']) : 0),
6848
-                        (array_key_exists('Content-Id', $attachment) ? stripos($substrXml, $attachment['Content-Id']) : 0),
6849
-                        (array_key_exists('Content-Transfer-Encoding', $attachment) ? stripos($substrXml, $attachment['Content-Transfer-Encoding']) : 0)
6850
-                    );
6851
-                    $substrXml = substr($substrXml, $startPos);
6852
-                    $startPos = stripos($substrXml, PHP_EOL);
6853
-                    $substrXml = substr($substrXml, $startPos);
6854
-                    $substrXml = trim($substrXml);
6855
-                    $length = null;
6856
-                    if(array_key_exists($key+1, $this->attachments) && $this->attachments[$key+1] && !empty($this->attachments[$key+1]['boundaryStr'])) {
6857
-                        $length = stripos($substrXml, ('--' . $this->attachments[$key+1]['boundaryStr']))-1;
6858
-                    }
6859
-                    $content = substr($substrXml, 0, $length);
6860
-                    $this->attachments[$key]['content'] = $content;
6861
-                }
6862
-            }
6863
-
6864
-            if(!empty($parseErrors) && !empty($this->attachments)){
6865
-                // Search the SOAP response message
6866
-                foreach($this->attachments as $key => $attachment) {
6867
-                    // Settings for xml_parse
6868
-                    $this->parser = xml_parser_create($this->xml_encoding);
6869
-                    xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6870
-                    xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6871
-                    xml_set_object($this->parser, $this);
6872
-                    xml_set_element_handler($this->parser, 'start_element', 'end_element');
6873
-                    xml_set_character_data_handler($this->parser, 'character_data');
6874
-
6875
-                    if(!empty($attachment['content'])) {
6876
-                        $content = $attachment['content'];
6877
-                        foreach(preg_split("/((\r?\n)|(\r\n?))/", $content) as $line){
6878
-                            if(preg_match(("/:Envelope/"), $line, $matches)) {
6879
-                                if(!xml_parse($this->parser, $content, true)) {
6880
-                                    $parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6881
-                                    $parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6882
-                                } else {
6883
-                                    $parseErrors = array();
6884
-                                    unset($this->attachments[$key]);
6885
-                                    break 2;
6886
-                                }
6887
-                            }
6888
-                        }
6889
-                    }
6890
-                }
6891
-            }
6892
-
6893
-            if(!empty($parseErrors)){
6894
-            	// Display an error message.
6895
-            	$err = sprintf('XML error parsing SOAP payload on line %d: %s',
6896
-            			$parseErrors['lineNumber'],
6897
-            			$parseErrors['errorString']);
6898
-            	$this->debug($err);
6899
-            	$this->setError($err);
6900
-            } else {
6901
-                $this->debug('in nusoap_parser ctor, message:');
6902
-                $this->appendDebug($this->varDump($this->message));
6903
-                $this->debug('parsed successfully, found root struct: ' . $this->root_struct . ' of name ' . $this->root_struct_name);
6904
-                // get final value
6905
-                $this->soapresponse = $this->message[$this->root_struct]['result'];
6906
-                // get header value
6907
-                if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
6908
-                    $this->soapheader = $this->message[$this->root_header]['result'];
6909
-                }
6910
-                // resolve hrefs/ids
6911
-                if (sizeof($this->multirefs) > 0) {
6912
-                    foreach ($this->multirefs as $id => $hrefs) {
6913
-                        $this->debug('resolving multirefs for id: ' . $id);
6914
-                        $idVal = $this->buildVal($this->ids[$id]);
6915
-                        if (is_array($idVal) && isset($idVal['!id'])) {
6916
-                            unset($idVal['!id']);
6917
-                        }
6918
-                        foreach ($hrefs as $refPos => $ref) {
6919
-                            $this->debug('resolving href at pos ' . $refPos);
6920
-                            $this->multirefs[$id][$refPos] = $idVal;
6921
-                        }
6922
-                    }
6923
-                }
6924
-            }
6925
-            xml_parser_free($this->parser);
6926
-            unset($this->parser);
6927
-        } else {
6928
-            $this->debug('xml was empty, didn\'t parse!');
6929
-            $this->setError('xml was empty, didn\'t parse!');
6930
-        }
6931
-    }
6932
-
6933
-    /**
6934
-     * start-element handler
6935
-     *
6936
-     * @param    resource $parser XML parser object
6937
-     * @param    string $name element name
6938
-     * @param    array $attrs associative array of attributes
6939
-     * @access   private
6940
-     */
6941
-    function start_element($parser, $name, $attrs)
6942
-    {
6943
-        // position in a total number of elements, starting from 0
6944
-        // update class level pos
6945
-        $pos = $this->position++;
6946
-        // and set mine
6947
-        $this->message[$pos] = array('pos' => $pos, 'children' => '', 'cdata' => '');
6948
-        // depth = how many levels removed from root?
6949
-        // set mine as current global depth and increment global depth value
6950
-        $this->message[$pos]['depth'] = $this->depth++;
6951
-
6952
-        // else add self as child to whoever the current parent is
6953
-        if ($pos != 0) {
6954
-            $this->message[$this->parent]['children'] .= '|' . $pos;
6955
-        }
6956
-        // set my parent
6957
-        $this->message[$pos]['parent'] = $this->parent;
6958
-        // set self as current parent
6959
-        $this->parent = $pos;
6960
-        // set self as current value for this depth
6961
-        $this->depth_array[$this->depth] = $pos;
6962
-        // get element prefix
6963
-        if (strpos($name, ':')) {
6964
-            // get ns prefix
6965
-            $prefix = substr($name, 0, strpos($name, ':'));
6966
-            // get unqualified name
6967
-            $name = substr(strstr($name, ':'), 1);
6968
-        }
6969
-        // set status
6970
-        if ($name == 'Envelope' && $this->status == '') {
6971
-            $this->status = 'envelope';
6972
-        } elseif ($name == 'Header' && $this->status == 'envelope') {
6973
-            $this->root_header = $pos;
6974
-            $this->status = 'header';
6975
-        } elseif ($name == 'Body' && $this->status == 'envelope') {
6976
-            $this->status = 'body';
6977
-            $this->body_position = $pos;
6978
-            // set method
6979
-        } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) {
6980
-            $this->status = 'method';
6981
-            $this->root_struct_name = $name;
6982
-            $this->root_struct = $pos;
6983
-            $this->message[$pos]['type'] = 'struct';
6984
-            $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6985
-        }
6986
-        // set my status
6987
-        $this->message[$pos]['status'] = $this->status;
6988
-        // set name
6989
-        $this->message[$pos]['name'] = htmlspecialchars($name);
6990
-        // set attrs
6991
-        $this->message[$pos]['attrs'] = $attrs;
6992
-
6993
-        // loop through atts, logging ns and type declarations
6994
-        $attstr = '';
6995
-        foreach ($attrs as $key => $value) {
6996
-            $key_prefix = $this->getPrefix($key);
6997
-            $key_localpart = $this->getLocalPart($key);
6998
-            // if ns declarations, add to class level array of valid namespaces
6999
-            if ($key_prefix == 'xmlns') {
7000
-                if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
7001
-                    $this->XMLSchemaVersion = $value;
7002
-                    $this->namespaces['xsd'] = $this->XMLSchemaVersion;
7003
-                    $this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
7004
-                }
7005
-                $this->namespaces[$key_localpart] = $value;
7006
-                // set method namespace
7007
-                if ($name == $this->root_struct_name) {
7008
-                    $this->methodNamespace = $value;
7009
-                }
7010
-                // if it's a type declaration, set type
7011
-            } elseif ($key_localpart == 'type') {
7012
-                if (!isset($this->message[$pos]['type']) || $this->message[$pos]['type'] != 'array')
7013
-                {
7014
-                    $value_prefix = $this->getPrefix ($value);
7015
-                    $value_localpart = $this->getLocalPart ($value);
7016
-                    $this->message[$pos]['type'] = $value_localpart;
7017
-                    $this->message[$pos]['typePrefix'] = $value_prefix;
7018
-                    if (isset($this->namespaces[$value_prefix]))
7019
-                    {
7020
-                        $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
7021
-                    }
7022
-                    elseif (isset($attrs['xmlns:' . $value_prefix]))
7023
-                    {
7024
-                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
7025
-                    }
7026
-                    // should do something here with the namespace of specified type?
7027
-                }
7028
-            } elseif ($key_localpart == 'arrayType') {
7029
-                $this->message[$pos]['type'] = 'array';
7030
-                /* do arrayType ereg here
6721
+	var $parser = null;
6722
+	var $methodNamespace = '';
6723
+	var $xml = '';
6724
+	var $xml_encoding = '';
6725
+	var $method = '';
6726
+	var $root_struct = '';
6727
+	var $root_struct_name = '';
6728
+	var $root_struct_namespace = '';
6729
+	var $root_header = '';
6730
+	var $document = '';            // incoming SOAP body (text)
6731
+	// determines where in the message we are (envelope,header,body,method)
6732
+	var $status = '';
6733
+	var $position = 0;
6734
+	var $depth = 0;
6735
+	var $default_namespace = '';
6736
+	var $namespaces = array();
6737
+	var $message = array();
6738
+	var $parent = '';
6739
+	var $fault = false;
6740
+	var $fault_code = '';
6741
+	var $fault_str = '';
6742
+	var $fault_detail = '';
6743
+	var $depth_array = array();
6744
+	var $debug_flag = true;
6745
+	var $soapresponse = null;    // parsed SOAP Body
6746
+	var $soapheader = null;        // parsed SOAP Header
6747
+	var $responseHeaders = '';    // incoming SOAP headers (text)
6748
+	var $body_position = 0;
6749
+	// for multiref parsing:
6750
+	// array of id => pos
6751
+	var $ids = array();
6752
+	// array of id => hrefs => pos
6753
+	var $multirefs = array();
6754
+	// toggle for auto-decoding element content
6755
+	var $decode_utf8 = true;
6756
+
6757
+	var $attachments = array();
6758
+
6759
+	/**
6760
+	 * constructor that actually does the parsing
6761
+	 *
6762
+	 * @param    string $xml SOAP message
6763
+	 * @param    string $encoding character encoding scheme of message
6764
+	 * @param    string $method method for which XML is parsed (unused?)
6765
+	 * @param    string $decode_utf8 whether to decode UTF-8 to ISO-8859-1
6766
+	 * @access   public
6767
+	 */
6768
+	function __construct($xml, $encoding = 'UTF-8', $method = '', $decode_utf8 = true)
6769
+	{
6770
+		parent::__construct();
6771
+		$this->xml = $xml;
6772
+		$this->xml_encoding = $encoding;
6773
+		$this->method = $method;
6774
+		$this->decode_utf8 = $decode_utf8;
6775
+		$this->attachments = array();
6776
+
6777
+		// Check whether content has been read.
6778
+		if (!empty($xml)) {
6779
+			// Check XML encoding
6780
+			$pos_xml = strpos($xml, '<?xml');
6781
+			if ($pos_xml !== false) {
6782
+				$xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6783
+				if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6784
+					$xml_encoding = $res[1];
6785
+					if (strtoupper($xml_encoding) != $encoding) {
6786
+						$err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6787
+						$this->debug($err);
6788
+						if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6789
+							$this->setError($err);
6790
+							return;
6791
+						}
6792
+						// when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
6793
+					} else {
6794
+						$this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6795
+					}
6796
+				} else {
6797
+					$this->debug('No encoding specified in XML declaration');
6798
+				}
6799
+			} else {
6800
+				$this->debug('No XML declaration');
6801
+			}
6802
+			$this->debug('Entering nusoap_parser(), length=' . strlen($xml) . ', encoding=' . $encoding);
6803
+			// Create an XML parser - why not xml_parser_create_ns?
6804
+			$this->parser = xml_parser_create($this->xml_encoding);
6805
+			// Set the options for parsing the XML data.
6806
+			//xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
6807
+			xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6808
+			xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6809
+			// Set the object for the parser.
6810
+			xml_set_object($this->parser, $this);
6811
+			// Set the element handlers for the parser.
6812
+			xml_set_element_handler($this->parser, 'start_element', 'end_element');
6813
+			xml_set_character_data_handler($this->parser, 'character_data');
6814
+			$parseErrors = array();
6815
+			$chunkSize = 4096;
6816
+			for($pointer = 0; $pointer < strlen($xml) && empty($parseErrors); $pointer += $chunkSize) {
6817
+				$xmlString = substr($xml, $pointer, $chunkSize);
6818
+				if(!xml_parse($this->parser, $xmlString)) {
6819
+					$parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6820
+					$parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6821
+				}
6822
+			}
6823
+			//Tell the script that is the end of the parsing (by setting is_final to TRUE)
6824
+			xml_parse($this->parser, '', true);
6825
+
6826
+			// Check if there is any attachment
6827
+			$this->attachments = array();
6828
+			foreach(preg_split("/((\r?\n)|(\r\n?))/", $xml) as $line){
6829
+				if(preg_match(("/^--(.*)/"), $line, $matches)) {
6830
+					$this->attachments[] = array ();
6831
+					$this->attachments[count($this->attachments)-1]['boundaryStr'] = $matches[1];
6832
+				} elseif(preg_match(("/Content-Type:(.*)/"), $line, $matches)) {
6833
+					$this->attachments[count($this->attachments)-1]['Content-Type'] = $matches[1];
6834
+				} elseif(preg_match(("/Content-Id:(.*)/"), $line, $matches)) {
6835
+					$this->attachments[count($this->attachments)-1]['Content-Id'] = $matches[1];
6836
+				} elseif(preg_match(("/Content-Transfer-Encoding:(.*)/"), $line, $matches)) {
6837
+					$this->attachments[count($this->attachments)-1]['Content-Transfer-Encoding'] = $matches[1];
6838
+				}
6839
+			}
6840
+
6841
+			if(!empty($this->attachments)) {
6842
+				// Extract the content of each attachments
6843
+				$substrXml = $xml;
6844
+				foreach($this->attachments as $key => $attachment) {
6845
+					$startPos = max(
6846
+						stripos($substrXml, $attachment['boundaryStr']),
6847
+						(array_key_exists('Content-Type', $attachment) ? stripos($substrXml, $attachment['Content-Type']) : 0),
6848
+						(array_key_exists('Content-Id', $attachment) ? stripos($substrXml, $attachment['Content-Id']) : 0),
6849
+						(array_key_exists('Content-Transfer-Encoding', $attachment) ? stripos($substrXml, $attachment['Content-Transfer-Encoding']) : 0)
6850
+					);
6851
+					$substrXml = substr($substrXml, $startPos);
6852
+					$startPos = stripos($substrXml, PHP_EOL);
6853
+					$substrXml = substr($substrXml, $startPos);
6854
+					$substrXml = trim($substrXml);
6855
+					$length = null;
6856
+					if(array_key_exists($key+1, $this->attachments) && $this->attachments[$key+1] && !empty($this->attachments[$key+1]['boundaryStr'])) {
6857
+						$length = stripos($substrXml, ('--' . $this->attachments[$key+1]['boundaryStr']))-1;
6858
+					}
6859
+					$content = substr($substrXml, 0, $length);
6860
+					$this->attachments[$key]['content'] = $content;
6861
+				}
6862
+			}
6863
+
6864
+			if(!empty($parseErrors) && !empty($this->attachments)){
6865
+				// Search the SOAP response message
6866
+				foreach($this->attachments as $key => $attachment) {
6867
+					// Settings for xml_parse
6868
+					$this->parser = xml_parser_create($this->xml_encoding);
6869
+					xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6870
+					xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6871
+					xml_set_object($this->parser, $this);
6872
+					xml_set_element_handler($this->parser, 'start_element', 'end_element');
6873
+					xml_set_character_data_handler($this->parser, 'character_data');
6874
+
6875
+					if(!empty($attachment['content'])) {
6876
+						$content = $attachment['content'];
6877
+						foreach(preg_split("/((\r?\n)|(\r\n?))/", $content) as $line){
6878
+							if(preg_match(("/:Envelope/"), $line, $matches)) {
6879
+								if(!xml_parse($this->parser, $content, true)) {
6880
+									$parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6881
+									$parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6882
+								} else {
6883
+									$parseErrors = array();
6884
+									unset($this->attachments[$key]);
6885
+									break 2;
6886
+								}
6887
+							}
6888
+						}
6889
+					}
6890
+				}
6891
+			}
6892
+
6893
+			if(!empty($parseErrors)){
6894
+				// Display an error message.
6895
+				$err = sprintf('XML error parsing SOAP payload on line %d: %s',
6896
+						$parseErrors['lineNumber'],
6897
+						$parseErrors['errorString']);
6898
+				$this->debug($err);
6899
+				$this->setError($err);
6900
+			} else {
6901
+				$this->debug('in nusoap_parser ctor, message:');
6902
+				$this->appendDebug($this->varDump($this->message));
6903
+				$this->debug('parsed successfully, found root struct: ' . $this->root_struct . ' of name ' . $this->root_struct_name);
6904
+				// get final value
6905
+				$this->soapresponse = $this->message[$this->root_struct]['result'];
6906
+				// get header value
6907
+				if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
6908
+					$this->soapheader = $this->message[$this->root_header]['result'];
6909
+				}
6910
+				// resolve hrefs/ids
6911
+				if (sizeof($this->multirefs) > 0) {
6912
+					foreach ($this->multirefs as $id => $hrefs) {
6913
+						$this->debug('resolving multirefs for id: ' . $id);
6914
+						$idVal = $this->buildVal($this->ids[$id]);
6915
+						if (is_array($idVal) && isset($idVal['!id'])) {
6916
+							unset($idVal['!id']);
6917
+						}
6918
+						foreach ($hrefs as $refPos => $ref) {
6919
+							$this->debug('resolving href at pos ' . $refPos);
6920
+							$this->multirefs[$id][$refPos] = $idVal;
6921
+						}
6922
+					}
6923
+				}
6924
+			}
6925
+			xml_parser_free($this->parser);
6926
+			unset($this->parser);
6927
+		} else {
6928
+			$this->debug('xml was empty, didn\'t parse!');
6929
+			$this->setError('xml was empty, didn\'t parse!');
6930
+		}
6931
+	}
6932
+
6933
+	/**
6934
+	 * start-element handler
6935
+	 *
6936
+	 * @param    resource $parser XML parser object
6937
+	 * @param    string $name element name
6938
+	 * @param    array $attrs associative array of attributes
6939
+	 * @access   private
6940
+	 */
6941
+	function start_element($parser, $name, $attrs)
6942
+	{
6943
+		// position in a total number of elements, starting from 0
6944
+		// update class level pos
6945
+		$pos = $this->position++;
6946
+		// and set mine
6947
+		$this->message[$pos] = array('pos' => $pos, 'children' => '', 'cdata' => '');
6948
+		// depth = how many levels removed from root?
6949
+		// set mine as current global depth and increment global depth value
6950
+		$this->message[$pos]['depth'] = $this->depth++;
6951
+
6952
+		// else add self as child to whoever the current parent is
6953
+		if ($pos != 0) {
6954
+			$this->message[$this->parent]['children'] .= '|' . $pos;
6955
+		}
6956
+		// set my parent
6957
+		$this->message[$pos]['parent'] = $this->parent;
6958
+		// set self as current parent
6959
+		$this->parent = $pos;
6960
+		// set self as current value for this depth
6961
+		$this->depth_array[$this->depth] = $pos;
6962
+		// get element prefix
6963
+		if (strpos($name, ':')) {
6964
+			// get ns prefix
6965
+			$prefix = substr($name, 0, strpos($name, ':'));
6966
+			// get unqualified name
6967
+			$name = substr(strstr($name, ':'), 1);
6968
+		}
6969
+		// set status
6970
+		if ($name == 'Envelope' && $this->status == '') {
6971
+			$this->status = 'envelope';
6972
+		} elseif ($name == 'Header' && $this->status == 'envelope') {
6973
+			$this->root_header = $pos;
6974
+			$this->status = 'header';
6975
+		} elseif ($name == 'Body' && $this->status == 'envelope') {
6976
+			$this->status = 'body';
6977
+			$this->body_position = $pos;
6978
+			// set method
6979
+		} elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) {
6980
+			$this->status = 'method';
6981
+			$this->root_struct_name = $name;
6982
+			$this->root_struct = $pos;
6983
+			$this->message[$pos]['type'] = 'struct';
6984
+			$this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6985
+		}
6986
+		// set my status
6987
+		$this->message[$pos]['status'] = $this->status;
6988
+		// set name
6989
+		$this->message[$pos]['name'] = htmlspecialchars($name);
6990
+		// set attrs
6991
+		$this->message[$pos]['attrs'] = $attrs;
6992
+
6993
+		// loop through atts, logging ns and type declarations
6994
+		$attstr = '';
6995
+		foreach ($attrs as $key => $value) {
6996
+			$key_prefix = $this->getPrefix($key);
6997
+			$key_localpart = $this->getLocalPart($key);
6998
+			// if ns declarations, add to class level array of valid namespaces
6999
+			if ($key_prefix == 'xmlns') {
7000
+				if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
7001
+					$this->XMLSchemaVersion = $value;
7002
+					$this->namespaces['xsd'] = $this->XMLSchemaVersion;
7003
+					$this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
7004
+				}
7005
+				$this->namespaces[$key_localpart] = $value;
7006
+				// set method namespace
7007
+				if ($name == $this->root_struct_name) {
7008
+					$this->methodNamespace = $value;
7009
+				}
7010
+				// if it's a type declaration, set type
7011
+			} elseif ($key_localpart == 'type') {
7012
+				if (!isset($this->message[$pos]['type']) || $this->message[$pos]['type'] != 'array')
7013
+				{
7014
+					$value_prefix = $this->getPrefix ($value);
7015
+					$value_localpart = $this->getLocalPart ($value);
7016
+					$this->message[$pos]['type'] = $value_localpart;
7017
+					$this->message[$pos]['typePrefix'] = $value_prefix;
7018
+					if (isset($this->namespaces[$value_prefix]))
7019
+					{
7020
+						$this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
7021
+					}
7022
+					elseif (isset($attrs['xmlns:' . $value_prefix]))
7023
+					{
7024
+						$this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
7025
+					}
7026
+					// should do something here with the namespace of specified type?
7027
+				}
7028
+			} elseif ($key_localpart == 'arrayType') {
7029
+				$this->message[$pos]['type'] = 'array';
7030
+				/* do arrayType ereg here
7031 7031
 				[1]    arrayTypeValue    ::=    atype asize
7032 7032
 				[2]    atype    ::=    QName rank*
7033 7033
 				[3]    rank    ::=    '[' (',')* ']'
@@ -7035,402 +7035,402 @@  discard block
 block discarded – undo
7035 7035
 				[5]    length    ::=    nextDimension* Digit+
7036 7036
 				[6]    nextDimension    ::=    Digit+ ','
7037 7037
 				*/
7038
-                $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
7039
-                if (preg_match($expr, $value, $regs)) {
7040
-                    $this->message[$pos]['typePrefix'] = $regs[1];
7041
-                    $this->message[$pos]['arrayTypePrefix'] = $regs[1];
7042
-                    if (isset($this->namespaces[$regs[1]])) {
7043
-                        $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
7044
-                    } elseif (isset($attrs['xmlns:' . $regs[1]])) {
7045
-                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
7046
-                    }
7047
-                    $this->message[$pos]['arrayType'] = $regs[2];
7048
-                    $this->message[$pos]['arraySize'] = $regs[3];
7049
-                    $this->message[$pos]['arrayCols'] = $regs[4];
7050
-                }
7051
-                // specifies nil value (or not)
7052
-            } elseif ($key_localpart == 'nil') {
7053
-                $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
7054
-                // some other attribute
7055
-            } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
7056
-                $this->message[$pos]['xattrs']['!' . $key] = $value;
7057
-            }
7058
-
7059
-            if ($key == 'xmlns') {
7060
-                $this->default_namespace = $value;
7061
-            }
7062
-            // log id
7063
-            if ($key == 'id') {
7064
-                $this->ids[$value] = $pos;
7065
-            }
7066
-            // root
7067
-            if ($key_localpart == 'root' && $value == 1) {
7068
-                $this->status = 'method';
7069
-                $this->root_struct_name = $name;
7070
-                $this->root_struct = $pos;
7071
-                $this->debug("found root struct $this->root_struct_name, pos $pos");
7072
-            }
7073
-            // for doclit
7074
-            $attstr .= " $key=\"$value\"";
7075
-        }
7076
-        // get namespace - must be done after namespace atts are processed
7077
-        if (isset($prefix)) {
7078
-            $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
7079
-            $this->default_namespace = $this->namespaces[$prefix];
7080
-        } else {
7081
-            $this->message[$pos]['namespace'] = $this->default_namespace;
7082
-        }
7083
-        if ($this->status == 'header') {
7084
-            if ($this->root_header != $pos) {
7085
-                $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7086
-            }
7087
-        } elseif ($this->root_struct_name != '') {
7088
-            $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7089
-        }
7090
-    }
7091
-
7092
-    /**
7093
-     * end-element handler
7094
-     *
7095
-     * @param    resource $parser XML parser object
7096
-     * @param    string $name element name
7097
-     * @access   private
7098
-     */
7099
-    function end_element($parser, $name)
7100
-    {
7101
-        // position of current element is equal to the last value left in depth_array for my depth
7102
-        $pos = $this->depth_array[$this->depth--];
7103
-
7104
-        // get element prefix
7105
-        if (strpos($name, ':')) {
7106
-            // get ns prefix
7107
-            $prefix = substr($name, 0, strpos($name, ':'));
7108
-            // get unqualified name
7109
-            $name = substr(strstr($name, ':'), 1);
7110
-        }
7111
-
7112
-        // build to native type
7113
-        if (isset($this->body_position) && $pos > $this->body_position) {
7114
-            // deal w/ multirefs
7115
-            if (isset($this->message[$pos]['attrs']['href'])) {
7116
-                // get id
7117
-                $id = substr($this->message[$pos]['attrs']['href'], 1);
7118
-                // add placeholder to href array
7119
-                $this->multirefs[$id][$pos] = 'placeholder';
7120
-                // add set a reference to it as the result value
7121
-                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
7122
-                // build complexType values
7123
-            } elseif ($this->message[$pos]['children'] != '') {
7124
-                // if result has already been generated (struct/array)
7125
-                if (!isset($this->message[$pos]['result'])) {
7126
-                    $this->message[$pos]['result'] = $this->buildVal($pos);
7127
-                }
7128
-                // build complexType values of attributes and possibly simpleContent
7129
-            } elseif (isset($this->message[$pos]['xattrs'])) {
7130
-                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
7131
-                    $this->message[$pos]['xattrs']['!'] = null;
7132
-                } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7133
-                    if (isset($this->message[$pos]['type'])) {
7134
-                        $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7135
-                    } else {
7136
-                        $parent = $this->message[$pos]['parent'];
7137
-                        if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7138
-                            $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7139
-                        } else {
7140
-                            $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
7141
-                        }
7142
-                    }
7143
-                }
7144
-                $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
7145
-                // set value of simpleType (or nil complexType)
7146
-            } else {
7147
-                //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
7148
-                if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
7149
-                    $this->message[$pos]['xattrs']['!'] = null;
7150
-                } elseif (isset($this->message[$pos]['type'])) {
7151
-                    $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7152
-                } else {
7153
-                    $parent = $this->message[$pos]['parent'];
7154
-                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7155
-                        $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7156
-                    } else {
7157
-                        $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
7158
-                    }
7159
-                }
7160
-
7161
-                /* add value to parent's result, if parent is struct/array
7038
+				$expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
7039
+				if (preg_match($expr, $value, $regs)) {
7040
+					$this->message[$pos]['typePrefix'] = $regs[1];
7041
+					$this->message[$pos]['arrayTypePrefix'] = $regs[1];
7042
+					if (isset($this->namespaces[$regs[1]])) {
7043
+						$this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
7044
+					} elseif (isset($attrs['xmlns:' . $regs[1]])) {
7045
+						$this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
7046
+					}
7047
+					$this->message[$pos]['arrayType'] = $regs[2];
7048
+					$this->message[$pos]['arraySize'] = $regs[3];
7049
+					$this->message[$pos]['arrayCols'] = $regs[4];
7050
+				}
7051
+				// specifies nil value (or not)
7052
+			} elseif ($key_localpart == 'nil') {
7053
+				$this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
7054
+				// some other attribute
7055
+			} elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
7056
+				$this->message[$pos]['xattrs']['!' . $key] = $value;
7057
+			}
7058
+
7059
+			if ($key == 'xmlns') {
7060
+				$this->default_namespace = $value;
7061
+			}
7062
+			// log id
7063
+			if ($key == 'id') {
7064
+				$this->ids[$value] = $pos;
7065
+			}
7066
+			// root
7067
+			if ($key_localpart == 'root' && $value == 1) {
7068
+				$this->status = 'method';
7069
+				$this->root_struct_name = $name;
7070
+				$this->root_struct = $pos;
7071
+				$this->debug("found root struct $this->root_struct_name, pos $pos");
7072
+			}
7073
+			// for doclit
7074
+			$attstr .= " $key=\"$value\"";
7075
+		}
7076
+		// get namespace - must be done after namespace atts are processed
7077
+		if (isset($prefix)) {
7078
+			$this->message[$pos]['namespace'] = $this->namespaces[$prefix];
7079
+			$this->default_namespace = $this->namespaces[$prefix];
7080
+		} else {
7081
+			$this->message[$pos]['namespace'] = $this->default_namespace;
7082
+		}
7083
+		if ($this->status == 'header') {
7084
+			if ($this->root_header != $pos) {
7085
+				$this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7086
+			}
7087
+		} elseif ($this->root_struct_name != '') {
7088
+			$this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7089
+		}
7090
+	}
7091
+
7092
+	/**
7093
+	 * end-element handler
7094
+	 *
7095
+	 * @param    resource $parser XML parser object
7096
+	 * @param    string $name element name
7097
+	 * @access   private
7098
+	 */
7099
+	function end_element($parser, $name)
7100
+	{
7101
+		// position of current element is equal to the last value left in depth_array for my depth
7102
+		$pos = $this->depth_array[$this->depth--];
7103
+
7104
+		// get element prefix
7105
+		if (strpos($name, ':')) {
7106
+			// get ns prefix
7107
+			$prefix = substr($name, 0, strpos($name, ':'));
7108
+			// get unqualified name
7109
+			$name = substr(strstr($name, ':'), 1);
7110
+		}
7111
+
7112
+		// build to native type
7113
+		if (isset($this->body_position) && $pos > $this->body_position) {
7114
+			// deal w/ multirefs
7115
+			if (isset($this->message[$pos]['attrs']['href'])) {
7116
+				// get id
7117
+				$id = substr($this->message[$pos]['attrs']['href'], 1);
7118
+				// add placeholder to href array
7119
+				$this->multirefs[$id][$pos] = 'placeholder';
7120
+				// add set a reference to it as the result value
7121
+				$this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
7122
+				// build complexType values
7123
+			} elseif ($this->message[$pos]['children'] != '') {
7124
+				// if result has already been generated (struct/array)
7125
+				if (!isset($this->message[$pos]['result'])) {
7126
+					$this->message[$pos]['result'] = $this->buildVal($pos);
7127
+				}
7128
+				// build complexType values of attributes and possibly simpleContent
7129
+			} elseif (isset($this->message[$pos]['xattrs'])) {
7130
+				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
7131
+					$this->message[$pos]['xattrs']['!'] = null;
7132
+				} elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7133
+					if (isset($this->message[$pos]['type'])) {
7134
+						$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7135
+					} else {
7136
+						$parent = $this->message[$pos]['parent'];
7137
+						if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7138
+							$this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7139
+						} else {
7140
+							$this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
7141
+						}
7142
+					}
7143
+				}
7144
+				$this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
7145
+				// set value of simpleType (or nil complexType)
7146
+			} else {
7147
+				//$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
7148
+				if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
7149
+					$this->message[$pos]['xattrs']['!'] = null;
7150
+				} elseif (isset($this->message[$pos]['type'])) {
7151
+					$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7152
+				} else {
7153
+					$parent = $this->message[$pos]['parent'];
7154
+					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7155
+						$this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7156
+					} else {
7157
+						$this->message[$pos]['result'] = $this->message[$pos]['cdata'];
7158
+					}
7159
+				}
7160
+
7161
+				/* add value to parent's result, if parent is struct/array
7162 7162
 				$parent = $this->message[$pos]['parent'];
7163 7163
 				if($this->message[$parent]['type'] != 'map'){
7164 7164
 					if(strtolower($this->message[$parent]['type']) == 'array'){
7165 7165
 						$this->message[$parent]['result'][] = $this->message[$pos]['result'];
7166 7166
 					} else {
7167
-						$this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
7167
+						$this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
7168
+					}
7169
+				}
7170
+				*/
7171
+			}
7172
+		}
7173
+
7174
+		// for doclit
7175
+		if ($this->status == 'header') {
7176
+			if ($this->root_header != $pos) {
7177
+				$this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7178
+			}
7179
+		} elseif ($pos >= $this->root_struct) {
7180
+			$this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7181
+		}
7182
+		// switch status
7183
+		if ($pos == $this->root_struct) {
7184
+			$this->status = 'body';
7185
+			$this->root_struct_namespace = $this->message[$pos]['namespace'];
7186
+		} elseif ($pos == $this->root_header) {
7187
+			$this->status = 'envelope';
7188
+		} elseif ($name == 'Body' && $this->status == 'body') {
7189
+			$this->status = 'envelope';
7190
+		} elseif ($name == 'Header' && $this->status == 'header') { // will never happen
7191
+			$this->status = 'envelope';
7192
+		} elseif ($name == 'Envelope' && $this->status == 'envelope') {
7193
+			$this->status = '';
7194
+		}
7195
+		// set parent back to my parent
7196
+		$this->parent = $this->message[$pos]['parent'];
7197
+	}
7198
+
7199
+	/**
7200
+	 * element content handler
7201
+	 *
7202
+	 * @param    resource $parser XML parser object
7203
+	 * @param    string $data element content
7204
+	 * @access   private
7205
+	 */
7206
+	function character_data($parser, $data)
7207
+	{
7208
+		$pos = $this->depth_array[$this->depth];
7209
+		if ($this->xml_encoding == 'UTF-8') {
7210
+			// TODO: add an option to disable this for folks who want
7211
+			// raw UTF-8 that, e.g., might not map to iso-8859-1
7212
+			// TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
7213
+			if ($this->decode_utf8) {
7214
+				$data = function_exists('mb_convert_encoding') ? mb_convert_encoding($data, 'ISO-8859-1', 'UTF-8') : utf8_decode($data);
7215
+			}
7216
+		}
7217
+		$this->message[$pos]['cdata'] .= $data;
7218
+		// for doclit
7219
+		if ($this->status == 'header') {
7220
+			$this->responseHeaders .= $data;
7221
+		} else {
7222
+			$this->document .= $data;
7223
+		}
7224
+	}
7225
+
7226
+	/**
7227
+	 * get the parsed message (SOAP Body)
7228
+	 *
7229
+	 * @return    mixed
7230
+	 * @access   public
7231
+	 * @deprecated    use get_soapbody instead
7232
+	 */
7233
+	function get_response()
7234
+	{
7235
+		return $this->soapresponse;
7236
+	}
7237
+
7238
+	/**
7239
+	 * get the parsed SOAP Body (null if there was none)
7240
+	 *
7241
+	 * @return    mixed
7242
+	 * @access   public
7243
+	 */
7244
+	function get_soapbody()
7245
+	{
7246
+		return $this->soapresponse;
7247
+	}
7248
+
7249
+	/**
7250
+	 * get the parsed SOAP Header (null if there was none)
7251
+	 *
7252
+	 * @return    mixed
7253
+	 * @access   public
7254
+	 */
7255
+	function get_soapheader()
7256
+	{
7257
+		return $this->soapheader;
7258
+	}
7259
+
7260
+	/**
7261
+	 * get the unparsed SOAP Header
7262
+	 *
7263
+	 * @return    string XML or empty if no Header
7264
+	 * @access   public
7265
+	 */
7266
+	function getHeaders()
7267
+	{
7268
+		return $this->responseHeaders;
7269
+	}
7270
+
7271
+	/**
7272
+	 * decodes simple types into PHP variables
7273
+	 *
7274
+	 * @param    string $value value to decode
7275
+	 * @param    string $type XML type to decode
7276
+	 * @param    string $typens XML type namespace to decode
7277
+	 * @return    mixed PHP value
7278
+	 * @access   private
7279
+	 */
7280
+	function decodeSimple($value, $type, $typens)
7281
+	{
7282
+		// TODO: use the namespace!
7283
+		if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
7284
+			return (string) $value;
7285
+		}
7286
+		if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
7287
+			return (int) $value;
7288
+		}
7289
+		if ($type == 'float' || $type == 'double' || $type == 'decimal') {
7290
+			return (double) $value;
7291
+		}
7292
+		if ($type == 'boolean') {
7293
+			if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7294
+				return false;
7295
+			}
7296
+			return (boolean) $value;
7297
+		}
7298
+		if ($type == 'base64' || $type == 'base64Binary') {
7299
+			$this->debug('Decode base64 value');
7300
+			return base64_decode($value);
7301
+		}
7302
+		// obscure numeric types
7303
+		if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
7304
+			|| $type == 'nonNegativeInteger' || $type == 'positiveInteger'
7305
+			|| $type == 'unsignedInt'
7306
+			|| $type == 'unsignedShort' || $type == 'unsignedByte'
7307
+		) {
7308
+			return (int) $value;
7309
+		}
7310
+		// bogus: parser treats array with no elements as a simple type
7311
+		if ($type == 'array') {
7312
+			return array();
7313
+		}
7314
+		// everything else
7315
+		return (string) $value;
7316
+	}
7317
+
7318
+	/**
7319
+	 * builds response structures for compound values (arrays/structs)
7320
+	 * and scalars
7321
+	 *
7322
+	 * @param    integer $pos position in node tree
7323
+	 * @return    mixed    PHP value
7324
+	 * @access   private
7325
+	 */
7326
+	function buildVal($pos)
7327
+	{
7328
+		if (!isset($this->message[$pos]['type'])) {
7329
+			$this->message[$pos]['type'] = '';
7330
+		}
7331
+		$this->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos $pos) of type " . $this->message[$pos]['type']);
7332
+		// if there are children...
7333
+		if ($this->message[$pos]['children'] != '') {
7334
+			$params = [];
7335
+			$this->debug('in buildVal, there are children');
7336
+			$children = explode('|', $this->message[$pos]['children']);
7337
+			array_shift($children); // knock off empty
7338
+			// md array
7339
+			if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
7340
+				$r = 0; // rowcount
7341
+				$c = 0; // colcount
7342
+				foreach ($children as $child_pos) {
7343
+					$this->debug("in buildVal, got an MD array element: $r, $c");
7344
+					$params[$r][] = $this->message[$child_pos]['result'];
7345
+					$c++;
7346
+					if ($c == $this->message[$pos]['arrayCols']) {
7347
+						$c = 0;
7348
+						$r++;
7349
+					}
7350
+				}
7351
+				// array
7352
+			} elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7353
+				$this->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
7354
+				foreach ($children as $child_pos) {
7355
+					$params[] = &$this->message[$child_pos]['result'];
7356
+				}
7357
+				// apache Map type: java hashtable
7358
+			} elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7359
+				$this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
7360
+				foreach ($children as $child_pos) {
7361
+					$kv = explode("|", $this->message[$child_pos]['children']);
7362
+					$params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
7363
+				}
7364
+				// generic compound type
7365
+				//} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
7366
+			} else {
7367
+				// Apache Vector type: treat as an array
7368
+				$this->debug('in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos]['name']);
7369
+				if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7370
+					$notstruct = 1;
7371
+				} else {
7372
+					$notstruct = 0;
7373
+				}
7374
+				//
7375
+				foreach ($children as $child_pos) {
7376
+					if ($notstruct) {
7377
+						$params[] = &$this->message[$child_pos]['result'];
7378
+					} else {
7379
+						if (isset($params[$this->message[$child_pos]['name']])) {
7380
+							// de-serialize repeated element name into an array
7381
+							if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
7382
+								$params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
7383
+							}
7384
+							$params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
7385
+						} else {
7386
+							$params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
7387
+						}
7168 7388
 					}
7169 7389
 				}
7170
-				*/
7171
-            }
7172
-        }
7173
-
7174
-        // for doclit
7175
-        if ($this->status == 'header') {
7176
-            if ($this->root_header != $pos) {
7177
-                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7178
-            }
7179
-        } elseif ($pos >= $this->root_struct) {
7180
-            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7181
-        }
7182
-        // switch status
7183
-        if ($pos == $this->root_struct) {
7184
-            $this->status = 'body';
7185
-            $this->root_struct_namespace = $this->message[$pos]['namespace'];
7186
-        } elseif ($pos == $this->root_header) {
7187
-            $this->status = 'envelope';
7188
-        } elseif ($name == 'Body' && $this->status == 'body') {
7189
-            $this->status = 'envelope';
7190
-        } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
7191
-            $this->status = 'envelope';
7192
-        } elseif ($name == 'Envelope' && $this->status == 'envelope') {
7193
-            $this->status = '';
7194
-        }
7195
-        // set parent back to my parent
7196
-        $this->parent = $this->message[$pos]['parent'];
7197
-    }
7198
-
7199
-    /**
7200
-     * element content handler
7201
-     *
7202
-     * @param    resource $parser XML parser object
7203
-     * @param    string $data element content
7204
-     * @access   private
7205
-     */
7206
-    function character_data($parser, $data)
7207
-    {
7208
-        $pos = $this->depth_array[$this->depth];
7209
-        if ($this->xml_encoding == 'UTF-8') {
7210
-            // TODO: add an option to disable this for folks who want
7211
-            // raw UTF-8 that, e.g., might not map to iso-8859-1
7212
-            // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
7213
-            if ($this->decode_utf8) {
7214
-                $data = function_exists('mb_convert_encoding') ? mb_convert_encoding($data, 'ISO-8859-1', 'UTF-8') : utf8_decode($data);
7215
-            }
7216
-        }
7217
-        $this->message[$pos]['cdata'] .= $data;
7218
-        // for doclit
7219
-        if ($this->status == 'header') {
7220
-            $this->responseHeaders .= $data;
7221
-        } else {
7222
-            $this->document .= $data;
7223
-        }
7224
-    }
7225
-
7226
-    /**
7227
-     * get the parsed message (SOAP Body)
7228
-     *
7229
-     * @return    mixed
7230
-     * @access   public
7231
-     * @deprecated    use get_soapbody instead
7232
-     */
7233
-    function get_response()
7234
-    {
7235
-        return $this->soapresponse;
7236
-    }
7237
-
7238
-    /**
7239
-     * get the parsed SOAP Body (null if there was none)
7240
-     *
7241
-     * @return    mixed
7242
-     * @access   public
7243
-     */
7244
-    function get_soapbody()
7245
-    {
7246
-        return $this->soapresponse;
7247
-    }
7248
-
7249
-    /**
7250
-     * get the parsed SOAP Header (null if there was none)
7251
-     *
7252
-     * @return    mixed
7253
-     * @access   public
7254
-     */
7255
-    function get_soapheader()
7256
-    {
7257
-        return $this->soapheader;
7258
-    }
7259
-
7260
-    /**
7261
-     * get the unparsed SOAP Header
7262
-     *
7263
-     * @return    string XML or empty if no Header
7264
-     * @access   public
7265
-     */
7266
-    function getHeaders()
7267
-    {
7268
-        return $this->responseHeaders;
7269
-    }
7270
-
7271
-    /**
7272
-     * decodes simple types into PHP variables
7273
-     *
7274
-     * @param    string $value value to decode
7275
-     * @param    string $type XML type to decode
7276
-     * @param    string $typens XML type namespace to decode
7277
-     * @return    mixed PHP value
7278
-     * @access   private
7279
-     */
7280
-    function decodeSimple($value, $type, $typens)
7281
-    {
7282
-        // TODO: use the namespace!
7283
-        if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
7284
-            return (string) $value;
7285
-        }
7286
-        if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
7287
-            return (int) $value;
7288
-        }
7289
-        if ($type == 'float' || $type == 'double' || $type == 'decimal') {
7290
-            return (double) $value;
7291
-        }
7292
-        if ($type == 'boolean') {
7293
-            if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7294
-                return false;
7295
-            }
7296
-            return (boolean) $value;
7297
-        }
7298
-        if ($type == 'base64' || $type == 'base64Binary') {
7299
-            $this->debug('Decode base64 value');
7300
-            return base64_decode($value);
7301
-        }
7302
-        // obscure numeric types
7303
-        if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
7304
-            || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
7305
-            || $type == 'unsignedInt'
7306
-            || $type == 'unsignedShort' || $type == 'unsignedByte'
7307
-        ) {
7308
-            return (int) $value;
7309
-        }
7310
-        // bogus: parser treats array with no elements as a simple type
7311
-        if ($type == 'array') {
7312
-            return array();
7313
-        }
7314
-        // everything else
7315
-        return (string) $value;
7316
-    }
7317
-
7318
-    /**
7319
-     * builds response structures for compound values (arrays/structs)
7320
-     * and scalars
7321
-     *
7322
-     * @param    integer $pos position in node tree
7323
-     * @return    mixed    PHP value
7324
-     * @access   private
7325
-     */
7326
-    function buildVal($pos)
7327
-    {
7328
-        if (!isset($this->message[$pos]['type'])) {
7329
-            $this->message[$pos]['type'] = '';
7330
-        }
7331
-        $this->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos $pos) of type " . $this->message[$pos]['type']);
7332
-        // if there are children...
7333
-        if ($this->message[$pos]['children'] != '') {
7334
-            $params = [];
7335
-            $this->debug('in buildVal, there are children');
7336
-            $children = explode('|', $this->message[$pos]['children']);
7337
-            array_shift($children); // knock off empty
7338
-            // md array
7339
-            if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
7340
-                $r = 0; // rowcount
7341
-                $c = 0; // colcount
7342
-                foreach ($children as $child_pos) {
7343
-                    $this->debug("in buildVal, got an MD array element: $r, $c");
7344
-                    $params[$r][] = $this->message[$child_pos]['result'];
7345
-                    $c++;
7346
-                    if ($c == $this->message[$pos]['arrayCols']) {
7347
-                        $c = 0;
7348
-                        $r++;
7349
-                    }
7350
-                }
7351
-                // array
7352
-            } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7353
-                $this->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
7354
-                foreach ($children as $child_pos) {
7355
-                    $params[] = &$this->message[$child_pos]['result'];
7356
-                }
7357
-                // apache Map type: java hashtable
7358
-            } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7359
-                $this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
7360
-                foreach ($children as $child_pos) {
7361
-                    $kv = explode("|", $this->message[$child_pos]['children']);
7362
-                    $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
7363
-                }
7364
-                // generic compound type
7365
-                //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
7366
-            } else {
7367
-                // Apache Vector type: treat as an array
7368
-                $this->debug('in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos]['name']);
7369
-                if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7370
-                    $notstruct = 1;
7371
-                } else {
7372
-                    $notstruct = 0;
7373
-                }
7374
-                //
7375
-                foreach ($children as $child_pos) {
7376
-                    if ($notstruct) {
7377
-                        $params[] = &$this->message[$child_pos]['result'];
7378
-                    } else {
7379
-                        if (isset($params[$this->message[$child_pos]['name']])) {
7380
-                            // de-serialize repeated element name into an array
7381
-                            if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
7382
-                                $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
7383
-                            }
7384
-                            $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
7385
-                        } else {
7386
-                            $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
7387
-                        }
7388
-                    }
7389
-                }
7390
-            }
7391
-            if (isset($this->message[$pos]['xattrs'])) {
7392
-                $this->debug('in buildVal, handling attributes');
7393
-                foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7394
-                    $params[$n] = $v;
7395
-                }
7396
-            }
7397
-            // handle simpleContent
7398
-            if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7399
-                $this->debug('in buildVal, handling simpleContent');
7400
-                if (isset($this->message[$pos]['type'])) {
7401
-                    $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7402
-                } else {
7403
-                    $parent = $this->message[$pos]['parent'];
7404
-                    if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7405
-                        $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7406
-                    } else {
7407
-                        $params['!'] = $this->message[$pos]['cdata'];
7408
-                    }
7409
-                }
7410
-            }
7411
-            $ret = is_array($params) ? $params : array();
7412
-            $this->debug('in buildVal, return:');
7413
-            $this->appendDebug($this->varDump($ret));
7414
-        } else {
7415
-            $this->debug('in buildVal, no children, building scalar');
7416
-            $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7417
-            if (isset($this->message[$pos]['type'])) {
7418
-                $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7419
-                $this->debug("in buildVal, return: $ret");
7420
-                return $ret;
7421
-            }
7422
-            $parent = $this->message[$pos]['parent'];
7423
-            if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7424
-                $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7425
-                $this->debug("in buildVal, return: $ret");
7426
-                return $ret;
7427
-            }
7428
-            $ret = $this->message[$pos]['cdata'];
7429
-            $this->debug("in buildVal, return: $ret");
7430
-        }
7431
-
7432
-        return $ret;
7433
-    }
7390
+			}
7391
+			if (isset($this->message[$pos]['xattrs'])) {
7392
+				$this->debug('in buildVal, handling attributes');
7393
+				foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7394
+					$params[$n] = $v;
7395
+				}
7396
+			}
7397
+			// handle simpleContent
7398
+			if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7399
+				$this->debug('in buildVal, handling simpleContent');
7400
+				if (isset($this->message[$pos]['type'])) {
7401
+					$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7402
+				} else {
7403
+					$parent = $this->message[$pos]['parent'];
7404
+					if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7405
+						$params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7406
+					} else {
7407
+						$params['!'] = $this->message[$pos]['cdata'];
7408
+					}
7409
+				}
7410
+			}
7411
+			$ret = is_array($params) ? $params : array();
7412
+			$this->debug('in buildVal, return:');
7413
+			$this->appendDebug($this->varDump($ret));
7414
+		} else {
7415
+			$this->debug('in buildVal, no children, building scalar');
7416
+			$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7417
+			if (isset($this->message[$pos]['type'])) {
7418
+				$ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7419
+				$this->debug("in buildVal, return: $ret");
7420
+				return $ret;
7421
+			}
7422
+			$parent = $this->message[$pos]['parent'];
7423
+			if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7424
+				$ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7425
+				$this->debug("in buildVal, return: $ret");
7426
+				return $ret;
7427
+			}
7428
+			$ret = $this->message[$pos]['cdata'];
7429
+			$this->debug("in buildVal, return: $ret");
7430
+		}
7431
+
7432
+		return $ret;
7433
+	}
7434 7434
 }
7435 7435
 
7436 7436
 
@@ -7465,264 +7465,264 @@  discard block
 block discarded – undo
7465 7465
 class nusoap_client extends nusoap_base
7466 7466
 {
7467 7467
 
7468
-    var $attachments = '';
7469
-    var $return = null;
7470
-    var $operation = '';
7471
-    var $opData = array();
7472
-    var $username = '';                // Username for HTTP authentication
7473
-    var $password = '';                // Password for HTTP authentication
7474
-    var $authtype = '';                // Type of HTTP authentication
7475
-    var $certRequest = array();        // Certificate for HTTP SSL authentication
7476
-    var $requestHeaders = false;    // SOAP headers in request (text)
7477
-    var $responseHeaders = '';        // SOAP headers from response (incomplete namespace resolution) (text)
7478
-    var $responseHeader = null;        // SOAP Header from response (parsed)
7479
-    var $document = '';                // SOAP body response portion (incomplete namespace resolution) (text)
7480
-    var $endpoint;
7481
-    var $forceEndpoint = '';        // overrides WSDL endpoint
7482
-    var $proxyhost = '';
7483
-    var $proxyport = '';
7484
-    var $proxyusername = '';
7485
-    var $proxypassword = '';
7486
-    var $portName = '';                // port name to use in WSDL
7487
-    var $xml_encoding = '';            // character set encoding of incoming (response) messages
7488
-    var $http_encoding = false;
7489
-    var $timeout = 0;                // HTTP connection timeout
7490
-    var $response_timeout = 30;        // HTTP response timeout
7491
-    var $endpointType = '';            // soap|wsdl, empty for WSDL initialization error
7492
-    var $persistentConnection = false;
7493
-    var $defaultRpcParams = false;    // This is no longer used
7494
-    var $request = '';                // HTTP request
7495
-    var $response = '';                // HTTP response
7496
-    var $responseData = '';            // SOAP payload of response
7497
-    var $cookies = array();            // Cookies from response or for request
7498
-    var $decode_utf8 = true;        // toggles whether the parser decodes element content w/ utf8_decode()
7499
-    var $operations = array();        // WSDL operations, empty for WSDL initialization error
7500
-    var $curl_options = array();    // User-specified cURL options
7501
-    var $bindingType = '';            // WSDL operation binding type
7502
-    var $use_curl = false;            // whether to always try to use cURL
7503
-
7504
-    /*
7468
+	var $attachments = '';
7469
+	var $return = null;
7470
+	var $operation = '';
7471
+	var $opData = array();
7472
+	var $username = '';                // Username for HTTP authentication
7473
+	var $password = '';                // Password for HTTP authentication
7474
+	var $authtype = '';                // Type of HTTP authentication
7475
+	var $certRequest = array();        // Certificate for HTTP SSL authentication
7476
+	var $requestHeaders = false;    // SOAP headers in request (text)
7477
+	var $responseHeaders = '';        // SOAP headers from response (incomplete namespace resolution) (text)
7478
+	var $responseHeader = null;        // SOAP Header from response (parsed)
7479
+	var $document = '';                // SOAP body response portion (incomplete namespace resolution) (text)
7480
+	var $endpoint;
7481
+	var $forceEndpoint = '';        // overrides WSDL endpoint
7482
+	var $proxyhost = '';
7483
+	var $proxyport = '';
7484
+	var $proxyusername = '';
7485
+	var $proxypassword = '';
7486
+	var $portName = '';                // port name to use in WSDL
7487
+	var $xml_encoding = '';            // character set encoding of incoming (response) messages
7488
+	var $http_encoding = false;
7489
+	var $timeout = 0;                // HTTP connection timeout
7490
+	var $response_timeout = 30;        // HTTP response timeout
7491
+	var $endpointType = '';            // soap|wsdl, empty for WSDL initialization error
7492
+	var $persistentConnection = false;
7493
+	var $defaultRpcParams = false;    // This is no longer used
7494
+	var $request = '';                // HTTP request
7495
+	var $response = '';                // HTTP response
7496
+	var $responseData = '';            // SOAP payload of response
7497
+	var $cookies = array();            // Cookies from response or for request
7498
+	var $decode_utf8 = true;        // toggles whether the parser decodes element content w/ utf8_decode()
7499
+	var $operations = array();        // WSDL operations, empty for WSDL initialization error
7500
+	var $curl_options = array();    // User-specified cURL options
7501
+	var $bindingType = '';            // WSDL operation binding type
7502
+	var $use_curl = false;            // whether to always try to use cURL
7503
+
7504
+	/*
7505 7505
 	 * fault related variables
7506 7506
 	 */
7507
-    /**
7508
-     * @var      bool
7509
-     * @access   public
7510
-     */
7511
-    var $fault;
7512
-    /**
7513
-     * @var      string
7514
-     * @access   public
7515
-     */
7516
-    var $faultcode;
7517
-    /**
7518
-     * @var      string
7519
-     * @access   public
7520
-     */
7521
-    var $faultstring;
7522
-    /**
7523
-     * @var      string
7524
-     * @access   public
7525
-     */
7526
-    var $faultdetail;
7527
-
7528
-    /** @var wsdl|null */
7529
-    var $wsdl;
7530
-    /** @var mixed */
7531
-    var $wsdlFile;
7532
-
7533
-    /**
7534
-     * constructor
7535
-     *
7536
-     * @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
7537
-     * @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
7538
-     * @param    string $proxyhost optional
7539
-     * @param    string $proxyport optional
7540
-     * @param    string $proxyusername optional
7541
-     * @param    string $proxypassword optional
7542
-     * @param    integer $timeout set the connection timeout
7543
-     * @param    integer $response_timeout set the response timeout
7544
-     * @param    string $portName optional portName in WSDL document
7545
-     * @access   public
7546
-     */
7547
-    function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '')
7548
-    {
7549
-        parent::__construct();
7550
-        $this->endpoint = $endpoint;
7551
-        $this->proxyhost = $proxyhost;
7552
-        $this->proxyport = $proxyport;
7553
-        $this->proxyusername = $proxyusername;
7554
-        $this->proxypassword = $proxypassword;
7555
-        $this->timeout = $timeout;
7556
-        $this->response_timeout = $response_timeout;
7557
-        $this->portName = $portName;
7558
-
7559
-        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7560
-        $this->appendDebug('endpoint=' . $this->varDump($endpoint));
7561
-
7562
-        // make values
7563
-        if ($wsdl) {
7564
-            if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
7565
-                $this->wsdl = $endpoint;
7566
-                $this->endpoint = $this->wsdl->wsdl;
7567
-                $this->wsdlFile = $this->endpoint;
7568
-                $this->debug('existing wsdl instance created from ' . $this->endpoint);
7569
-                $this->checkWSDL();
7570
-            } else {
7571
-                $this->wsdlFile = $this->endpoint;
7572
-                $this->wsdl = null;
7573
-                $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
7574
-            }
7575
-            $this->endpointType = 'wsdl';
7576
-        } else {
7577
-            $this->debug("instantiate SOAP with endpoint at $endpoint");
7578
-            $this->endpointType = 'soap';
7579
-        }
7580
-    }
7581
-
7582
-    /**
7583
-     * calls method, returns PHP native type
7584
-     *
7585
-     * @param    string $operation SOAP server URL or path
7586
-     * @param    mixed $params An array, associative or simple, of the parameters
7587
-     *                          for the method call, or a string that is the XML
7588
-     *                          for the call.  For rpc style, this call will
7589
-     *                          wrap the XML in a tag named after the method, as
7590
-     *                          well as the SOAP Envelope and Body.  For document
7591
-     *                          style, this will only wrap with the Envelope and Body.
7592
-     *                          IMPORTANT: when using an array with document style,
7593
-     *                          in which case there
7594
-     *                         is really one parameter, the root of the fragment
7595
-     *                         used in the call, which encloses what programmers
7596
-     *                         normally think of parameters.  A parameter array
7597
-     *                         *must* include the wrapper.
7598
-     * @param    string $namespace optional method namespace (WSDL can override)
7599
-     * @param    string $soapAction optional SOAPAction value (WSDL can override)
7600
-     * @param    mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
7601
-     * @param    boolean $rpcParams optional (no longer used)
7602
-     * @param    string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
7603
-     * @param    string $use optional (encoded|literal|literal wrapped) the use when serializing parameters (WSDL can override)
7604
-     * @return    mixed    response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
7605
-     * @access   public
7606
-     */
7607
-    function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded')
7608
-    {
7609
-        $this->operation = $operation;
7610
-        $this->fault = false;
7611
-        $this->setError('');
7612
-        $this->request = '';
7613
-        $this->response = '';
7614
-        $this->responseData = '';
7615
-        $this->faultstring = '';
7616
-        $this->faultcode = '';
7617
-        $this->opData = array();
7618
-
7619
-        $usewrapped = false;
7620
-
7621
-        $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
7622
-        $this->appendDebug('params=' . $this->varDump($params));
7623
-        $this->appendDebug('headers=' . $this->varDump($headers));
7624
-        if ($headers) {
7625
-            $this->requestHeaders = $headers;
7626
-        }
7627
-        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7628
-            $this->loadWSDL();
7629
-            if ($this->getError()) {
7630
-                return false;
7631
-            }
7632
-        }
7633
-        // serialize parameters
7634
-        if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
7635
-            // use WSDL for operation
7636
-            $this->opData = $opData;
7637
-            $this->debug("found operation");
7638
-            $this->appendDebug('opData=' . $this->varDump($opData));
7639
-            if (isset($opData['soapAction'])) {
7640
-                $soapAction = $opData['soapAction'];
7641
-            }
7642
-            if (!$this->forceEndpoint) {
7643
-                $this->endpoint = $opData['endpoint'];
7644
-            } else {
7645
-                $this->endpoint = $this->forceEndpoint;
7646
-            }
7647
-            $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace;
7648
-            $style = $opData['style'];
7649
-            $use = $opData['input']['use'];
7650
-            // add ns to ns array
7651
-            if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
7652
-                $nsPrefix = 'ns' . rand(1000, 9999);
7653
-                $this->wsdl->namespaces[$nsPrefix] = $namespace;
7654
-            }
7655
-            $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
7656
-            // serialize payload
7657
-            if (is_string($params)) {
7658
-                $this->debug("serializing param string for WSDL operation $operation");
7659
-                $payload = $params;
7660
-            } elseif (is_array($params)) {
7661
-                $this->debug("serializing param array for WSDL operation $operation");
7662
-                $payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType);
7663
-            } else {
7664
-                $this->debug('params must be array or string');
7665
-                $this->setError('params must be array or string');
7666
-                return false;
7667
-            }
7668
-            $usedNamespaces = $this->wsdl->usedNamespaces;
7669
-            if (isset($opData['input']['encodingStyle'])) {
7670
-                $encodingStyle = $opData['input']['encodingStyle'];
7671
-            } else {
7672
-                $encodingStyle = '';
7673
-            }
7674
-            $this->appendDebug($this->wsdl->getDebug());
7675
-            $this->wsdl->clearDebug();
7676
-            if ($errstr = $this->wsdl->getError()) {
7677
-                $this->debug('got wsdl error: ' . $errstr);
7678
-                $this->setError('wsdl error: ' . $errstr);
7679
-                return false;
7680
-            }
7681
-        } elseif ($this->endpointType == 'wsdl') {
7682
-            // operation not in WSDL
7683
-            $this->appendDebug($this->wsdl->getDebug());
7684
-            $this->wsdl->clearDebug();
7685
-            $this->setError('operation ' . $operation . ' not present in WSDL.');
7686
-            $this->debug("operation '$operation' not present in WSDL.");
7687
-            return false;
7688
-        } else {
7689
-            // no WSDL
7690
-            //$this->namespaces['ns1'] = $namespace;
7691
-            $nsPrefix = 'ns' . rand(1000, 9999);
7692
-            // serialize
7693
-            $payload = '';
7694
-
7695
-            if ($use == 'literal wrapped') {
7696
-                // 'literal wrapped' is only sensible (and defined) for 'document'.
7697
-                if ($style == 'document') {
7698
-                    $usewrapped = true;
7699
-                }
7700
-                // For compatibility with the rest of the code:
7701
-                $use = 'literal';
7702
-            }
7703
-
7704
-            if (is_string($params)) {
7705
-                $this->debug("serializing param string for operation $operation");
7706
-                $payload = $params;
7707
-            } elseif (is_array($params)) {
7708
-                $this->debug("serializing param array for operation $operation");
7709
-                foreach ($params as $k => $v) {
7710
-                    $payload .= $this->serialize_val($v, $k, false, false, false, false, $use);
7711
-                }
7712
-            } else {
7713
-                $this->debug('params must be array or string');
7714
-                $this->setError('params must be array or string');
7715
-                return false;
7716
-            }
7717
-            $usedNamespaces = array();
7718
-            if ($use == 'encoded') {
7719
-                $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
7720
-            } else {
7721
-                $encodingStyle = '';
7722
-            }
7723
-        }
7724
-
7725
-        // wrap document/literal wrapped calls with operation element
7507
+	/**
7508
+	 * @var      bool
7509
+	 * @access   public
7510
+	 */
7511
+	var $fault;
7512
+	/**
7513
+	 * @var      string
7514
+	 * @access   public
7515
+	 */
7516
+	var $faultcode;
7517
+	/**
7518
+	 * @var      string
7519
+	 * @access   public
7520
+	 */
7521
+	var $faultstring;
7522
+	/**
7523
+	 * @var      string
7524
+	 * @access   public
7525
+	 */
7526
+	var $faultdetail;
7527
+
7528
+	/** @var wsdl|null */
7529
+	var $wsdl;
7530
+	/** @var mixed */
7531
+	var $wsdlFile;
7532
+
7533
+	/**
7534
+	 * constructor
7535
+	 *
7536
+	 * @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
7537
+	 * @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
7538
+	 * @param    string $proxyhost optional
7539
+	 * @param    string $proxyport optional
7540
+	 * @param    string $proxyusername optional
7541
+	 * @param    string $proxypassword optional
7542
+	 * @param    integer $timeout set the connection timeout
7543
+	 * @param    integer $response_timeout set the response timeout
7544
+	 * @param    string $portName optional portName in WSDL document
7545
+	 * @access   public
7546
+	 */
7547
+	function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '')
7548
+	{
7549
+		parent::__construct();
7550
+		$this->endpoint = $endpoint;
7551
+		$this->proxyhost = $proxyhost;
7552
+		$this->proxyport = $proxyport;
7553
+		$this->proxyusername = $proxyusername;
7554
+		$this->proxypassword = $proxypassword;
7555
+		$this->timeout = $timeout;
7556
+		$this->response_timeout = $response_timeout;
7557
+		$this->portName = $portName;
7558
+
7559
+		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7560
+		$this->appendDebug('endpoint=' . $this->varDump($endpoint));
7561
+
7562
+		// make values
7563
+		if ($wsdl) {
7564
+			if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
7565
+				$this->wsdl = $endpoint;
7566
+				$this->endpoint = $this->wsdl->wsdl;
7567
+				$this->wsdlFile = $this->endpoint;
7568
+				$this->debug('existing wsdl instance created from ' . $this->endpoint);
7569
+				$this->checkWSDL();
7570
+			} else {
7571
+				$this->wsdlFile = $this->endpoint;
7572
+				$this->wsdl = null;
7573
+				$this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
7574
+			}
7575
+			$this->endpointType = 'wsdl';
7576
+		} else {
7577
+			$this->debug("instantiate SOAP with endpoint at $endpoint");
7578
+			$this->endpointType = 'soap';
7579
+		}
7580
+	}
7581
+
7582
+	/**
7583
+	 * calls method, returns PHP native type
7584
+	 *
7585
+	 * @param    string $operation SOAP server URL or path
7586
+	 * @param    mixed $params An array, associative or simple, of the parameters
7587
+	 *                          for the method call, or a string that is the XML
7588
+	 *                          for the call.  For rpc style, this call will
7589
+	 *                          wrap the XML in a tag named after the method, as
7590
+	 *                          well as the SOAP Envelope and Body.  For document
7591
+	 *                          style, this will only wrap with the Envelope and Body.
7592
+	 *                          IMPORTANT: when using an array with document style,
7593
+	 *                          in which case there
7594
+	 *                         is really one parameter, the root of the fragment
7595
+	 *                         used in the call, which encloses what programmers
7596
+	 *                         normally think of parameters.  A parameter array
7597
+	 *                         *must* include the wrapper.
7598
+	 * @param    string $namespace optional method namespace (WSDL can override)
7599
+	 * @param    string $soapAction optional SOAPAction value (WSDL can override)
7600
+	 * @param    mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
7601
+	 * @param    boolean $rpcParams optional (no longer used)
7602
+	 * @param    string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
7603
+	 * @param    string $use optional (encoded|literal|literal wrapped) the use when serializing parameters (WSDL can override)
7604
+	 * @return    mixed    response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
7605
+	 * @access   public
7606
+	 */
7607
+	function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded')
7608
+	{
7609
+		$this->operation = $operation;
7610
+		$this->fault = false;
7611
+		$this->setError('');
7612
+		$this->request = '';
7613
+		$this->response = '';
7614
+		$this->responseData = '';
7615
+		$this->faultstring = '';
7616
+		$this->faultcode = '';
7617
+		$this->opData = array();
7618
+
7619
+		$usewrapped = false;
7620
+
7621
+		$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
7622
+		$this->appendDebug('params=' . $this->varDump($params));
7623
+		$this->appendDebug('headers=' . $this->varDump($headers));
7624
+		if ($headers) {
7625
+			$this->requestHeaders = $headers;
7626
+		}
7627
+		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7628
+			$this->loadWSDL();
7629
+			if ($this->getError()) {
7630
+				return false;
7631
+			}
7632
+		}
7633
+		// serialize parameters
7634
+		if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
7635
+			// use WSDL for operation
7636
+			$this->opData = $opData;
7637
+			$this->debug("found operation");
7638
+			$this->appendDebug('opData=' . $this->varDump($opData));
7639
+			if (isset($opData['soapAction'])) {
7640
+				$soapAction = $opData['soapAction'];
7641
+			}
7642
+			if (!$this->forceEndpoint) {
7643
+				$this->endpoint = $opData['endpoint'];
7644
+			} else {
7645
+				$this->endpoint = $this->forceEndpoint;
7646
+			}
7647
+			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace;
7648
+			$style = $opData['style'];
7649
+			$use = $opData['input']['use'];
7650
+			// add ns to ns array
7651
+			if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
7652
+				$nsPrefix = 'ns' . rand(1000, 9999);
7653
+				$this->wsdl->namespaces[$nsPrefix] = $namespace;
7654
+			}
7655
+			$nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
7656
+			// serialize payload
7657
+			if (is_string($params)) {
7658
+				$this->debug("serializing param string for WSDL operation $operation");
7659
+				$payload = $params;
7660
+			} elseif (is_array($params)) {
7661
+				$this->debug("serializing param array for WSDL operation $operation");
7662
+				$payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType);
7663
+			} else {
7664
+				$this->debug('params must be array or string');
7665
+				$this->setError('params must be array or string');
7666
+				return false;
7667
+			}
7668
+			$usedNamespaces = $this->wsdl->usedNamespaces;
7669
+			if (isset($opData['input']['encodingStyle'])) {
7670
+				$encodingStyle = $opData['input']['encodingStyle'];
7671
+			} else {
7672
+				$encodingStyle = '';
7673
+			}
7674
+			$this->appendDebug($this->wsdl->getDebug());
7675
+			$this->wsdl->clearDebug();
7676
+			if ($errstr = $this->wsdl->getError()) {
7677
+				$this->debug('got wsdl error: ' . $errstr);
7678
+				$this->setError('wsdl error: ' . $errstr);
7679
+				return false;
7680
+			}
7681
+		} elseif ($this->endpointType == 'wsdl') {
7682
+			// operation not in WSDL
7683
+			$this->appendDebug($this->wsdl->getDebug());
7684
+			$this->wsdl->clearDebug();
7685
+			$this->setError('operation ' . $operation . ' not present in WSDL.');
7686
+			$this->debug("operation '$operation' not present in WSDL.");
7687
+			return false;
7688
+		} else {
7689
+			// no WSDL
7690
+			//$this->namespaces['ns1'] = $namespace;
7691
+			$nsPrefix = 'ns' . rand(1000, 9999);
7692
+			// serialize
7693
+			$payload = '';
7694
+
7695
+			if ($use == 'literal wrapped') {
7696
+				// 'literal wrapped' is only sensible (and defined) for 'document'.
7697
+				if ($style == 'document') {
7698
+					$usewrapped = true;
7699
+				}
7700
+				// For compatibility with the rest of the code:
7701
+				$use = 'literal';
7702
+			}
7703
+
7704
+			if (is_string($params)) {
7705
+				$this->debug("serializing param string for operation $operation");
7706
+				$payload = $params;
7707
+			} elseif (is_array($params)) {
7708
+				$this->debug("serializing param array for operation $operation");
7709
+				foreach ($params as $k => $v) {
7710
+					$payload .= $this->serialize_val($v, $k, false, false, false, false, $use);
7711
+				}
7712
+			} else {
7713
+				$this->debug('params must be array or string');
7714
+				$this->setError('params must be array or string');
7715
+				return false;
7716
+			}
7717
+			$usedNamespaces = array();
7718
+			if ($use == 'encoded') {
7719
+				$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
7720
+			} else {
7721
+				$encodingStyle = '';
7722
+			}
7723
+		}
7724
+
7725
+		// wrap document/literal wrapped calls with operation element
7726 7726
 		if ($usewrapped) {
7727 7727
 			// (This code block was based on http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
7728 7728
 			// and tailored to the needs of one specific SOAP server, where no nsPrefix was seen...
@@ -7731,787 +7731,787 @@  discard block
 block discarded – undo
7731 7731
 			if ($namespace) {
7732 7732
 				$payload = "<$operation xmlns=\"$namespace\">" .
7733 7733
 					$payload .
7734
-                    "</$operation>";
7734
+					"</$operation>";
7735 7735
 			} else {
7736 7736
 				$payload = "<$operation>" . $payload . "</$operation>";
7737 7737
 			}
7738 7738
 		}
7739 7739
 
7740
-        // wrap RPC calls with method element
7741
-        if ($style == 'rpc') {
7742
-            if ($use == 'literal') {
7743
-                $this->debug("wrapping RPC request with literal method element");
7744
-                if ($namespace) {
7745
-                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
7746
-                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7747
-                        $payload .
7748
-                        "</$nsPrefix:$operation>";
7749
-                } else {
7750
-                    $payload = "<$operation>" . $payload . "</$operation>";
7751
-                }
7752
-            } else {
7753
-                $this->debug("wrapping RPC request with encoded method element");
7754
-                if ($namespace) {
7755
-                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7756
-                        $payload .
7757
-                        "</$nsPrefix:$operation>";
7758
-                } else {
7759
-                    $payload = "<$operation>" .
7760
-                        $payload .
7761
-                        "</$operation>";
7762
-                }
7763
-            }
7764
-        }
7765
-        // serialize envelope
7766
-        $soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle);
7767
-        $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
7768
-        $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
7769
-        // send
7770
-        $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
7771
-        if ($errstr = $this->getError()) {
7772
-            $this->debug('Error: ' . $errstr);
7773
-            return false;
7774
-        } else {
7775
-            $this->return = $return;
7776
-            $this->debug('sent message successfully and got a(n) ' . gettype($return));
7777
-            $this->appendDebug('return=' . $this->varDump($return));
7778
-
7779
-            // fault?
7780
-            if (is_array($return) && isset($return['faultcode'])) {
7781
-                $this->debug('got fault');
7782
-                $this->setError($return['faultcode'] . ': ' . $return['faultstring']);
7783
-                $this->fault = true;
7784
-                foreach ($return as $k => $v) {
7785
-                    $this->$k = $v;
7786
-                    if (is_array($v)) {
7787
-                        $this->debug("$k = " . json_encode($v));
7788
-                    } else {
7789
-                        $this->debug("$k = $v<br>");
7790
-                    }
7791
-                }
7792
-                return $return;
7793
-            } elseif ($style == 'document') {
7794
-                // NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
7795
-                // we are only going to return the first part here...sorry about that
7796
-                return $return;
7797
-            } else {
7798
-                // array of return values
7799
-                if (is_array($return)) {
7800
-                    // multiple 'out' parameters, which we return wrapped up
7801
-                    // in the array
7802
-                    if (sizeof($return) > 1) {
7803
-                        return $return;
7804
-                    }
7805
-                    // single 'out' parameter (normally the return value)
7806
-                    $return = array_shift($return);
7807
-                    $this->debug('return shifted value: ');
7808
-                    $this->appendDebug($this->varDump($return));
7809
-                    return $return;
7810
-                    // nothing returned (ie, echoVoid)
7811
-                } else {
7812
-                    return "";
7813
-                }
7814
-            }
7815
-        }
7816
-    }
7817
-
7818
-    /**
7819
-     * check WSDL passed as an instance or pulled from an endpoint
7820
-     *
7821
-     * @access   private
7822
-     */
7823
-    function checkWSDL()
7824
-    {
7825
-        $this->appendDebug($this->wsdl->getDebug());
7826
-        $this->wsdl->clearDebug();
7827
-        $this->debug('checkWSDL');
7828
-        // catch errors
7829
-        if ($errstr = $this->wsdl->getError()) {
7830
-            $this->appendDebug($this->wsdl->getDebug());
7831
-            $this->wsdl->clearDebug();
7832
-            $this->debug('got wsdl error: ' . $errstr);
7833
-            $this->setError('wsdl error: ' . $errstr);
7834
-        } elseif ($this->operations = $this->wsdl->getOperations($this->portName)) {
7835
-            $this->appendDebug($this->wsdl->getDebug());
7836
-            $this->wsdl->clearDebug();
7837
-            $this->bindingType = 'soap';
7838
-            $this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7839
-        } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
7840
-            $this->appendDebug($this->wsdl->getDebug());
7841
-            $this->wsdl->clearDebug();
7842
-            $this->bindingType = 'soap12';
7843
-            $this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7844
-            $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
7845
-        } else {
7846
-            $this->appendDebug($this->wsdl->getDebug());
7847
-            $this->wsdl->clearDebug();
7848
-            $this->debug('getOperations returned false');
7849
-            $this->setError('no operations defined in the WSDL document!');
7850
-        }
7851
-    }
7852
-
7853
-    /**
7854
-     * instantiate wsdl object and parse wsdl file
7855
-     *
7856
-     * @access    public
7857
-     */
7858
-    function loadWSDL()
7859
-    {
7860
-        $this->debug('instantiating wsdl class with doc: ' . $this->wsdlFile);
7861
-        $this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
7862
-        $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7863
-        $this->wsdl->fetchWSDL($this->wsdlFile);
7864
-        $this->checkWSDL();
7865
-    }
7866
-
7867
-    /**
7868
-     * get available data pertaining to an operation
7869
-     *
7870
-     * @param    string $operation operation name
7871
-     * @return   array|false array of data pertaining to the operation, false on error or no data
7872
-     * @access   public
7873
-     */
7874
-    function getOperationData($operation)
7875
-    {
7876
-        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7877
-            $this->loadWSDL();
7878
-            if ($this->getError()) {
7879
-                return false;
7880
-            }
7881
-        }
7882
-        if (isset($this->operations[$operation])) {
7883
-            return $this->operations[$operation];
7884
-        }
7885
-        $this->debug("No data for operation: $operation");
7886
-        return false;
7887
-    }
7888
-
7889
-    /**
7890
-     * send the SOAP message
7891
-     *
7892
-     * Note: if the operation has multiple return values
7893
-     * the return value of this method will be an array
7894
-     * of those values.
7895
-     *
7896
-     * @param    string $msg a SOAPx4 soapmsg object
7897
-     * @param    string $soapaction SOAPAction value
7898
-     * @param    integer $timeout set connection timeout in seconds
7899
-     * @param    integer $response_timeout set response timeout in seconds
7900
-     * @return    mixed native PHP types.
7901
-     * @access   private
7902
-     */
7903
-    function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30)
7904
-    {
7905
-        $this->checkCookies();
7906
-        // detect transport
7907
-        switch (true) {
7908
-            // http(s)
7909
-            case preg_match('/^http/', $this->endpoint):
7910
-                $this->debug('transporting via HTTP');
7911
-                if ($this->persistentConnection && is_object($this->persistentConnection)) {
7912
-                    $http =& $this->persistentConnection;
7913
-                } else {
7914
-                    $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
7915
-                    if ($this->persistentConnection) {
7916
-                        $http->usePersistentConnection();
7917
-                    }
7918
-                }
7919
-                $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
7920
-                $http->setSOAPAction($soapaction);
7921
-                if ($this->proxyhost && $this->proxyport) {
7922
-                    $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
7923
-                }
7924
-                if ($this->authtype != '') {
7925
-                    $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
7926
-                }
7927
-                if ($this->http_encoding != '') {
7928
-                    $http->setEncoding($this->http_encoding);
7929
-                }
7930
-                $this->debug('sending message, length=' . strlen($msg));
7931
-                if (preg_match('/^http:/', $this->endpoint)) {
7932
-                    //if(strpos($this->endpoint,'http:')){
7933
-                    $this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
7934
-                } elseif (preg_match('/^https/', $this->endpoint)) {
7935
-                    //} elseif(strpos($this->endpoint,'https:')){
7936
-                    //if(phpversion() == '4.3.0-dev'){
7937
-                    //$response = $http->send($msg,$timeout,$response_timeout);
7938
-                    //$this->request = $http->outgoing_payload;
7939
-                    //$this->response = $http->incoming_payload;
7940
-                    //} else
7941
-                    $this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
7942
-                } else {
7943
-                    $this->setError('no http/s in endpoint url');
7944
-                }
7945
-                $this->request = $http->outgoing_payload;
7946
-                $this->response = $http->incoming_payload;
7947
-                $this->appendDebug($http->getDebug());
7948
-                $this->UpdateCookies($http->incoming_cookies);
7949
-
7950
-                // save transport object if using persistent connections
7951
-                if ($this->persistentConnection) {
7952
-                    $http->clearDebug();
7953
-                    if (!is_object($this->persistentConnection)) {
7954
-                        $this->persistentConnection = $http;
7955
-                    }
7956
-                }
7957
-
7958
-                if ($err = $http->getError()) {
7959
-                    $this->setError('HTTP Error: ' . $err);
7960
-                    return false;
7961
-                } elseif ($this->getError()) {
7962
-                    return false;
7963
-                } else {
7964
-                    $this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']);
7965
-                    return $this->parseResponse($http->incoming_headers, $this->responseData);
7966
-                }
7967
-            default:
7968
-                $this->setError('no transport found, or selected transport is not yet supported!');
7969
-                return false;
7970
-        }
7971
-    }
7972
-
7973
-    /**
7974
-     * processes SOAP message returned from server
7975
-     *
7976
-     * @param    array $headers The HTTP headers
7977
-     * @param    string $data unprocessed response data from server
7978
-     * @return    mixed    value of the message, decoded into a PHP type
7979
-     * @access   private
7980
-     */
7981
-    function parseResponse($headers, $data)
7982
-    {
7983
-        $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
7984
-        $this->appendDebug($this->varDump($headers));
7985
-        if (!isset($headers['content-type'])) {
7986
-            $this->setError('Response not of type '.$this->contentType.' (no content-type header)');
7987
-            return false;
7988
-        }
7989
-        if (!strstr($headers['content-type'], $this->contentType)) {
7990
-            $this->setError('Response not of type '.$this->contentType.': ' . $headers['content-type']);
7991
-            return false;
7992
-        }
7993
-        if (strpos($headers['content-type'], '=')) {
7994
-            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
7995
-            $this->debug('Got response encoding: ' . $enc);
7996
-            if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
7997
-                $this->xml_encoding = strtoupper($enc);
7998
-            } else {
7999
-                $this->xml_encoding = 'US-ASCII';
8000
-            }
8001
-        } else {
8002
-            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
8003
-            $this->xml_encoding = 'ISO-8859-1';
8004
-        }
8005
-        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
8006
-        $parser = new nusoap_parser($data, $this->xml_encoding, $this->operations, $this->decode_utf8);
8007
-        // add parser debug data to our debug
8008
-        $this->appendDebug($parser->getDebug());
8009
-        // if parse errors
8010
-        if ($errstr = $parser->getError()) {
8011
-            $this->setError($errstr);
8012
-            // destroy the parser object
8013
-            unset($parser);
8014
-            return false;
8015
-        } else {
8016
-            // get SOAP headers
8017
-            $this->responseHeaders = $parser->getHeaders();
8018
-            // get SOAP headers
8019
-            $this->responseHeader = $parser->get_soapheader();
8020
-            // get decoded message
8021
-            $return = $parser->get_soapbody();
8022
-            // add document for doclit support
8023
-            $this->document = $parser->document;
8024
-            // Add attachments
8025
-            $this->attachments = $parser->attachments;
8026
-            // destroy the parser object
8027
-            unset($parser);
8028
-            // return decode message
8029
-            return $return;
8030
-        }
8031
-    }
8032
-
8033
-    /**
8034
-     * sets user-specified cURL options
8035
-     *
8036
-     * @param    mixed $option The cURL option (always integer?)
8037
-     * @param    mixed $value The cURL option value
8038
-     * @access   public
8039
-     */
8040
-    function setCurlOption($option, $value)
8041
-    {
8042
-        $this->debug("setCurlOption option=$option, value=");
8043
-        $this->appendDebug($this->varDump($value));
8044
-        $this->curl_options[$option] = $value;
8045
-    }
8046
-
8047
-    /**
8048
-     * sets the SOAP endpoint, which can override WSDL
8049
-     *
8050
-     * @param    string $endpoint The endpoint URL to use, or empty string or false to prevent override
8051
-     * @access   public
8052
-     */
8053
-    function setEndpoint($endpoint)
8054
-    {
8055
-        $this->debug("setEndpoint(\"$endpoint\")");
8056
-        $this->forceEndpoint = $endpoint;
8057
-    }
8058
-
8059
-    /**
8060
-     * set the SOAP headers
8061
-     *
8062
-     * @param    mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
8063
-     * @access   public
8064
-     */
8065
-    function setHeaders($headers)
8066
-    {
8067
-        $this->debug("setHeaders headers=");
8068
-        $this->appendDebug($this->varDump($headers));
8069
-        $this->requestHeaders = $headers;
8070
-    }
8071
-
8072
-    /**
8073
-     * get the SOAP response headers (namespace resolution incomplete)
8074
-     *
8075
-     * @return    string
8076
-     * @access   public
8077
-     */
8078
-    function getHeaders()
8079
-    {
8080
-        return $this->responseHeaders;
8081
-    }
8082
-
8083
-    /**
8084
-     * get the SOAP response Header (parsed)
8085
-     *
8086
-     * @return    mixed
8087
-     * @access   public
8088
-     */
8089
-    function getHeader()
8090
-    {
8091
-        return $this->responseHeader;
8092
-    }
8093
-
8094
-    /**
8095
-     * set proxy info here
8096
-     *
8097
-     * @param    string $proxyhost
8098
-     * @param    string $proxyport
8099
-     * @param    string $proxyusername
8100
-     * @param    string $proxypassword
8101
-     * @access   public
8102
-     */
8103
-    function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '')
8104
-    {
8105
-        $this->proxyhost = $proxyhost;
8106
-        $this->proxyport = $proxyport;
8107
-        $this->proxyusername = $proxyusername;
8108
-        $this->proxypassword = $proxypassword;
8109
-    }
8110
-
8111
-    /**
8112
-     * if authenticating, set user credentials here
8113
-     *
8114
-     * @param    string $username
8115
-     * @param    string $password
8116
-     * @param    string $authtype (basic|digest|certificate|ntlm)
8117
-     * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
8118
-     * @access   public
8119
-     */
8120
-    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array())
8121
-    {
8122
-        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
8123
-        $this->appendDebug($this->varDump($certRequest));
8124
-        $this->username = $username;
8125
-        $this->password = $password;
8126
-        $this->authtype = $authtype;
8127
-        $this->certRequest = $certRequest;
8128
-    }
8129
-
8130
-    /**
8131
-     * use HTTP encoding
8132
-     *
8133
-     * @param    string $enc HTTP encoding
8134
-     * @access   public
8135
-     */
8136
-    function setHTTPEncoding($enc = 'gzip, deflate')
8137
-    {
8138
-        $this->debug("setHTTPEncoding(\"$enc\")");
8139
-        $this->http_encoding = $enc;
8140
-    }
8141
-
8142
-    /**
8143
-     * Set whether to try to use cURL connections if possible
8144
-     *
8145
-     * @param    boolean $use Whether to try to use cURL
8146
-     * @access   public
8147
-     */
8148
-    function setUseCURL($use)
8149
-    {
8150
-        $this->debug("setUseCURL($use)");
8151
-        $this->use_curl = $use;
8152
-    }
8153
-
8154
-    /**
8155
-     * use HTTP persistent connections if possible
8156
-     *
8157
-     * @access   public
8158
-     */
8159
-    function useHTTPPersistentConnection()
8160
-    {
8161
-        $this->debug("useHTTPPersistentConnection");
8162
-        $this->persistentConnection = true;
8163
-    }
8164
-
8165
-    /**
8166
-     * gets the default RPC parameter setting.
8167
-     * If true, default is that call params are like RPC even for document style.
8168
-     * Each call() can override this value.
8169
-     *
8170
-     * This is no longer used.
8171
-     *
8172
-     * @return boolean
8173
-     * @access public
8174
-     * @deprecated
8175
-     */
8176
-    function getDefaultRpcParams()
8177
-    {
8178
-        return $this->defaultRpcParams;
8179
-    }
8180
-
8181
-    /**
8182
-     * sets the default RPC parameter setting.
8183
-     * If true, default is that call params are like RPC even for document style
8184
-     * Each call() can override this value.
8185
-     *
8186
-     * This is no longer used.
8187
-     *
8188
-     * @param    boolean $rpcParams
8189
-     * @access public
8190
-     * @deprecated
8191
-     */
8192
-    function setDefaultRpcParams($rpcParams)
8193
-    {
8194
-        $this->defaultRpcParams = $rpcParams;
8195
-    }
8196
-
8197
-    /**
8198
-     * dynamically creates an instance of a proxy class,
8199
-     * allowing user to directly call methods from wsdl
8200
-     *
8201
-     * @return   object soap_proxy object
8202
-     * @access   public
8203
-     */
8204
-    function getProxy()
8205
-    {
8206
-        $r = rand();
8207
-        $evalStr = $this->_getProxyClassCode($r);
8208
-        //$this->debug("proxy class: $evalStr");
8209
-        if ($this->getError()) {
8210
-            $this->debug("Error from _getProxyClassCode, so return null");
8211
-            return null;
8212
-        }
8213
-        // eval the class
8214
-        eval($evalStr);
8215
-        // instantiate proxy object
8216
-        /** @var nusoap_client $proxy */
8217
-        eval("\$proxy = new nusoap_proxy_$r('');");
8218
-        // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
8219
-        $proxy->endpointType = 'wsdl';
8220
-        $proxy->wsdlFile = $this->wsdlFile;
8221
-        $proxy->wsdl = $this->wsdl;
8222
-        $proxy->operations = $this->operations;
8223
-        $proxy->defaultRpcParams = $this->defaultRpcParams;
8224
-        // transfer other state
8225
-        $proxy->soap_defencoding = $this->soap_defencoding;
8226
-        $proxy->username = $this->username;
8227
-        $proxy->password = $this->password;
8228
-        $proxy->authtype = $this->authtype;
8229
-        $proxy->certRequest = $this->certRequest;
8230
-        $proxy->requestHeaders = $this->requestHeaders;
8231
-        $proxy->endpoint = $this->endpoint;
8232
-        $proxy->forceEndpoint = $this->forceEndpoint;
8233
-        $proxy->proxyhost = $this->proxyhost;
8234
-        $proxy->proxyport = $this->proxyport;
8235
-        $proxy->proxyusername = $this->proxyusername;
8236
-        $proxy->proxypassword = $this->proxypassword;
8237
-        $proxy->http_encoding = $this->http_encoding;
8238
-        $proxy->timeout = $this->timeout;
8239
-        $proxy->response_timeout = $this->response_timeout;
8240
-        $proxy->persistentConnection = &$this->persistentConnection;
8241
-        $proxy->decode_utf8 = $this->decode_utf8;
8242
-        $proxy->curl_options = $this->curl_options;
8243
-        $proxy->bindingType = $this->bindingType;
8244
-        $proxy->use_curl = $this->use_curl;
8245
-        return $proxy;
8246
-    }
8247
-
8248
-    /**
8249
-     * dynamically creates proxy class code
8250
-     *
8251
-     * @return   string PHP/NuSOAP code for the proxy class
8252
-     * @access   private
8253
-     */
8254
-    function _getProxyClassCode($r)
8255
-    {
8256
-        $this->debug("in getProxy endpointType=$this->endpointType");
8257
-        $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
8258
-        if ($this->endpointType != 'wsdl') {
8259
-            $evalStr = 'A proxy can only be created for a WSDL client';
8260
-            $this->setError($evalStr);
8261
-
8262
-          return "echo \"$evalStr\";";
8263
-        }
8264
-        if (is_null($this->wsdl)) {
8265
-            $this->loadWSDL();
8266
-            if ($this->getError()) {
8267
-                return "echo \"" . $this->getError() . "\";";
8268
-            }
8269
-        }
8270
-        $evalStr = '';
8271
-        foreach ($this->operations as $operation => $opData) {
8272
-            if ($operation != '') {
8273
-                $paramStr = '';
8274
-                $paramArrayStr = '';
8275
-                // create param string and param comment string
8276
-                if (sizeof($opData['input']['parts']) > 0) {
8277
-                    $paramCommentStr = '';
8278
-                    foreach ($opData['input']['parts'] as $name => $type) {
8279
-                        $paramStr .= "\$$name, ";
8280
-                        $paramArrayStr .= "'$name' => \$$name, ";
8281
-                        $paramCommentStr .= "$type \$$name, ";
8282
-                    }
8283
-                    $paramStr = substr($paramStr, 0, strlen($paramStr) - 2);
8284
-                    $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2);
8285
-                    $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2);
8286
-                } else {
8287
-                    $paramCommentStr = 'void';
8288
-                }
8289
-                $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
8290
-                $evalStr .= "// $paramCommentStr
7740
+		// wrap RPC calls with method element
7741
+		if ($style == 'rpc') {
7742
+			if ($use == 'literal') {
7743
+				$this->debug("wrapping RPC request with literal method element");
7744
+				if ($namespace) {
7745
+					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
7746
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7747
+						$payload .
7748
+						"</$nsPrefix:$operation>";
7749
+				} else {
7750
+					$payload = "<$operation>" . $payload . "</$operation>";
7751
+				}
7752
+			} else {
7753
+				$this->debug("wrapping RPC request with encoded method element");
7754
+				if ($namespace) {
7755
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7756
+						$payload .
7757
+						"</$nsPrefix:$operation>";
7758
+				} else {
7759
+					$payload = "<$operation>" .
7760
+						$payload .
7761
+						"</$operation>";
7762
+				}
7763
+			}
7764
+		}
7765
+		// serialize envelope
7766
+		$soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle);
7767
+		$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
7768
+		$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
7769
+		// send
7770
+		$return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
7771
+		if ($errstr = $this->getError()) {
7772
+			$this->debug('Error: ' . $errstr);
7773
+			return false;
7774
+		} else {
7775
+			$this->return = $return;
7776
+			$this->debug('sent message successfully and got a(n) ' . gettype($return));
7777
+			$this->appendDebug('return=' . $this->varDump($return));
7778
+
7779
+			// fault?
7780
+			if (is_array($return) && isset($return['faultcode'])) {
7781
+				$this->debug('got fault');
7782
+				$this->setError($return['faultcode'] . ': ' . $return['faultstring']);
7783
+				$this->fault = true;
7784
+				foreach ($return as $k => $v) {
7785
+					$this->$k = $v;
7786
+					if (is_array($v)) {
7787
+						$this->debug("$k = " . json_encode($v));
7788
+					} else {
7789
+						$this->debug("$k = $v<br>");
7790
+					}
7791
+				}
7792
+				return $return;
7793
+			} elseif ($style == 'document') {
7794
+				// NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
7795
+				// we are only going to return the first part here...sorry about that
7796
+				return $return;
7797
+			} else {
7798
+				// array of return values
7799
+				if (is_array($return)) {
7800
+					// multiple 'out' parameters, which we return wrapped up
7801
+					// in the array
7802
+					if (sizeof($return) > 1) {
7803
+						return $return;
7804
+					}
7805
+					// single 'out' parameter (normally the return value)
7806
+					$return = array_shift($return);
7807
+					$this->debug('return shifted value: ');
7808
+					$this->appendDebug($this->varDump($return));
7809
+					return $return;
7810
+					// nothing returned (ie, echoVoid)
7811
+				} else {
7812
+					return "";
7813
+				}
7814
+			}
7815
+		}
7816
+	}
7817
+
7818
+	/**
7819
+	 * check WSDL passed as an instance or pulled from an endpoint
7820
+	 *
7821
+	 * @access   private
7822
+	 */
7823
+	function checkWSDL()
7824
+	{
7825
+		$this->appendDebug($this->wsdl->getDebug());
7826
+		$this->wsdl->clearDebug();
7827
+		$this->debug('checkWSDL');
7828
+		// catch errors
7829
+		if ($errstr = $this->wsdl->getError()) {
7830
+			$this->appendDebug($this->wsdl->getDebug());
7831
+			$this->wsdl->clearDebug();
7832
+			$this->debug('got wsdl error: ' . $errstr);
7833
+			$this->setError('wsdl error: ' . $errstr);
7834
+		} elseif ($this->operations = $this->wsdl->getOperations($this->portName)) {
7835
+			$this->appendDebug($this->wsdl->getDebug());
7836
+			$this->wsdl->clearDebug();
7837
+			$this->bindingType = 'soap';
7838
+			$this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7839
+		} elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
7840
+			$this->appendDebug($this->wsdl->getDebug());
7841
+			$this->wsdl->clearDebug();
7842
+			$this->bindingType = 'soap12';
7843
+			$this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7844
+			$this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
7845
+		} else {
7846
+			$this->appendDebug($this->wsdl->getDebug());
7847
+			$this->wsdl->clearDebug();
7848
+			$this->debug('getOperations returned false');
7849
+			$this->setError('no operations defined in the WSDL document!');
7850
+		}
7851
+	}
7852
+
7853
+	/**
7854
+	 * instantiate wsdl object and parse wsdl file
7855
+	 *
7856
+	 * @access    public
7857
+	 */
7858
+	function loadWSDL()
7859
+	{
7860
+		$this->debug('instantiating wsdl class with doc: ' . $this->wsdlFile);
7861
+		$this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
7862
+		$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7863
+		$this->wsdl->fetchWSDL($this->wsdlFile);
7864
+		$this->checkWSDL();
7865
+	}
7866
+
7867
+	/**
7868
+	 * get available data pertaining to an operation
7869
+	 *
7870
+	 * @param    string $operation operation name
7871
+	 * @return   array|false array of data pertaining to the operation, false on error or no data
7872
+	 * @access   public
7873
+	 */
7874
+	function getOperationData($operation)
7875
+	{
7876
+		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
7877
+			$this->loadWSDL();
7878
+			if ($this->getError()) {
7879
+				return false;
7880
+			}
7881
+		}
7882
+		if (isset($this->operations[$operation])) {
7883
+			return $this->operations[$operation];
7884
+		}
7885
+		$this->debug("No data for operation: $operation");
7886
+		return false;
7887
+	}
7888
+
7889
+	/**
7890
+	 * send the SOAP message
7891
+	 *
7892
+	 * Note: if the operation has multiple return values
7893
+	 * the return value of this method will be an array
7894
+	 * of those values.
7895
+	 *
7896
+	 * @param    string $msg a SOAPx4 soapmsg object
7897
+	 * @param    string $soapaction SOAPAction value
7898
+	 * @param    integer $timeout set connection timeout in seconds
7899
+	 * @param    integer $response_timeout set response timeout in seconds
7900
+	 * @return    mixed native PHP types.
7901
+	 * @access   private
7902
+	 */
7903
+	function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30)
7904
+	{
7905
+		$this->checkCookies();
7906
+		// detect transport
7907
+		switch (true) {
7908
+			// http(s)
7909
+			case preg_match('/^http/', $this->endpoint):
7910
+				$this->debug('transporting via HTTP');
7911
+				if ($this->persistentConnection && is_object($this->persistentConnection)) {
7912
+					$http =& $this->persistentConnection;
7913
+				} else {
7914
+					$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
7915
+					if ($this->persistentConnection) {
7916
+						$http->usePersistentConnection();
7917
+					}
7918
+				}
7919
+				$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
7920
+				$http->setSOAPAction($soapaction);
7921
+				if ($this->proxyhost && $this->proxyport) {
7922
+					$http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
7923
+				}
7924
+				if ($this->authtype != '') {
7925
+					$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
7926
+				}
7927
+				if ($this->http_encoding != '') {
7928
+					$http->setEncoding($this->http_encoding);
7929
+				}
7930
+				$this->debug('sending message, length=' . strlen($msg));
7931
+				if (preg_match('/^http:/', $this->endpoint)) {
7932
+					//if(strpos($this->endpoint,'http:')){
7933
+					$this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
7934
+				} elseif (preg_match('/^https/', $this->endpoint)) {
7935
+					//} elseif(strpos($this->endpoint,'https:')){
7936
+					//if(phpversion() == '4.3.0-dev'){
7937
+					//$response = $http->send($msg,$timeout,$response_timeout);
7938
+					//$this->request = $http->outgoing_payload;
7939
+					//$this->response = $http->incoming_payload;
7940
+					//} else
7941
+					$this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
7942
+				} else {
7943
+					$this->setError('no http/s in endpoint url');
7944
+				}
7945
+				$this->request = $http->outgoing_payload;
7946
+				$this->response = $http->incoming_payload;
7947
+				$this->appendDebug($http->getDebug());
7948
+				$this->UpdateCookies($http->incoming_cookies);
7949
+
7950
+				// save transport object if using persistent connections
7951
+				if ($this->persistentConnection) {
7952
+					$http->clearDebug();
7953
+					if (!is_object($this->persistentConnection)) {
7954
+						$this->persistentConnection = $http;
7955
+					}
7956
+				}
7957
+
7958
+				if ($err = $http->getError()) {
7959
+					$this->setError('HTTP Error: ' . $err);
7960
+					return false;
7961
+				} elseif ($this->getError()) {
7962
+					return false;
7963
+				} else {
7964
+					$this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']);
7965
+					return $this->parseResponse($http->incoming_headers, $this->responseData);
7966
+				}
7967
+			default:
7968
+				$this->setError('no transport found, or selected transport is not yet supported!');
7969
+				return false;
7970
+		}
7971
+	}
7972
+
7973
+	/**
7974
+	 * processes SOAP message returned from server
7975
+	 *
7976
+	 * @param    array $headers The HTTP headers
7977
+	 * @param    string $data unprocessed response data from server
7978
+	 * @return    mixed    value of the message, decoded into a PHP type
7979
+	 * @access   private
7980
+	 */
7981
+	function parseResponse($headers, $data)
7982
+	{
7983
+		$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
7984
+		$this->appendDebug($this->varDump($headers));
7985
+		if (!isset($headers['content-type'])) {
7986
+			$this->setError('Response not of type '.$this->contentType.' (no content-type header)');
7987
+			return false;
7988
+		}
7989
+		if (!strstr($headers['content-type'], $this->contentType)) {
7990
+			$this->setError('Response not of type '.$this->contentType.': ' . $headers['content-type']);
7991
+			return false;
7992
+		}
7993
+		if (strpos($headers['content-type'], '=')) {
7994
+			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
7995
+			$this->debug('Got response encoding: ' . $enc);
7996
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
7997
+				$this->xml_encoding = strtoupper($enc);
7998
+			} else {
7999
+				$this->xml_encoding = 'US-ASCII';
8000
+			}
8001
+		} else {
8002
+			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
8003
+			$this->xml_encoding = 'ISO-8859-1';
8004
+		}
8005
+		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
8006
+		$parser = new nusoap_parser($data, $this->xml_encoding, $this->operations, $this->decode_utf8);
8007
+		// add parser debug data to our debug
8008
+		$this->appendDebug($parser->getDebug());
8009
+		// if parse errors
8010
+		if ($errstr = $parser->getError()) {
8011
+			$this->setError($errstr);
8012
+			// destroy the parser object
8013
+			unset($parser);
8014
+			return false;
8015
+		} else {
8016
+			// get SOAP headers
8017
+			$this->responseHeaders = $parser->getHeaders();
8018
+			// get SOAP headers
8019
+			$this->responseHeader = $parser->get_soapheader();
8020
+			// get decoded message
8021
+			$return = $parser->get_soapbody();
8022
+			// add document for doclit support
8023
+			$this->document = $parser->document;
8024
+			// Add attachments
8025
+			$this->attachments = $parser->attachments;
8026
+			// destroy the parser object
8027
+			unset($parser);
8028
+			// return decode message
8029
+			return $return;
8030
+		}
8031
+	}
8032
+
8033
+	/**
8034
+	 * sets user-specified cURL options
8035
+	 *
8036
+	 * @param    mixed $option The cURL option (always integer?)
8037
+	 * @param    mixed $value The cURL option value
8038
+	 * @access   public
8039
+	 */
8040
+	function setCurlOption($option, $value)
8041
+	{
8042
+		$this->debug("setCurlOption option=$option, value=");
8043
+		$this->appendDebug($this->varDump($value));
8044
+		$this->curl_options[$option] = $value;
8045
+	}
8046
+
8047
+	/**
8048
+	 * sets the SOAP endpoint, which can override WSDL
8049
+	 *
8050
+	 * @param    string $endpoint The endpoint URL to use, or empty string or false to prevent override
8051
+	 * @access   public
8052
+	 */
8053
+	function setEndpoint($endpoint)
8054
+	{
8055
+		$this->debug("setEndpoint(\"$endpoint\")");
8056
+		$this->forceEndpoint = $endpoint;
8057
+	}
8058
+
8059
+	/**
8060
+	 * set the SOAP headers
8061
+	 *
8062
+	 * @param    mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
8063
+	 * @access   public
8064
+	 */
8065
+	function setHeaders($headers)
8066
+	{
8067
+		$this->debug("setHeaders headers=");
8068
+		$this->appendDebug($this->varDump($headers));
8069
+		$this->requestHeaders = $headers;
8070
+	}
8071
+
8072
+	/**
8073
+	 * get the SOAP response headers (namespace resolution incomplete)
8074
+	 *
8075
+	 * @return    string
8076
+	 * @access   public
8077
+	 */
8078
+	function getHeaders()
8079
+	{
8080
+		return $this->responseHeaders;
8081
+	}
8082
+
8083
+	/**
8084
+	 * get the SOAP response Header (parsed)
8085
+	 *
8086
+	 * @return    mixed
8087
+	 * @access   public
8088
+	 */
8089
+	function getHeader()
8090
+	{
8091
+		return $this->responseHeader;
8092
+	}
8093
+
8094
+	/**
8095
+	 * set proxy info here
8096
+	 *
8097
+	 * @param    string $proxyhost
8098
+	 * @param    string $proxyport
8099
+	 * @param    string $proxyusername
8100
+	 * @param    string $proxypassword
8101
+	 * @access   public
8102
+	 */
8103
+	function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '')
8104
+	{
8105
+		$this->proxyhost = $proxyhost;
8106
+		$this->proxyport = $proxyport;
8107
+		$this->proxyusername = $proxyusername;
8108
+		$this->proxypassword = $proxypassword;
8109
+	}
8110
+
8111
+	/**
8112
+	 * if authenticating, set user credentials here
8113
+	 *
8114
+	 * @param    string $username
8115
+	 * @param    string $password
8116
+	 * @param    string $authtype (basic|digest|certificate|ntlm)
8117
+	 * @param    array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
8118
+	 * @access   public
8119
+	 */
8120
+	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array())
8121
+	{
8122
+		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
8123
+		$this->appendDebug($this->varDump($certRequest));
8124
+		$this->username = $username;
8125
+		$this->password = $password;
8126
+		$this->authtype = $authtype;
8127
+		$this->certRequest = $certRequest;
8128
+	}
8129
+
8130
+	/**
8131
+	 * use HTTP encoding
8132
+	 *
8133
+	 * @param    string $enc HTTP encoding
8134
+	 * @access   public
8135
+	 */
8136
+	function setHTTPEncoding($enc = 'gzip, deflate')
8137
+	{
8138
+		$this->debug("setHTTPEncoding(\"$enc\")");
8139
+		$this->http_encoding = $enc;
8140
+	}
8141
+
8142
+	/**
8143
+	 * Set whether to try to use cURL connections if possible
8144
+	 *
8145
+	 * @param    boolean $use Whether to try to use cURL
8146
+	 * @access   public
8147
+	 */
8148
+	function setUseCURL($use)
8149
+	{
8150
+		$this->debug("setUseCURL($use)");
8151
+		$this->use_curl = $use;
8152
+	}
8153
+
8154
+	/**
8155
+	 * use HTTP persistent connections if possible
8156
+	 *
8157
+	 * @access   public
8158
+	 */
8159
+	function useHTTPPersistentConnection()
8160
+	{
8161
+		$this->debug("useHTTPPersistentConnection");
8162
+		$this->persistentConnection = true;
8163
+	}
8164
+
8165
+	/**
8166
+	 * gets the default RPC parameter setting.
8167
+	 * If true, default is that call params are like RPC even for document style.
8168
+	 * Each call() can override this value.
8169
+	 *
8170
+	 * This is no longer used.
8171
+	 *
8172
+	 * @return boolean
8173
+	 * @access public
8174
+	 * @deprecated
8175
+	 */
8176
+	function getDefaultRpcParams()
8177
+	{
8178
+		return $this->defaultRpcParams;
8179
+	}
8180
+
8181
+	/**
8182
+	 * sets the default RPC parameter setting.
8183
+	 * If true, default is that call params are like RPC even for document style
8184
+	 * Each call() can override this value.
8185
+	 *
8186
+	 * This is no longer used.
8187
+	 *
8188
+	 * @param    boolean $rpcParams
8189
+	 * @access public
8190
+	 * @deprecated
8191
+	 */
8192
+	function setDefaultRpcParams($rpcParams)
8193
+	{
8194
+		$this->defaultRpcParams = $rpcParams;
8195
+	}
8196
+
8197
+	/**
8198
+	 * dynamically creates an instance of a proxy class,
8199
+	 * allowing user to directly call methods from wsdl
8200
+	 *
8201
+	 * @return   object soap_proxy object
8202
+	 * @access   public
8203
+	 */
8204
+	function getProxy()
8205
+	{
8206
+		$r = rand();
8207
+		$evalStr = $this->_getProxyClassCode($r);
8208
+		//$this->debug("proxy class: $evalStr");
8209
+		if ($this->getError()) {
8210
+			$this->debug("Error from _getProxyClassCode, so return null");
8211
+			return null;
8212
+		}
8213
+		// eval the class
8214
+		eval($evalStr);
8215
+		// instantiate proxy object
8216
+		/** @var nusoap_client $proxy */
8217
+		eval("\$proxy = new nusoap_proxy_$r('');");
8218
+		// transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
8219
+		$proxy->endpointType = 'wsdl';
8220
+		$proxy->wsdlFile = $this->wsdlFile;
8221
+		$proxy->wsdl = $this->wsdl;
8222
+		$proxy->operations = $this->operations;
8223
+		$proxy->defaultRpcParams = $this->defaultRpcParams;
8224
+		// transfer other state
8225
+		$proxy->soap_defencoding = $this->soap_defencoding;
8226
+		$proxy->username = $this->username;
8227
+		$proxy->password = $this->password;
8228
+		$proxy->authtype = $this->authtype;
8229
+		$proxy->certRequest = $this->certRequest;
8230
+		$proxy->requestHeaders = $this->requestHeaders;
8231
+		$proxy->endpoint = $this->endpoint;
8232
+		$proxy->forceEndpoint = $this->forceEndpoint;
8233
+		$proxy->proxyhost = $this->proxyhost;
8234
+		$proxy->proxyport = $this->proxyport;
8235
+		$proxy->proxyusername = $this->proxyusername;
8236
+		$proxy->proxypassword = $this->proxypassword;
8237
+		$proxy->http_encoding = $this->http_encoding;
8238
+		$proxy->timeout = $this->timeout;
8239
+		$proxy->response_timeout = $this->response_timeout;
8240
+		$proxy->persistentConnection = &$this->persistentConnection;
8241
+		$proxy->decode_utf8 = $this->decode_utf8;
8242
+		$proxy->curl_options = $this->curl_options;
8243
+		$proxy->bindingType = $this->bindingType;
8244
+		$proxy->use_curl = $this->use_curl;
8245
+		return $proxy;
8246
+	}
8247
+
8248
+	/**
8249
+	 * dynamically creates proxy class code
8250
+	 *
8251
+	 * @return   string PHP/NuSOAP code for the proxy class
8252
+	 * @access   private
8253
+	 */
8254
+	function _getProxyClassCode($r)
8255
+	{
8256
+		$this->debug("in getProxy endpointType=$this->endpointType");
8257
+		$this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
8258
+		if ($this->endpointType != 'wsdl') {
8259
+			$evalStr = 'A proxy can only be created for a WSDL client';
8260
+			$this->setError($evalStr);
8261
+
8262
+		  return "echo \"$evalStr\";";
8263
+		}
8264
+		if (is_null($this->wsdl)) {
8265
+			$this->loadWSDL();
8266
+			if ($this->getError()) {
8267
+				return "echo \"" . $this->getError() . "\";";
8268
+			}
8269
+		}
8270
+		$evalStr = '';
8271
+		foreach ($this->operations as $operation => $opData) {
8272
+			if ($operation != '') {
8273
+				$paramStr = '';
8274
+				$paramArrayStr = '';
8275
+				// create param string and param comment string
8276
+				if (sizeof($opData['input']['parts']) > 0) {
8277
+					$paramCommentStr = '';
8278
+					foreach ($opData['input']['parts'] as $name => $type) {
8279
+						$paramStr .= "\$$name, ";
8280
+						$paramArrayStr .= "'$name' => \$$name, ";
8281
+						$paramCommentStr .= "$type \$$name, ";
8282
+					}
8283
+					$paramStr = substr($paramStr, 0, strlen($paramStr) - 2);
8284
+					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2);
8285
+					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2);
8286
+				} else {
8287
+					$paramCommentStr = 'void';
8288
+				}
8289
+				$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
8290
+				$evalStr .= "// $paramCommentStr
8291 8291
 	function " . str_replace('.', '__', $operation) . "($paramStr) {
8292 8292
 		\$params = array($paramArrayStr);
8293 8293
 		return \$this->call('$operation', \$params, '" . $opData['namespace'] . "', '" . (isset($opData['soapAction']) ? $opData['soapAction'] : '') . "');
8294 8294
 	}
8295 8295
 	";
8296
-                unset($paramStr);
8297
-                unset($paramCommentStr);
8298
-            }
8299
-        }
8296
+				unset($paramStr);
8297
+				unset($paramCommentStr);
8298
+			}
8299
+		}
8300 8300
 
8301
-      return 'class nusoap_proxy_' . $r . ' extends nusoap_client {
8301
+	  return 'class nusoap_proxy_' . $r . ' extends nusoap_client {
8302 8302
 ' . $evalStr . '
8303 8303
 }';
8304
-    }
8305
-
8306
-    /**
8307
-     * dynamically creates proxy class code
8308
-     *
8309
-     * @return   string PHP/NuSOAP code for the proxy class
8310
-     * @access   public
8311
-     */
8312
-    function getProxyClassCode()
8313
-    {
8314
-        $r = rand();
8315
-        return $this->_getProxyClassCode($r);
8316
-    }
8317
-
8318
-    /**
8319
-     * gets the HTTP body for the current request.
8320
-     *
8321
-     * @param string $soapmsg The SOAP payload
8322
-     * @return string The HTTP body, which includes the SOAP payload
8323
-     * @access private
8324
-     */
8325
-    function getHTTPBody($soapmsg)
8326
-    {
8327
-        return $soapmsg;
8328
-    }
8329
-
8330
-    /**
8331
-     * gets the HTTP content type for the current request.
8332
-     *
8333
-     * Note: getHTTPBody must be called before this.
8334
-     *
8335
-     * @return string the HTTP content type for the current request.
8336
-     * @access private
8337
-     */
8338
-    function getHTTPContentType()
8339
-    {
8340
-        return $this->contentType;
8341
-    }
8342
-
8343
-    /**
8344
-     * allows you to change the HTTP ContentType of the request.
8345
-     *
8346
-     * @param   string $contentTypeNew
8347
-     * @return  void
8348
-     */
8349
-    function setHTTPContentType($contentTypeNew = "text/xml"){
8350
-        $this->contentType = $contentTypeNew;
8351
-    }
8352
-
8353
-    /**
8354
-     * gets the HTTP content type charset for the current request.
8355
-     * returns false for non-text content types.
8356
-     *
8357
-     * Note: getHTTPBody must be called before this.
8358
-     *
8359
-     * @return string the HTTP content type charset for the current request.
8360
-     * @access private
8361
-     */
8362
-    function getHTTPContentTypeCharset()
8363
-    {
8364
-        return $this->soap_defencoding;
8365
-    }
8366
-
8367
-    /*
8304
+	}
8305
+
8306
+	/**
8307
+	 * dynamically creates proxy class code
8308
+	 *
8309
+	 * @return   string PHP/NuSOAP code for the proxy class
8310
+	 * @access   public
8311
+	 */
8312
+	function getProxyClassCode()
8313
+	{
8314
+		$r = rand();
8315
+		return $this->_getProxyClassCode($r);
8316
+	}
8317
+
8318
+	/**
8319
+	 * gets the HTTP body for the current request.
8320
+	 *
8321
+	 * @param string $soapmsg The SOAP payload
8322
+	 * @return string The HTTP body, which includes the SOAP payload
8323
+	 * @access private
8324
+	 */
8325
+	function getHTTPBody($soapmsg)
8326
+	{
8327
+		return $soapmsg;
8328
+	}
8329
+
8330
+	/**
8331
+	 * gets the HTTP content type for the current request.
8332
+	 *
8333
+	 * Note: getHTTPBody must be called before this.
8334
+	 *
8335
+	 * @return string the HTTP content type for the current request.
8336
+	 * @access private
8337
+	 */
8338
+	function getHTTPContentType()
8339
+	{
8340
+		return $this->contentType;
8341
+	}
8342
+
8343
+	/**
8344
+	 * allows you to change the HTTP ContentType of the request.
8345
+	 *
8346
+	 * @param   string $contentTypeNew
8347
+	 * @return  void
8348
+	 */
8349
+	function setHTTPContentType($contentTypeNew = "text/xml"){
8350
+		$this->contentType = $contentTypeNew;
8351
+	}
8352
+
8353
+	/**
8354
+	 * gets the HTTP content type charset for the current request.
8355
+	 * returns false for non-text content types.
8356
+	 *
8357
+	 * Note: getHTTPBody must be called before this.
8358
+	 *
8359
+	 * @return string the HTTP content type charset for the current request.
8360
+	 * @access private
8361
+	 */
8362
+	function getHTTPContentTypeCharset()
8363
+	{
8364
+		return $this->soap_defencoding;
8365
+	}
8366
+
8367
+	/*
8368 8368
 	* whether or not parser should decode utf8 element content
8369 8369
     *
8370 8370
     * @return   always returns true
8371 8371
     * @access   public
8372 8372
     */
8373
-    function decodeUTF8($bool)
8374
-    {
8375
-        $this->decode_utf8 = $bool;
8376
-        return true;
8377
-    }
8378
-
8379
-    /**
8380
-     * adds a new Cookie into $this->cookies array
8381
-     *
8382
-     * @param    string $name Cookie Name
8383
-     * @param    string $value Cookie Value
8384
-     * @return    boolean if cookie-set was successful returns true, else false
8385
-     * @access    public
8386
-     */
8387
-    function setCookie($name, $value)
8388
-    {
8389
-        if (strlen($name) == 0) {
8390
-            return false;
8391
-        }
8392
-        $this->cookies[] = array('name' => $name, 'value' => $value);
8393
-        return true;
8394
-    }
8395
-
8396
-    /**
8397
-     * gets all Cookies
8398
-     *
8399
-     * @return   array with all internal cookies
8400
-     * @access   public
8401
-     */
8402
-    function getCookies()
8403
-    {
8404
-        return $this->cookies;
8405
-    }
8406
-
8407
-    /**
8408
-     * checks all Cookies and delete those which are expired
8409
-     *
8410
-     * @return   boolean always return true
8411
-     * @access   private
8412
-     */
8413
-    function checkCookies()
8414
-    {
8415
-        if (sizeof($this->cookies) == 0) {
8416
-            return true;
8417
-        }
8418
-        $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
8419
-        $curr_cookies = $this->cookies;
8420
-        $this->cookies = array();
8421
-        foreach ($curr_cookies as $cookie) {
8422
-            if (!is_array($cookie)) {
8423
-                $this->debug('Remove cookie that is not an array');
8424
-                continue;
8425
-            }
8426
-            if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
8427
-                if (strtotime($cookie['expires']) > time()) {
8428
-                    $this->cookies[] = $cookie;
8429
-                } else {
8430
-                    $this->debug('Remove expired cookie ' . $cookie['name']);
8431
-                }
8432
-            } else {
8433
-                $this->cookies[] = $cookie;
8434
-            }
8435
-        }
8436
-        $this->debug('checkCookie: ' . sizeof($this->cookies) . ' cookies left in array');
8437
-        return true;
8438
-    }
8439
-
8440
-    /**
8441
-     * updates the current cookies with a new set
8442
-     *
8443
-     * @param    array $cookies new cookies with which to update current ones
8444
-     * @return    boolean always return true
8445
-     * @access    private
8446
-     */
8447
-    function UpdateCookies($cookies)
8448
-    {
8449
-        if (sizeof($this->cookies) == 0) {
8450
-            // no existing cookies: take whatever is new
8451
-            if (sizeof($cookies) > 0) {
8452
-                $this->debug('Setting new cookie(s)');
8453
-                $this->cookies = $cookies;
8454
-            }
8455
-            return true;
8456
-        }
8457
-        if (sizeof($cookies) == 0) {
8458
-            // no new cookies: keep what we've got
8459
-            return true;
8460
-        }
8461
-        // merge
8462
-        foreach ($cookies as $newCookie) {
8463
-            if (!is_array($newCookie)) {
8464
-                continue;
8465
-            }
8466
-            if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
8467
-                continue;
8468
-            }
8469
-            $newName = $newCookie['name'];
8470
-
8471
-            $found = false;
8472
-            for ($i = 0; $i < count($this->cookies); $i++) {
8473
-                $cookie = $this->cookies[$i];
8474
-                if (!is_array($cookie)) {
8475
-                    continue;
8476
-                }
8477
-                if (!isset($cookie['name'])) {
8478
-                    continue;
8479
-                }
8480
-                if ($newName != $cookie['name']) {
8481
-                    continue;
8482
-                }
8483
-                $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
8484
-                $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
8485
-                if ($newDomain != $domain) {
8486
-                    continue;
8487
-                }
8488
-                $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
8489
-                $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
8490
-                if ($newPath != $path) {
8491
-                    continue;
8492
-                }
8493
-                $this->cookies[$i] = $newCookie;
8494
-                $found = true;
8495
-                $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
8496
-                break;
8497
-            }
8498
-            if (!$found) {
8499
-                $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
8500
-                $this->cookies[] = $newCookie;
8501
-            }
8502
-        }
8503
-        return true;
8504
-    }
8373
+	function decodeUTF8($bool)
8374
+	{
8375
+		$this->decode_utf8 = $bool;
8376
+		return true;
8377
+	}
8378
+
8379
+	/**
8380
+	 * adds a new Cookie into $this->cookies array
8381
+	 *
8382
+	 * @param    string $name Cookie Name
8383
+	 * @param    string $value Cookie Value
8384
+	 * @return    boolean if cookie-set was successful returns true, else false
8385
+	 * @access    public
8386
+	 */
8387
+	function setCookie($name, $value)
8388
+	{
8389
+		if (strlen($name) == 0) {
8390
+			return false;
8391
+		}
8392
+		$this->cookies[] = array('name' => $name, 'value' => $value);
8393
+		return true;
8394
+	}
8395
+
8396
+	/**
8397
+	 * gets all Cookies
8398
+	 *
8399
+	 * @return   array with all internal cookies
8400
+	 * @access   public
8401
+	 */
8402
+	function getCookies()
8403
+	{
8404
+		return $this->cookies;
8405
+	}
8406
+
8407
+	/**
8408
+	 * checks all Cookies and delete those which are expired
8409
+	 *
8410
+	 * @return   boolean always return true
8411
+	 * @access   private
8412
+	 */
8413
+	function checkCookies()
8414
+	{
8415
+		if (sizeof($this->cookies) == 0) {
8416
+			return true;
8417
+		}
8418
+		$this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
8419
+		$curr_cookies = $this->cookies;
8420
+		$this->cookies = array();
8421
+		foreach ($curr_cookies as $cookie) {
8422
+			if (!is_array($cookie)) {
8423
+				$this->debug('Remove cookie that is not an array');
8424
+				continue;
8425
+			}
8426
+			if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
8427
+				if (strtotime($cookie['expires']) > time()) {
8428
+					$this->cookies[] = $cookie;
8429
+				} else {
8430
+					$this->debug('Remove expired cookie ' . $cookie['name']);
8431
+				}
8432
+			} else {
8433
+				$this->cookies[] = $cookie;
8434
+			}
8435
+		}
8436
+		$this->debug('checkCookie: ' . sizeof($this->cookies) . ' cookies left in array');
8437
+		return true;
8438
+	}
8439
+
8440
+	/**
8441
+	 * updates the current cookies with a new set
8442
+	 *
8443
+	 * @param    array $cookies new cookies with which to update current ones
8444
+	 * @return    boolean always return true
8445
+	 * @access    private
8446
+	 */
8447
+	function UpdateCookies($cookies)
8448
+	{
8449
+		if (sizeof($this->cookies) == 0) {
8450
+			// no existing cookies: take whatever is new
8451
+			if (sizeof($cookies) > 0) {
8452
+				$this->debug('Setting new cookie(s)');
8453
+				$this->cookies = $cookies;
8454
+			}
8455
+			return true;
8456
+		}
8457
+		if (sizeof($cookies) == 0) {
8458
+			// no new cookies: keep what we've got
8459
+			return true;
8460
+		}
8461
+		// merge
8462
+		foreach ($cookies as $newCookie) {
8463
+			if (!is_array($newCookie)) {
8464
+				continue;
8465
+			}
8466
+			if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
8467
+				continue;
8468
+			}
8469
+			$newName = $newCookie['name'];
8470
+
8471
+			$found = false;
8472
+			for ($i = 0; $i < count($this->cookies); $i++) {
8473
+				$cookie = $this->cookies[$i];
8474
+				if (!is_array($cookie)) {
8475
+					continue;
8476
+				}
8477
+				if (!isset($cookie['name'])) {
8478
+					continue;
8479
+				}
8480
+				if ($newName != $cookie['name']) {
8481
+					continue;
8482
+				}
8483
+				$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
8484
+				$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
8485
+				if ($newDomain != $domain) {
8486
+					continue;
8487
+				}
8488
+				$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
8489
+				$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
8490
+				if ($newPath != $path) {
8491
+					continue;
8492
+				}
8493
+				$this->cookies[$i] = $newCookie;
8494
+				$found = true;
8495
+				$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
8496
+				break;
8497
+			}
8498
+			if (!$found) {
8499
+				$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
8500
+				$this->cookies[] = $newCookie;
8501
+			}
8502
+		}
8503
+		return true;
8504
+	}
8505 8505
 }
8506 8506
 
8507 8507
 
8508 8508
 if (!extension_loaded('soap')) {
8509
-    /**
8510
-     *    For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
8511
-     */
8512
-    class soapclient extends nusoap_client
8513
-    {
8514
-    }
8509
+	/**
8510
+	 *    For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
8511
+	 */
8512
+	class soapclient extends nusoap_client
8513
+	{
8514
+	}
8515 8515
 }
8516 8516
 
8517 8517
 /**
@@ -8523,189 +8523,189 @@  discard block
 block discarded – undo
8523 8523
  * @access public
8524 8524
  */
8525 8525
 class nusoap_wsdlcache {
8526
-    /**
8527
-     *	@var resource
8528
-     *	@access private
8529
-     */
8530
-    var $fplock;
8531
-    /**
8532
-     *	@var integer
8533
-     *	@access private
8534
-     */
8535
-    var $cache_lifetime;
8536
-    /**
8537
-     *	@var string
8538
-     *	@access private
8539
-     */
8540
-    var $cache_dir;
8541
-    /**
8542
-     *	@var string
8543
-     *	@access public
8544
-     */
8545
-    var $debug_str = '';
8546
-
8547
-    /**
8548
-     * constructor
8549
-     *
8550
-     * @param string $cache_dir directory for cache-files
8551
-     * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
8552
-     * @access public
8553
-     */
8554
-    function __construct($cache_dir='.', $cache_lifetime=0) {
8555
-        $this->fplock = array();
8556
-        $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
8557
-        $this->cache_lifetime = $cache_lifetime;
8558
-    }
8559
-
8560
-    /**
8561
-     * creates the filename used to cache a wsdl instance
8562
-     *
8563
-     * @param string $wsdl The URL of the wsdl instance
8564
-     * @return string The filename used to cache the instance
8565
-     * @access private
8566
-     */
8567
-    function createFilename($wsdl) {
8568
-        return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
8569
-    }
8570
-
8571
-    /**
8572
-     * adds debug data to the class level debug string
8573
-     *
8574
-     * @param    string $string debug data
8575
-     * @access   private
8576
-     */
8577
-    function debug($string){
8578
-        $this->debug_str .= get_class($this).": $string\n";
8579
-    }
8580
-
8581
-    /**
8582
-     * gets a wsdl instance from the cache
8583
-     *
8584
-     * @param string $wsdl The URL of the wsdl instance
8585
-     * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
8586
-     * @access public
8587
-     */
8588
-    function get($wsdl) {
8589
-        $filename = $this->createFilename($wsdl);
8590
-        if ($this->obtainMutex($filename, "r")) {
8591
-            // check for expired WSDL that must be removed from the cache
8592
-            if ($this->cache_lifetime > 0) {
8593
-                if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
8594
-                    unlink($filename);
8595
-                    $this->debug("Expired $wsdl ($filename) from cache");
8596
-                    $this->releaseMutex($filename);
8597
-                    return null;
8598
-                }
8599
-            }
8600
-            // see what there is to return
8601
-            if (!file_exists($filename)) {
8602
-                $this->debug("$wsdl ($filename) not in cache (1)");
8603
-                $this->releaseMutex($filename);
8604
-                return null;
8605
-            }
8606
-            $fp = @fopen($filename, "r");
8607
-            if ($fp) {
8608
-                $s = implode("", @file($filename));
8609
-                fclose($fp);
8610
-                $this->debug("Got $wsdl ($filename) from cache");
8611
-            } else {
8612
-                $s = null;
8613
-                $this->debug("$wsdl ($filename) not in cache (2)");
8614
-            }
8615
-            $this->releaseMutex($filename);
8616
-            return (!is_null($s)) ? unserialize($s) : null;
8617
-        } else {
8618
-            $this->debug("Unable to obtain mutex for $filename in get");
8619
-        }
8620
-        return null;
8621
-    }
8622
-
8623
-    /**
8624
-     * obtains the local mutex
8625
-     *
8626
-     * @param string $filename The Filename of the Cache to lock
8627
-     * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
8628
-     * @return boolean Lock successfully obtained ?!
8629
-     * @access private
8630
-     */
8631
-    function obtainMutex($filename, $mode) {
8632
-        if (isset($this->fplock[md5($filename)])) {
8633
-            $this->debug("Lock for $filename already exists");
8634
-            return false;
8635
-        }
8636
-        $this->fplock[md5($filename)] = fopen($filename.".lock", "w");
8637
-        if ($mode == "r") {
8638
-            return flock($this->fplock[md5($filename)], LOCK_SH);
8639
-        } else {
8640
-            return flock($this->fplock[md5($filename)], LOCK_EX);
8641
-        }
8642
-    }
8643
-
8644
-    /**
8645
-     * adds a wsdl instance to the cache
8646
-     *
8647
-     * @param wsdl $wsdl_instance The wsdl instance to add
8648
-     * @return boolean WSDL successfully cached
8649
-     * @access public
8650
-     */
8651
-    function put($wsdl_instance) {
8652
-        $filename = $this->createFilename($wsdl_instance->wsdl);
8653
-        $s = serialize($wsdl_instance);
8654
-        if ($this->obtainMutex($filename, "w")) {
8655
-            $fp = fopen($filename, "w");
8656
-            if (! $fp) {
8657
-                $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
8658
-                $this->releaseMutex($filename);
8659
-                return false;
8660
-            }
8661
-            fputs($fp, $s);
8662
-            fclose($fp);
8663
-            $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
8664
-            $this->releaseMutex($filename);
8665
-            return true;
8666
-        } else {
8667
-            $this->debug("Unable to obtain mutex for $filename in put");
8668
-        }
8669
-        return false;
8670
-    }
8671
-
8672
-    /**
8673
-     * releases the local mutex
8674
-     *
8675
-     * @param string $filename The Filename of the Cache to lock
8676
-     * @return boolean Lock successfully released
8677
-     * @access private
8678
-     */
8679
-    function releaseMutex($filename) {
8680
-        $ret = flock($this->fplock[md5($filename)], LOCK_UN);
8681
-        fclose($this->fplock[md5($filename)]);
8682
-        unset($this->fplock[md5($filename)]);
8683
-        if (! $ret) {
8684
-            $this->debug("Not able to release lock for $filename");
8685
-        }
8686
-        return $ret;
8687
-    }
8688
-
8689
-    /**
8690
-     * removes a wsdl instance from the cache
8691
-     *
8692
-     * @param string $wsdl The URL of the wsdl instance
8693
-     * @return boolean Whether there was an instance to remove
8694
-     * @access public
8695
-     */
8696
-    function remove($wsdl) {
8697
-        $filename = $this->createFilename($wsdl);
8698
-        if (!file_exists($filename)) {
8699
-            $this->debug("$wsdl ($filename) not in cache to be removed");
8700
-            return false;
8701
-        }
8702
-        // ignore errors obtaining mutex
8703
-        $this->obtainMutex($filename, "w");
8704
-        $ret = unlink($filename);
8705
-        $this->debug("Removed ($ret) $wsdl ($filename) from cache");
8706
-        $this->releaseMutex($filename);
8707
-        return $ret;
8708
-    }
8526
+	/**
8527
+	 *	@var resource
8528
+	 *	@access private
8529
+	 */
8530
+	var $fplock;
8531
+	/**
8532
+	 *	@var integer
8533
+	 *	@access private
8534
+	 */
8535
+	var $cache_lifetime;
8536
+	/**
8537
+	 *	@var string
8538
+	 *	@access private
8539
+	 */
8540
+	var $cache_dir;
8541
+	/**
8542
+	 *	@var string
8543
+	 *	@access public
8544
+	 */
8545
+	var $debug_str = '';
8546
+
8547
+	/**
8548
+	 * constructor
8549
+	 *
8550
+	 * @param string $cache_dir directory for cache-files
8551
+	 * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
8552
+	 * @access public
8553
+	 */
8554
+	function __construct($cache_dir='.', $cache_lifetime=0) {
8555
+		$this->fplock = array();
8556
+		$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
8557
+		$this->cache_lifetime = $cache_lifetime;
8558
+	}
8559
+
8560
+	/**
8561
+	 * creates the filename used to cache a wsdl instance
8562
+	 *
8563
+	 * @param string $wsdl The URL of the wsdl instance
8564
+	 * @return string The filename used to cache the instance
8565
+	 * @access private
8566
+	 */
8567
+	function createFilename($wsdl) {
8568
+		return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
8569
+	}
8570
+
8571
+	/**
8572
+	 * adds debug data to the class level debug string
8573
+	 *
8574
+	 * @param    string $string debug data
8575
+	 * @access   private
8576
+	 */
8577
+	function debug($string){
8578
+		$this->debug_str .= get_class($this).": $string\n";
8579
+	}
8580
+
8581
+	/**
8582
+	 * gets a wsdl instance from the cache
8583
+	 *
8584
+	 * @param string $wsdl The URL of the wsdl instance
8585
+	 * @return object wsdl The cached wsdl instance, null if the instance is not in the cache
8586
+	 * @access public
8587
+	 */
8588
+	function get($wsdl) {
8589
+		$filename = $this->createFilename($wsdl);
8590
+		if ($this->obtainMutex($filename, "r")) {
8591
+			// check for expired WSDL that must be removed from the cache
8592
+			if ($this->cache_lifetime > 0) {
8593
+				if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
8594
+					unlink($filename);
8595
+					$this->debug("Expired $wsdl ($filename) from cache");
8596
+					$this->releaseMutex($filename);
8597
+					return null;
8598
+				}
8599
+			}
8600
+			// see what there is to return
8601
+			if (!file_exists($filename)) {
8602
+				$this->debug("$wsdl ($filename) not in cache (1)");
8603
+				$this->releaseMutex($filename);
8604
+				return null;
8605
+			}
8606
+			$fp = @fopen($filename, "r");
8607
+			if ($fp) {
8608
+				$s = implode("", @file($filename));
8609
+				fclose($fp);
8610
+				$this->debug("Got $wsdl ($filename) from cache");
8611
+			} else {
8612
+				$s = null;
8613
+				$this->debug("$wsdl ($filename) not in cache (2)");
8614
+			}
8615
+			$this->releaseMutex($filename);
8616
+			return (!is_null($s)) ? unserialize($s) : null;
8617
+		} else {
8618
+			$this->debug("Unable to obtain mutex for $filename in get");
8619
+		}
8620
+		return null;
8621
+	}
8622
+
8623
+	/**
8624
+	 * obtains the local mutex
8625
+	 *
8626
+	 * @param string $filename The Filename of the Cache to lock
8627
+	 * @param string $mode The open-mode ("r" or "w") or the file - affects lock-mode
8628
+	 * @return boolean Lock successfully obtained ?!
8629
+	 * @access private
8630
+	 */
8631
+	function obtainMutex($filename, $mode) {
8632
+		if (isset($this->fplock[md5($filename)])) {
8633
+			$this->debug("Lock for $filename already exists");
8634
+			return false;
8635
+		}
8636
+		$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
8637
+		if ($mode == "r") {
8638
+			return flock($this->fplock[md5($filename)], LOCK_SH);
8639
+		} else {
8640
+			return flock($this->fplock[md5($filename)], LOCK_EX);
8641
+		}
8642
+	}
8643
+
8644
+	/**
8645
+	 * adds a wsdl instance to the cache
8646
+	 *
8647
+	 * @param wsdl $wsdl_instance The wsdl instance to add
8648
+	 * @return boolean WSDL successfully cached
8649
+	 * @access public
8650
+	 */
8651
+	function put($wsdl_instance) {
8652
+		$filename = $this->createFilename($wsdl_instance->wsdl);
8653
+		$s = serialize($wsdl_instance);
8654
+		if ($this->obtainMutex($filename, "w")) {
8655
+			$fp = fopen($filename, "w");
8656
+			if (! $fp) {
8657
+				$this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
8658
+				$this->releaseMutex($filename);
8659
+				return false;
8660
+			}
8661
+			fputs($fp, $s);
8662
+			fclose($fp);
8663
+			$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
8664
+			$this->releaseMutex($filename);
8665
+			return true;
8666
+		} else {
8667
+			$this->debug("Unable to obtain mutex for $filename in put");
8668
+		}
8669
+		return false;
8670
+	}
8671
+
8672
+	/**
8673
+	 * releases the local mutex
8674
+	 *
8675
+	 * @param string $filename The Filename of the Cache to lock
8676
+	 * @return boolean Lock successfully released
8677
+	 * @access private
8678
+	 */
8679
+	function releaseMutex($filename) {
8680
+		$ret = flock($this->fplock[md5($filename)], LOCK_UN);
8681
+		fclose($this->fplock[md5($filename)]);
8682
+		unset($this->fplock[md5($filename)]);
8683
+		if (! $ret) {
8684
+			$this->debug("Not able to release lock for $filename");
8685
+		}
8686
+		return $ret;
8687
+	}
8688
+
8689
+	/**
8690
+	 * removes a wsdl instance from the cache
8691
+	 *
8692
+	 * @param string $wsdl The URL of the wsdl instance
8693
+	 * @return boolean Whether there was an instance to remove
8694
+	 * @access public
8695
+	 */
8696
+	function remove($wsdl) {
8697
+		$filename = $this->createFilename($wsdl);
8698
+		if (!file_exists($filename)) {
8699
+			$this->debug("$wsdl ($filename) not in cache to be removed");
8700
+			return false;
8701
+		}
8702
+		// ignore errors obtaining mutex
8703
+		$this->obtainMutex($filename, "w");
8704
+		$ret = unlink($filename);
8705
+		$this->debug("Removed ($ret) $wsdl ($filename) from cache");
8706
+		$this->releaseMutex($filename);
8707
+		return $ret;
8708
+	}
8709 8709
 }
8710 8710
 
8711 8711
 /**
Please login to merge, or discard this patch.
Spacing   +520 added lines, -522 removed lines patch added patch discarded remove patch
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
     function debug($string)
292 292
     {
293 293
         if ($this->debugLevel > 0) {
294
-            $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n");
294
+            $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n");
295 295
         }
296 296
     }
297 297
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         while (strpos($this->debug_str, '--')) {
350 350
             $this->debug_str = str_replace('--', '- -', $this->debug_str);
351 351
         }
352
-        $ret = "<!--\n" . $this->debug_str . "\n-->";
352
+        $ret = "<!--\n".$this->debug_str."\n-->";
353 353
         return $ret;
354 354
     }
355 355
 
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
     function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false)
433 433
     {
434 434
         $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
435
-        $this->appendDebug('value=' . $this->varDump($val));
436
-        $this->appendDebug('attributes=' . $this->varDump($attributes));
435
+        $this->appendDebug('value='.$this->varDump($val));
436
+        $this->appendDebug('attributes='.$this->varDump($attributes));
437 437
 
438 438
         if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
439 439
             $this->debug("serialize_val: serialize soapval");
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
         }
446 446
         // force valid name if necessary
447 447
         if (is_numeric($name)) {
448
-            $name = '__numeric_' . $name;
448
+            $name = '__numeric_'.$name;
449 449
         } elseif (!$name) {
450 450
             $name = 'noname';
451 451
         }
452 452
         // if name has ns, add ns prefix to name
453 453
         $xmlns = '';
454 454
         if ($name_ns) {
455
-            $prefix = 'nu' . rand(1000, 9999);
456
-            $name = $prefix . ':' . $name;
455
+            $prefix = 'nu'.rand(1000, 9999);
456
+            $name = $prefix.':'.$name;
457 457
             $xmlns .= " xmlns:$prefix=\"$name_ns\"";
458 458
         }
459 459
         // if type is prefixed, create type prefix
@@ -462,14 +462,14 @@  discard block
 block discarded – undo
462 462
             // w/o checking against typemap
463 463
             $type_prefix = 'xsd';
464 464
         } elseif ($type_ns) {
465
-            $type_prefix = 'ns' . rand(1000, 9999);
465
+            $type_prefix = 'ns'.rand(1000, 9999);
466 466
             $xmlns .= " xmlns:$type_prefix=\"$type_ns\"";
467 467
         }
468 468
         // serialize attributes if present
469 469
         $atts = '';
470 470
         if ($attributes) {
471 471
             foreach ($attributes as $k => $v) {
472
-                $atts .= " $k=\"" . $this->expandEntities($v) . '"';
472
+                $atts .= " $k=\"".$this->expandEntities($v).'"';
473 473
             }
474 474
         }
475 475
         // serialize null value
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
                         $name = get_class($val);
564 564
                         $this->debug("In serialize_val, used class name $name as element name");
565 565
                     } else {
566
-                        $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
566
+                        $this->debug("In serialize_val, do not override name $name for element name for class ".get_class($val));
567 567
                     }
568 568
                     foreach (get_object_vars($val) as $k => $v) {
569
-                        $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
569
+                        $pXml = isset($pXml) ? $pXml.$this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use);
570 570
                     }
571 571
                 }
572 572
                 if (isset($type) && isset($type_prefix)) {
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
                     $this->debug("serialize_val: serialize array");
588 588
                     $i = 0;
589 589
                     if (is_array($val) && count($val) > 0) {
590
-                        $array_types = array ();
590
+                        $array_types = array();
591 591
                         $tt_ns = "";
592 592
                         $tt = "";
593 593
                         foreach ($val as $v) {
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
                             if ($tt == 'integer') {
611 611
                                 $tt = 'int';
612 612
                             }
613
-                            $array_typename = 'xsd:' . $tt;
613
+                            $array_typename = 'xsd:'.$tt;
614 614
                         } elseif (isset($tt) && $tt == 'arraySimple') {
615 615
                             $array_typename = 'SOAP-ENC:Array';
616 616
                         } elseif (isset($tt) && $tt == 'arrayStruct') {
@@ -618,9 +618,9 @@  discard block
 block discarded – undo
618 618
                         } else {
619 619
                             // if type is prefixed, create type prefix
620 620
                             if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
621
-                                $array_typename = 'xsd:' . $tt;
621
+                                $array_typename = 'xsd:'.$tt;
622 622
                             } elseif ($tt_ns) {
623
-                                $tt_prefix = 'ns' . rand(1000, 9999);
623
+                                $tt_prefix = 'ns'.rand(1000, 9999);
624 624
                                 $array_typename = "$tt_prefix:$tt";
625 625
                                 $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\"";
626 626
                             } else {
@@ -633,7 +633,7 @@  discard block
 block discarded – undo
633 633
                         } elseif (isset($type) && isset($type_prefix)) {
634 634
                             $type_str = " xsi:type=\"$type_prefix:$type\"";
635 635
                         } else {
636
-                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\"";
636
+                            $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\"";
637 637
                         }
638 638
                         // empty array
639 639
                     } else {
@@ -646,7 +646,7 @@  discard block
 block discarded – undo
646 646
                         }
647 647
                     }
648 648
                     // TODO: for array in literal, there is no wrapper here
649
-                    $xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>";
649
+                    $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>";
650 650
                 } else {
651 651
                     // got a struct
652 652
                     $this->debug("serialize_val: serialize struct");
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
                 break;
677 677
             default:
678 678
                 $this->debug("serialize_val: serialize unknown");
679
-                $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val;
679
+                $xml .= 'not detected, got '.gettype($val).' for '.$val;
680 680
                 break;
681 681
         }
682 682
         $this->debug("serialize_val returning $xml");
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         // if $this->soap_defencoding is UTF-8.  Not doing this automatically allows
702 702
         // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1
703 703
 
704
-        $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
704
+        $this->debug("In serializeEnvelope length=".strlen($body)." body (max 1000 characters)=".substr($body, 0, 1000)." style=$style use=$use encodingStyle=$encodingStyle");
705 705
         $this->debug("headers:");
706 706
         $this->appendDebug($this->varDump($headers));
707 707
         $this->debug("namespaces:");
@@ -730,16 +730,16 @@  discard block
 block discarded – undo
730 730
                 $headers = $xml;
731 731
                 $this->debug("In serializeEnvelope, serialized array of headers to $headers");
732 732
             }
733
-            $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>";
733
+            $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>";
734 734
         }
735 735
         // serialize envelope
736 736
         return
737
-            '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" .
738
-            '<SOAP-ENV:Envelope' . $ns_string . ">" .
739
-            $headers .
740
-            "<SOAP-ENV:Body>" .
741
-            $body .
742
-            "</SOAP-ENV:Body>" .
737
+            '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?'.">".
738
+            '<SOAP-ENV:Envelope'.$ns_string.">".
739
+            $headers.
740
+            "<SOAP-ENV:Body>".
741
+            $body.
742
+            "</SOAP-ENV:Body>".
743 743
             "</SOAP-ENV:Envelope>";
744 744
     }
745 745
 
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
             $ns = substr($qname, 0, strrpos($qname, ':'));
776 776
             $p = $this->getPrefixFromNamespace($ns);
777 777
             if ($p) {
778
-                return $p . ':' . $name;
778
+                return $p.':'.$name;
779 779
             }
780 780
         }
781 781
         return $qname;
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
             // get ns prefix
798 798
             $prefix = substr($qname, 0, strpos($qname, ':'));
799 799
             if (isset($this->namespaces[$prefix])) {
800
-                return $this->namespaces[$prefix] . ':' . $name;
800
+                return $this->namespaces[$prefix].':'.$name;
801 801
             } else {
802 802
                 return $qname;
803 803
             }
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
         }
895 895
         $dtx = new DateTime("@$sec");
896 896
 	return
897
-          date_format($dtx, 'Y-m-d H:i:s') . '.' . sprintf('%06d', $usec);
897
+          date_format($dtx, 'Y-m-d H:i:s').'.'.sprintf('%06d', $usec);
898 898
     }
899 899
 
900 900
     /**
@@ -946,19 +946,19 @@  discard block
 block discarded – undo
946 946
     }
947 947
     if ($pos !== false) {
948 948
         if (strlen($datestr) == $pos + 5) {
949
-            $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
949
+            $datestr = substr($datestr, 0, $pos + 3).':'.substr($datestr, -2);
950 950
         }
951 951
     }
952 952
     if ($utc) {
953
-        $pattern = '/' .
954
-            '([0-9]{4})-' .    // centuries & years CCYY-
955
-            '([0-9]{2})-' .    // months MM-
956
-            '([0-9]{2})' .    // days DD
957
-            'T' .            // separator T
958
-            '([0-9]{2}):' .    // hours hh:
959
-            '([0-9]{2}):' .    // minutes mm:
960
-            '([0-9]{2})(\.[0-9]*)?' . // seconds ss.ss...
961
-            '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
953
+        $pattern = '/'.
954
+            '([0-9]{4})-'.// centuries & years CCYY-
955
+            '([0-9]{2})-'.// months MM-
956
+            '([0-9]{2})'.// days DD
957
+            'T'.// separator T
958
+            '([0-9]{2}):'.// hours hh:
959
+            '([0-9]{2}):'.// minutes mm:
960
+            '([0-9]{2})(\.[0-9]*)?'.// seconds ss.ss...
961
+            '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
962 962
             '/';
963 963
 
964 964
         if (preg_match($pattern, $datestr, $regs)) {
@@ -979,15 +979,15 @@  discard block
 block discarded – undo
979 979
  */
980 980
 function iso8601_to_timestamp($datestr)
981 981
 {
982
-    $pattern = '/' .
983
-        '([0-9]{4})-' .    // centuries & years CCYY-
984
-        '([0-9]{2})-' .    // months MM-
985
-        '([0-9]{2})' .    // days DD
986
-        'T' .            // separator T
987
-        '([0-9]{2}):' .    // hours hh:
988
-        '([0-9]{2}):' .    // minutes mm:
989
-        '([0-9]{2})(\.[0-9]+)?' . // seconds ss.ss...
990
-        '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
982
+    $pattern = '/'.
983
+        '([0-9]{4})-'.// centuries & years CCYY-
984
+        '([0-9]{2})-'.// months MM-
985
+        '([0-9]{2})'.// days DD
986
+        'T'.// separator T
987
+        '([0-9]{2}):'.// hours hh:
988
+        '([0-9]{2}):'.// minutes mm:
989
+        '([0-9]{2})(\.[0-9]+)?'.// seconds ss.ss...
990
+        '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
991 991
         '/';
992 992
     if (preg_match($pattern, $datestr, $regs)) {
993 993
         // not utc
@@ -996,11 +996,11 @@  discard block
 block discarded – undo
996 996
             $h = substr($regs[8], 1, 2);
997 997
             $m = substr($regs[8], strlen($regs[8]) - 2, 2);
998 998
             if ($op == '-') {
999
-                $regs[4] = intval ($regs[4]) + intval ($h);
1000
-                $regs[5] = intval ($regs[5]) + intval ($m);
999
+                $regs[4] = intval($regs[4]) + intval($h);
1000
+                $regs[5] = intval($regs[5]) + intval($m);
1001 1001
             } elseif ($op == '+') {
1002
-                $regs[4] = intval ($regs[4]) - intval ($h);
1003
-                $regs[5] = intval ($regs[5]) - intval ($m);
1002
+                $regs[4] = intval($regs[4]) - intval($h);
1003
+                $regs[5] = intval($regs[5]) - intval($m);
1004 1004
             }
1005 1005
         }
1006 1006
         return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
@@ -1099,16 +1099,16 @@  discard block
 block discarded – undo
1099 1099
             $ns_string .= "\n  xmlns:$k=\"$v\"";
1100 1100
         }
1101 1101
 
1102
-      return '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' .
1103
-       '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" .
1104
-       '<SOAP-ENV:Body>' .
1105
-       '<SOAP-ENV:Fault>' .
1106
-       $this->serialize_val($this->faultcode, 'faultcode') .
1107
-       $this->serialize_val($this->faultstring, 'faultstring') .
1108
-       $this->serialize_val($this->faultactor, 'faultactor') .
1109
-       $this->serialize_val($this->faultdetail, 'detail') .
1110
-       '</SOAP-ENV:Fault>' .
1111
-       '</SOAP-ENV:Body>' .
1102
+      return '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
1103
+       '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
1104
+       '<SOAP-ENV:Body>'.
1105
+       '<SOAP-ENV:Fault>'.
1106
+       $this->serialize_val($this->faultcode, 'faultcode').
1107
+       $this->serialize_val($this->faultstring, 'faultstring').
1108
+       $this->serialize_val($this->faultactor, 'faultactor').
1109
+       $this->serialize_val($this->faultdetail, 'detail').
1110
+       '</SOAP-ENV:Fault>'.
1111
+       '</SOAP-ENV:Body>'.
1112 1112
        '</SOAP-ENV:Envelope>';
1113 1113
     }
1114 1114
 }
@@ -1185,13 +1185,13 @@  discard block
 block discarded – undo
1185 1185
 
1186 1186
         // parse schema file
1187 1187
         if ($schema != '') {
1188
-            $this->debug('initial schema file: ' . $schema);
1188
+            $this->debug('initial schema file: '.$schema);
1189 1189
             $this->parseFile($schema, 'schema');
1190 1190
         }
1191 1191
 
1192 1192
         // parse xml file
1193 1193
         if ($xml != '') {
1194
-            $this->debug('initial xml file: ' . $xml);
1194
+            $this->debug('initial xml file: '.$xml);
1195 1195
             $this->parseFile($xml, 'xml');
1196 1196
         }
1197 1197
 
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
         if ($xml != "") {
1212 1212
             $xmlStr = @join("", @file($xml));
1213 1213
             if ($xmlStr == "") {
1214
-                $msg = 'Error reading XML from ' . $xml;
1214
+                $msg = 'Error reading XML from '.$xml;
1215 1215
                 $this->setError($msg);
1216 1216
                 $this->debug($msg);
1217 1217
                 return false;
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
                 xml_set_character_data_handler($this->parser, 'xmlCharacterData');
1255 1255
             }
1256 1256
 
1257
-            libxml_disable_entity_loader(true);	// Avoid load of external entities (security problem). Required only for libxml < 2.
1257
+            libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only for libxml < 2.
1258 1258
 
1259 1259
             // Parse the XML file.
1260 1260
             if (!xml_parse($this->parser, $xml, true)) {
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
                     xml_error_string(xml_get_error_code($this->parser))
1265 1265
                 );
1266 1266
                 $this->debug($errstr);
1267
-                $this->debug("XML payload:\n" . $xml);
1267
+                $this->debug("XML payload:\n".$xml);
1268 1268
                 $this->setError($errstr);
1269 1269
             }
1270 1270
 
@@ -1287,9 +1287,9 @@  discard block
 block discarded – undo
1287 1287
     {
1288 1288
         $scope = '';
1289 1289
         for ($i = 0; $i < count($this->complexTypeStack); $i++) {
1290
-            $scope .= $this->complexTypeStack[$i] . '_';
1290
+            $scope .= $this->complexTypeStack[$i].'_';
1291 1291
         }
1292
-        return $scope . $ename . '_ContainedType';
1292
+        return $scope.$ename.'_ContainedType';
1293 1293
     }
1294 1294
 
1295 1295
     /**
@@ -1336,16 +1336,16 @@  discard block
 block discarded – undo
1336 1336
                     } else {
1337 1337
                         $this->defaultNamespace[$pos] = $v;
1338 1338
                         if (!$this->getPrefixFromNamespace($v)) {
1339
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
1339
+                            $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v;
1340 1340
                         }
1341 1341
                     }
1342 1342
                     if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
1343 1343
                         $this->XMLSchemaVersion = $v;
1344
-                        $this->namespaces['xsi'] = $v . '-instance';
1344
+                        $this->namespaces['xsi'] = $v.'-instance';
1345 1345
                     }
1346 1346
                 }
1347 1347
             }
1348
-            $eAttrs = array ();
1348
+            $eAttrs = array();
1349 1349
             foreach ($attrs as $k => $v) {
1350 1350
                 // expand each attribute
1351 1351
                 $k = strpos($k, ':') ? $this->expandQname($k) : $k;
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
                         // no namespace in arrayType attribute value...
1383 1383
                         if ($this->defaultNamespace[$pos]) {
1384 1384
                             // ...so use the default
1385
-                            $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1385
+                            $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos].':'.$attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'];
1386 1386
                         }
1387 1387
                     }
1388 1388
                 }
@@ -1418,7 +1418,7 @@  discard block
 block discarded – undo
1418 1418
                     }
1419 1419
                     $v = substr($v, 0, strpos($v, '[')); // clip the []
1420 1420
                     if (!strpos($v, ':') && isset($this->typemap[$this->XMLSchemaVersion][$v])) {
1421
-                        $v = $this->XMLSchemaVersion . ':' . $v;
1421
+                        $v = $this->XMLSchemaVersion.':'.$v;
1422 1422
                     }
1423 1423
                     $this->complexTypes[$this->currentComplexType]['arrayType'] = $v;
1424 1424
                 }
@@ -1431,12 +1431,12 @@  discard block
 block discarded – undo
1431 1431
                 if (isset($attrs['name'])) {
1432 1432
                     // TODO: what is the scope of named complexTypes that appear
1433 1433
                     //       nested within other c complexTypes?
1434
-                    $this->xdebug('processing named complexType ' . $attrs['name']);
1434
+                    $this->xdebug('processing named complexType '.$attrs['name']);
1435 1435
                     //$this->currentElement = false;
1436 1436
                     $this->currentComplexType = $attrs['name'];
1437 1437
                 } else {
1438 1438
                     $name = $this->CreateTypeName($this->currentElement);
1439
-                    $this->xdebug('processing unnamed complexType for element ' . $this->currentElement . ' named ' . $name);
1439
+                    $this->xdebug('processing unnamed complexType for element '.$this->currentElement.' named '.$name);
1440 1440
                     $this->currentComplexType = $name;
1441 1441
                     //$this->currentElement = false;
1442 1442
                 }
@@ -1468,11 +1468,11 @@  discard block
 block discarded – undo
1468 1468
                     }
1469 1469
                 }
1470 1470
                 if (isset($attrs['type'])) {
1471
-                    $this->xdebug("processing typed element " . $attrs['name'] . " of type " . $attrs['type']);
1471
+                    $this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
1472 1472
                     if (!$this->getPrefix($attrs['type'])) {
1473 1473
                         if ($this->defaultNamespace[$pos]) {
1474
-                            $attrs['type'] = $this->defaultNamespace[$pos] . ':' . $attrs['type'];
1475
-                            $this->xdebug('used default namespace to make type ' . $attrs['type']);
1474
+                            $attrs['type'] = $this->defaultNamespace[$pos].':'.$attrs['type'];
1475
+                            $this->xdebug('used default namespace to make type '.$attrs['type']);
1476 1476
                         }
1477 1477
                     }
1478 1478
                     // This is for constructs like
@@ -1483,20 +1483,20 @@  discard block
 block discarded – undo
1483 1483
                     //                </sequence>
1484 1484
                     //            </complexType>
1485 1485
                     if ($this->currentComplexType && $this->complexTypes[$this->currentComplexType]['phpType'] == 'array') {
1486
-                        $this->xdebug('arrayType for unusual array is ' . $attrs['type']);
1486
+                        $this->xdebug('arrayType for unusual array is '.$attrs['type']);
1487 1487
                         $this->complexTypes[$this->currentComplexType]['arrayType'] = $attrs['type'];
1488 1488
                     }
1489 1489
                     $this->currentElement = $attrs['name'];
1490 1490
                     $ename = $attrs['name'];
1491 1491
                 } elseif (isset($attrs['ref'])) {
1492
-                    $this->xdebug("processing element as ref to " . $attrs['ref']);
1493
-                    $this->currentElement = "ref to " . $attrs['ref'];
1492
+                    $this->xdebug("processing element as ref to ".$attrs['ref']);
1493
+                    $this->currentElement = "ref to ".$attrs['ref'];
1494 1494
                     $ename = $this->getLocalPart($attrs['ref']);
1495 1495
                 } else {
1496
-                    $type = $this->CreateTypeName($this->currentComplexType . '_' . $attrs['name']);
1497
-                    $this->xdebug("processing untyped element " . $attrs['name'] . ' type ' . $type);
1496
+                    $type = $this->CreateTypeName($this->currentComplexType.'_'.$attrs['name']);
1497
+                    $this->xdebug("processing untyped element ".$attrs['name'].' type '.$type);
1498 1498
                     $this->currentElement = $attrs['name'];
1499
-                    $attrs['type'] = $this->schemaTargetNamespace . ':' . $type;
1499
+                    $attrs['type'] = $this->schemaTargetNamespace.':'.$type;
1500 1500
                     $ename = $attrs['name'];
1501 1501
                 }
1502 1502
                 if (isset($ename) && $this->currentComplexType) {
@@ -1509,7 +1509,7 @@  discard block
 block discarded – undo
1509 1509
                 }
1510 1510
                 break;
1511 1511
             case 'enumeration':    //	restriction value list member
1512
-                $this->xdebug('enumeration ' . $attrs['value']);
1512
+                $this->xdebug('enumeration '.$attrs['value']);
1513 1513
                 if ($this->currentSimpleType) {
1514 1514
                     $this->simpleTypes[$this->currentSimpleType]['enumeration'][] = $attrs['value'];
1515 1515
                 } elseif ($this->currentComplexType) {
@@ -1517,11 +1517,11 @@  discard block
 block discarded – undo
1517 1517
                 }
1518 1518
                 break;
1519 1519
             case 'extension':    // simpleContent or complexContent type extension
1520
-                $this->xdebug('extension ' . $attrs['base']);
1520
+                $this->xdebug('extension '.$attrs['base']);
1521 1521
                 if ($this->currentComplexType) {
1522 1522
                     $ns = $this->getPrefix($attrs['base']);
1523 1523
                     if ($ns == '') {
1524
-                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
1524
+                        $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace.':'.$attrs['base'];
1525 1525
                     } else {
1526 1526
                         $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
1527 1527
                     }
@@ -1531,19 +1531,19 @@  discard block
 block discarded – undo
1531 1531
                 break;
1532 1532
             case 'import':
1533 1533
                 if (isset($attrs['schemaLocation'])) {
1534
-                    $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
1534
+                    $this->xdebug('import namespace '.$attrs['namespace'].' from '.$attrs['schemaLocation']);
1535 1535
                     $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1536 1536
                 } else {
1537
-                    $this->xdebug('import namespace ' . $attrs['namespace']);
1537
+                    $this->xdebug('import namespace '.$attrs['namespace']);
1538 1538
                     $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
1539 1539
                     if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
1540
-                        $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
1540
+                        $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace'];
1541 1541
                     }
1542 1542
                 }
1543 1543
                 break;
1544 1544
             case 'include':
1545 1545
                 if (isset($attrs['schemaLocation'])) {
1546
-                    $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
1546
+                    $this->xdebug('include into namespace '.$this->schemaTargetNamespace.' from '.$attrs['schemaLocation']);
1547 1547
                     $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
1548 1548
                 } else {
1549 1549
                     $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
                 $this->xdebug("do nothing for element $name");
1554 1554
                 break;
1555 1555
             case 'restriction':    // simpleType, simpleContent or complexContent value restriction
1556
-                $this->xdebug('restriction ' . $attrs['base']);
1556
+                $this->xdebug('restriction '.$attrs['base']);
1557 1557
                 if ($this->currentSimpleType) {
1558 1558
                     $this->simpleTypes[$this->currentSimpleType]['type'] = $attrs['base'];
1559 1559
                 } elseif ($this->currentComplexType) {
@@ -1586,14 +1586,14 @@  discard block
 block discarded – undo
1586 1586
             case 'simpleType':
1587 1587
                 $this->simpleTypeStack[] = $this->currentSimpleType;
1588 1588
                 if (isset($attrs['name'])) {
1589
-                    $this->xdebug("processing simpleType for name " . $attrs['name']);
1589
+                    $this->xdebug("processing simpleType for name ".$attrs['name']);
1590 1590
                     $this->currentSimpleType = $attrs['name'];
1591 1591
                     $this->simpleTypes[$attrs['name']] = $attrs;
1592 1592
                     $this->simpleTypes[$attrs['name']]['typeClass'] = 'simpleType';
1593 1593
                     $this->simpleTypes[$attrs['name']]['phpType'] = 'scalar';
1594 1594
                 } else {
1595
-                    $name = $this->CreateTypeName($this->currentComplexType . '_' . $this->currentElement);
1596
-                    $this->xdebug('processing unnamed simpleType for element ' . $this->currentElement . ' named ' . $name);
1595
+                    $name = $this->CreateTypeName($this->currentComplexType.'_'.$this->currentElement);
1596
+                    $this->xdebug('processing unnamed simpleType for element '.$this->currentElement.' named '.$name);
1597 1597
                     $this->currentSimpleType = $name;
1598 1598
                     //$this->currentElement = false;
1599 1599
                     $this->simpleTypes[$this->currentSimpleType] = $attrs;
@@ -1626,17 +1626,17 @@  discard block
 block discarded – undo
1626 1626
         }
1627 1627
         // move on...
1628 1628
         if ($name == 'complexType') {
1629
-            $this->xdebug('done processing complexType ' . ($this->currentComplexType ?: '(unknown)'));
1629
+            $this->xdebug('done processing complexType '.($this->currentComplexType ?: '(unknown)'));
1630 1630
             $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
1631 1631
             $this->currentComplexType = array_pop($this->complexTypeStack);
1632 1632
             //$this->currentElement = false;
1633 1633
         }
1634 1634
         if ($name == 'element') {
1635
-            $this->xdebug('done processing element ' . ($this->currentElement ?: '(unknown)'));
1635
+            $this->xdebug('done processing element '.($this->currentElement ?: '(unknown)'));
1636 1636
             $this->currentElement = array_pop($this->elementStack);
1637 1637
         }
1638 1638
         if ($name == 'simpleType') {
1639
-            $this->xdebug('done processing simpleType ' . ($this->currentSimpleType ?: '(unknown)'));
1639
+            $this->xdebug('done processing simpleType '.($this->currentSimpleType ?: '(unknown)'));
1640 1640
             $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
1641 1641
             $this->currentSimpleType = array_pop($this->simpleTypeStack);
1642 1642
         }
@@ -1670,9 +1670,9 @@  discard block
 block discarded – undo
1670 1670
             foreach ($this->imports as $ns => $list) {
1671 1671
                 foreach ($list as $ii) {
1672 1672
                     if ($ii['location'] != '') {
1673
-                        $xml .= " <$schemaPrefix:import location=\"" . $ii['location'] . '" namespace="' . $ns . "\" />\n";
1673
+                        $xml .= " <$schemaPrefix:import location=\"".$ii['location'].'" namespace="'.$ns."\" />\n";
1674 1674
                     } else {
1675
-                        $xml .= " <$schemaPrefix:import namespace=\"" . $ns . "\" />\n";
1675
+                        $xml .= " <$schemaPrefix:import namespace=\"".$ns."\" />\n";
1676 1676
                     }
1677 1677
                 }
1678 1678
             }
@@ -1686,7 +1686,7 @@  discard block
 block discarded – undo
1686 1686
                     if (isset($eParts['ref'])) {
1687 1687
                         $contentStr .= "   <$schemaPrefix:element ref=\"$element\"/>\n";
1688 1688
                     } else {
1689
-                        $contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"";
1689
+                        $contentStr .= "   <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"";
1690 1690
                         foreach ($eParts as $aName => $aValue) {
1691 1691
                             // handle, e.g., abstract, default, form, minOccurs, maxOccurs, nillable
1692 1692
                             if ($aName != 'name' && $aName != 'type') {
@@ -1698,7 +1698,7 @@  discard block
 block discarded – undo
1698 1698
                 }
1699 1699
                 // compositor wraps elements
1700 1700
                 if (isset($attrs['compositor']) && ($attrs['compositor'] != '')) {
1701
-                    $contentStr = "  <$schemaPrefix:$attrs[compositor]>\n" . $contentStr . "  </$schemaPrefix:$attrs[compositor]>\n";
1701
+                    $contentStr = "  <$schemaPrefix:$attrs[compositor]>\n".$contentStr."  </$schemaPrefix:$attrs[compositor]>\n";
1702 1702
                 }
1703 1703
             }
1704 1704
             // attributes
@@ -1707,10 +1707,10 @@  discard block
 block discarded – undo
1707 1707
                     $contentStr .= "    <$schemaPrefix:attribute";
1708 1708
                     foreach ($aParts as $a => $v) {
1709 1709
                         if ($a == 'ref' || $a == 'type') {
1710
-                            $contentStr .= " $a=\"" . $this->contractQName($v) . '"';
1710
+                            $contentStr .= " $a=\"".$this->contractQName($v).'"';
1711 1711
                         } elseif ($a == 'http://schemas.xmlsoap.org/wsdl/:arrayType') {
1712 1712
                             $this->usedNamespaces['wsdl'] = $this->namespaces['wsdl'];
1713
-                            $contentStr .= ' wsdl:arrayType="' . $this->contractQName($v) . '"';
1713
+                            $contentStr .= ' wsdl:arrayType="'.$this->contractQName($v).'"';
1714 1714
                         } else {
1715 1715
                             $contentStr .= " $a=\"$v\"";
1716 1716
                         }
@@ -1720,15 +1720,15 @@  discard block
 block discarded – undo
1720 1720
             }
1721 1721
             // if restriction
1722 1722
             if (isset($attrs['restrictionBase']) && $attrs['restrictionBase'] != '') {
1723
-                $contentStr = "   <$schemaPrefix:restriction base=\"" . $this->contractQName($attrs['restrictionBase']) . "\">\n" . $contentStr . "   </$schemaPrefix:restriction>\n";
1723
+                $contentStr = "   <$schemaPrefix:restriction base=\"".$this->contractQName($attrs['restrictionBase'])."\">\n".$contentStr."   </$schemaPrefix:restriction>\n";
1724 1724
                 // complex or simple content
1725 1725
                 if ((isset($attrs['elements']) && count($attrs['elements']) > 0) || (isset($attrs['attrs']) && count($attrs['attrs']) > 0)) {
1726
-                    $contentStr = "  <$schemaPrefix:complexContent>\n" . $contentStr . "  </$schemaPrefix:complexContent>\n";
1726
+                    $contentStr = "  <$schemaPrefix:complexContent>\n".$contentStr."  </$schemaPrefix:complexContent>\n";
1727 1727
                 }
1728 1728
             }
1729 1729
             // finalize complex type
1730 1730
             if ($contentStr != '') {
1731
-                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n" . $contentStr . " </$schemaPrefix:complexType>\n";
1731
+                $contentStr = " <$schemaPrefix:complexType name=\"$typeName\">\n".$contentStr." </$schemaPrefix:complexType>\n";
1732 1732
             } else {
1733 1733
                 $contentStr = " <$schemaPrefix:complexType name=\"$typeName\"/>\n";
1734 1734
             }
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
         // simple types
1738 1738
         if (isset($this->simpleTypes) && count($this->simpleTypes) > 0) {
1739 1739
             foreach ($this->simpleTypes as $typeName => $eParts) {
1740
-                $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"" . $this->contractQName($eParts['type']) . "\">\n";
1740
+                $xml .= " <$schemaPrefix:simpleType name=\"$typeName\">\n  <$schemaPrefix:restriction base=\"".$this->contractQName($eParts['type'])."\">\n";
1741 1741
                 if (isset($eParts['enumeration'])) {
1742 1742
                     foreach ($eParts['enumeration'] as $e) {
1743 1743
                         $xml .= "  <$schemaPrefix:enumeration value=\"$e\"/>\n";
@@ -1749,13 +1749,13 @@  discard block
 block discarded – undo
1749 1749
         // elements
1750 1750
         if (isset($this->elements) && count($this->elements) > 0) {
1751 1751
             foreach ($this->elements as $element => $eParts) {
1752
-                $xml .= " <$schemaPrefix:element name=\"$element\" type=\"" . $this->contractQName($eParts['type']) . "\"/>\n";
1752
+                $xml .= " <$schemaPrefix:element name=\"$element\" type=\"".$this->contractQName($eParts['type'])."\"/>\n";
1753 1753
             }
1754 1754
         }
1755 1755
         // attributes
1756 1756
         if (isset($this->attributes) && count($this->attributes) > 0) {
1757 1757
             foreach ($this->attributes as $attr => $aParts) {
1758
-                $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"" . $this->contractQName($aParts['type']) . "\"\n/>";
1758
+                $xml .= " <$schemaPrefix:attribute name=\"$attr\" type=\"".$this->contractQName($aParts['type'])."\"\n/>";
1759 1759
             }
1760 1760
         }
1761 1761
         // finish 'er up
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
             $el .= " xmlns:$nsp=\"$ns\"";
1771 1771
         }
1772 1772
 
1773
-      return $el . ">\n" . $xml . "</$schemaPrefix:schema>\n";
1773
+      return $el.">\n".$xml."</$schemaPrefix:schema>\n";
1774 1774
     }
1775 1775
 
1776 1776
     /**
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
      */
1782 1782
     function xdebug($string)
1783 1783
     {
1784
-        $this->debug('<' . $this->schemaTargetNamespace . '> ' . $string);
1784
+        $this->debug('<'.$this->schemaTargetNamespace.'> '.$string);
1785 1785
     }
1786 1786
 
1787 1787
     /**
@@ -1913,13 +1913,13 @@  discard block
 block discarded – undo
1913 1913
         $str = '';
1914 1914
         //print "in sTD() for type $type<br>";
1915 1915
         if ($typeDef = $this->getTypeDef($type)) {
1916
-            $str .= '<' . $type;
1916
+            $str .= '<'.$type;
1917 1917
             if (is_array($typeDef['attrs'])) {
1918 1918
                 foreach ($typeDef['attrs'] as $attName => $data) {
1919
-                    $str .= " $attName=\"{type = " . $data['type'] . "}\"";
1919
+                    $str .= " $attName=\"{type = ".$data['type']."}\"";
1920 1920
                 }
1921 1921
             }
1922
-            $str .= " xmlns=\"" . $this->schema['targetNamespace'] . "\"";
1922
+            $str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
1923 1923
             if (count($typeDef['elements']) > 0) {
1924 1924
                 $str .= ">";
1925 1925
                 foreach ($typeDef['elements'] as $element => $eData) {
@@ -1956,16 +1956,16 @@  discard block
 block discarded – undo
1956 1956
                 $buffer .= '<table>';
1957 1957
                 foreach ($typeDef['elements'] as $childDef) {
1958 1958
                     $buffer .= "
1959
-					<tr><td align='right'>$childDef[name] (type: " . $this->getLocalPart($childDef['type']) . "):</td>
1960
-					<td><input type='text' name='parameters[" . $name . "][$childDef[name]]'></td></tr>";
1959
+					<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
1960
+					<td><input type='text' name='parameters[" . $name."][$childDef[name]]'></td></tr>";
1961 1961
                 }
1962 1962
                 $buffer .= '</table>';
1963 1963
                 // if array
1964 1964
             } elseif ($typeDef['phpType'] == 'array') {
1965 1965
                 $buffer .= '<table>';
1966
-              $buffer .= str_repeat ("
1966
+              $buffer .= str_repeat("
1967 1967
 					<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
1968
-					<td><input type='text' name='parameters[" . $name . "][]'></td></tr>", 3);
1968
+					<td><input type='text' name='parameters[".$name."][]'></td></tr>", 3);
1969 1969
                 $buffer .= '</table>';
1970 1970
                 // if scalar
1971 1971
             } else {
@@ -2068,12 +2068,12 @@  discard block
 block discarded – undo
2068 2068
     function addElement($attrs)
2069 2069
     {
2070 2070
         if (!$this->getPrefix($attrs['type'])) {
2071
-            $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type'];
2071
+            $attrs['type'] = $this->schemaTargetNamespace.':'.$attrs['type'];
2072 2072
         }
2073 2073
         $this->elements[$attrs['name']] = $attrs;
2074 2074
         $this->elements[$attrs['name']]['typeClass'] = 'element';
2075 2075
 
2076
-        $this->xdebug("addElement " . $attrs['name']);
2076
+        $this->xdebug("addElement ".$attrs['name']);
2077 2077
         $this->appendDebug($this->varDump($this->elements[$attrs['name']]));
2078 2078
     }
2079 2079
 }
@@ -2221,18 +2221,18 @@  discard block
 block discarded – undo
2221 2221
     var $incoming_cookies = array();
2222 2222
     var $outgoing_payload = '';
2223 2223
     var $incoming_payload = '';
2224
-    var $response_status_line;    // HTTP response status line
2224
+    var $response_status_line; // HTTP response status line
2225 2225
     var $useSOAPAction = true;
2226 2226
     var $persistentConnection = false;
2227
-    var $ch = false;    // cURL handle
2228
-    var $ch_options = array();    // cURL custom options
2229
-    var $use_curl = false;        // force cURL use
2230
-    var $proxy = null;            // proxy information (associative array)
2227
+    var $ch = false; // cURL handle
2228
+    var $ch_options = array(); // cURL custom options
2229
+    var $use_curl = false; // force cURL use
2230
+    var $proxy = null; // proxy information (associative array)
2231 2231
     var $username = '';
2232 2232
     var $password = '';
2233 2233
     var $authtype = '';
2234 2234
     var $digestRequest = array();
2235
-    var $certRequest = array();    // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
2235
+    var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
2236 2236
     // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
2237 2237
     // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
2238 2238
     // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
@@ -2263,8 +2263,8 @@  discard block
 block discarded – undo
2263 2263
             $this->ch_options = $curl_options;
2264 2264
         }
2265 2265
         $this->use_curl = $use_curl;
2266
-        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2267
-        $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . $rev[1] . ')');
2266
+        preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
2267
+        $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
2268 2268
     }
2269 2269
 
2270 2270
     /**
@@ -2326,7 +2326,7 @@  discard block
 block discarded – undo
2326 2326
 
2327 2327
         // add any GET params to path
2328 2328
         if (isset($u['query']) && $u['query'] != '') {
2329
-            $this->path .= '?' . $u['query'];
2329
+            $this->path .= '?'.$u['query'];
2330 2330
         }
2331 2331
 
2332 2332
         // set default port
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
         if (!isset($u['port'])) {
2346 2346
             $this->setHeader('Host', $this->host);
2347 2347
         } else {
2348
-            $this->setHeader('Host', $this->host . ':' . $this->port);
2348
+            $this->setHeader('Host', $this->host.':'.$this->port);
2349 2349
         }
2350 2350
 
2351 2351
         if (isset($u['user']) && $u['user'] != '') {
@@ -2412,9 +2412,9 @@  discard block
 block discarded – undo
2412 2412
 
2413 2413
             // munge host if using OpenSSL
2414 2414
             if ($this->scheme == 'ssl') {
2415
-                $host = 'ssl://' . $host;
2415
+                $host = 'ssl://'.$host;
2416 2416
             }
2417
-            $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2417
+            $this->debug('calling fsockopen with host '.$host.' connection_timeout '.$connection_timeout);
2418 2418
 
2419 2419
             // open socket
2420 2420
             if ($connection_timeout > 0) {
@@ -2425,9 +2425,9 @@  discard block
 block discarded – undo
2425 2425
 
2426 2426
             // test pointer
2427 2427
             if (!$this->fp) {
2428
-                $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2428
+                $msg = 'Couldn\'t open socket connection to server '.$this->url;
2429 2429
                 if ($this->errno) {
2430
-                    $msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2430
+                    $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
2431 2431
                 } else {
2432 2432
                     $msg .= ' prior to connect().  This is often a problem looking up the host name.';
2433 2433
                 }
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
             }
2438 2438
 
2439 2439
             // set response timeout
2440
-            $this->debug('set response timeout to ' . $response_timeout);
2440
+            $this->debug('set response timeout to '.$response_timeout);
2441 2441
             socket_set_timeout($this->fp, $response_timeout, 0);
2442 2442
 
2443 2443
             $this->debug('socket connected');
@@ -2585,13 +2585,13 @@  discard block
 block discarded – undo
2585 2585
             if (is_array($this->proxy)) {
2586 2586
                 $this->debug('set cURL proxy options');
2587 2587
                 if ($this->proxy['port'] != '') {
2588
-                    $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2588
+                    $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
2589 2589
                 } else {
2590 2590
                     $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2591 2591
                 }
2592 2592
                 if ($this->proxy['username'] || $this->proxy['password']) {
2593 2593
                     $this->debug('set cURL proxy authentication options');
2594
-                    $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2594
+                    $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
2595 2595
                     if ($this->proxy['authtype'] == 'basic') {
2596 2596
                         $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2597 2597
                     }
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
             $this->debug('cURL connection set up');
2604 2604
             return true;
2605 2605
         } else {
2606
-            $this->setError('Unknown scheme ' . $this->scheme);
2607
-            $this->debug('Unknown scheme ' . $this->scheme);
2606
+            $this->setError('Unknown scheme '.$this->scheme);
2607
+            $this->debug('Unknown scheme '.$this->scheme);
2608 2608
             return false;
2609 2609
         }
2610 2610
     }
@@ -2621,7 +2621,7 @@  discard block
 block discarded – undo
2621 2621
      */
2622 2622
     function send($data, $timeout = 0, $response_timeout = 30, $cookies = null)
2623 2623
     {
2624
-        $this->debug('entered send() with data of length: ' . strlen($data));
2624
+        $this->debug('entered send() with data of length: '.strlen($data));
2625 2625
 
2626 2626
         $respdata = "";
2627 2627
         $this->tryagain = true;
@@ -2683,7 +2683,7 @@  discard block
 block discarded – undo
2683 2683
         $this->appendDebug($this->varDump($certRequest));
2684 2684
         // cf. RFC 2617
2685 2685
         if ($authtype == 'basic') {
2686
-            $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2686
+            $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':', '', $username).':'.$password));
2687 2687
         } elseif ($authtype == 'digest') {
2688 2688
             if (isset($digestRequest['nonce'])) {
2689 2689
                 $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
@@ -2691,13 +2691,13 @@  discard block
 block discarded – undo
2691 2691
                 // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2692 2692
 
2693 2693
                 // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2694
-                $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2694
+                $A1 = $username.':'.(isset($digestRequest['realm']) ? $digestRequest['realm'] : '').':'.$password;
2695 2695
 
2696 2696
                 // H(A1) = MD5(A1)
2697 2697
                 $HA1 = md5($A1);
2698 2698
 
2699 2699
                 // A2 = Method ":" digest-uri-value
2700
-                $A2 = $this->request_method . ':' . $this->digest_uri;
2700
+                $A2 = $this->request_method.':'.$this->digest_uri;
2701 2701
 
2702 2702
                 // H(A2)
2703 2703
                 $HA2 = md5($A2);
@@ -2716,19 +2716,19 @@  discard block
 block discarded – undo
2716 2716
                 $nonce = $digestRequest['nonce'];
2717 2717
                 $cnonce = $nonce;
2718 2718
                 if ($digestRequest['qop'] != '') {
2719
-                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2719
+                    $unhashedDigest = $HA1.':'.$nonce.':'.sprintf("%08d", $digestRequest['nc']).':'.$cnonce.':'.$digestRequest['qop'].':'.$HA2;
2720 2720
                 } else {
2721
-                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2721
+                    $unhashedDigest = $HA1.':'.$nonce.':'.$HA2;
2722 2722
                 }
2723 2723
 
2724 2724
                 $hashedDigest = md5($unhashedDigest);
2725 2725
 
2726 2726
                 $opaque = '';
2727 2727
                 if (isset($digestRequest['opaque'])) {
2728
-                    $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2728
+                    $opaque = ', opaque="'.$digestRequest['opaque'].'"';
2729 2729
                 }
2730 2730
 
2731
-                $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
2731
+                $this->setHeader('Authorization', 'Digest username="'.$username.'", realm="'.$digestRequest['realm'].'", nonce="'.$nonce.'", uri="'.$this->digest_uri.$opaque.'", cnonce="'.$cnonce.'", nc='.sprintf("%08x", $digestRequest['nc']).', qop="'.$digestRequest['qop'].'", response="'.$hashedDigest.'"');
2732 2732
             }
2733 2733
         } elseif ($authtype == 'certificate') {
2734 2734
             $this->certRequest = $certRequest;
@@ -2751,7 +2751,7 @@  discard block
 block discarded – undo
2751 2751
      */
2752 2752
     function setSOAPAction($soapaction)
2753 2753
     {
2754
-        $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2754
+        $this->setHeader('SOAPAction', '"'.$soapaction.'"');
2755 2755
     }
2756 2756
 
2757 2757
     /**
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
                 'authtype' => $proxyauthtype
2797 2797
             );
2798 2798
             if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype == 'basic') {
2799
-                $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2799
+                $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
2800 2800
             }
2801 2801
         } else {
2802 2802
             $this->debug('remove proxy');
@@ -2921,14 +2921,14 @@  discard block
 block discarded – undo
2921 2921
 
2922 2922
         // loop thru headers, serializing
2923 2923
         foreach ($this->outgoing_headers as $k => $v) {
2924
-            $hdr = $k . ': ' . $v;
2924
+            $hdr = $k.': '.$v;
2925 2925
             $this->debug("HTTP header: $hdr");
2926 2926
             $this->outgoing_payload .= "$hdr\r\n";
2927 2927
         }
2928 2928
 
2929 2929
         // add any cookies
2930 2930
         if ($cookie_str != '') {
2931
-            $hdr = 'Cookie: ' . $cookie_str;
2931
+            $hdr = 'Cookie: '.$cookie_str;
2932 2932
             $this->debug("HTTP header: $hdr");
2933 2933
             $this->outgoing_payload .= "$hdr\r\n";
2934 2934
         }
@@ -2963,7 +2963,7 @@  discard block
 block discarded – undo
2963 2963
                 $this->debug('couldn\'t write message data to socket');
2964 2964
                 return false;
2965 2965
             }
2966
-            $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2966
+            $this->debug('wrote data to socket, length = '.strlen($this->outgoing_payload));
2967 2967
             return true;
2968 2968
         } elseif ($this->io_method() == 'curl') {
2969 2969
             // set payload
@@ -2980,7 +2980,7 @@  discard block
 block discarded – undo
2980 2980
                 }
2981 2981
             }
2982 2982
             if ($cookie_str != '') {
2983
-                $curl_headers[] = 'Cookie: ' . $cookie_str;
2983
+                $curl_headers[] = 'Cookie: '.$cookie_str;
2984 2984
             }
2985 2985
             $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2986 2986
             $this->debug('set cURL HTTP headers');
@@ -3009,7 +3009,7 @@  discard block
 block discarded – undo
3009 3009
     function getResponse()
3010 3010
     {
3011 3011
         $this->incoming_payload = '';
3012
-        $header_array = array ();
3012
+        $header_array = array();
3013 3013
         $data = '';
3014 3014
 
3015 3015
         if ($this->io_method() == 'socket') {
@@ -3019,20 +3019,20 @@  discard block
 block discarded – undo
3019 3019
                 // We might EOF during header read.
3020 3020
                 if (feof($this->fp)) {
3021 3021
                     $this->incoming_payload = $data;
3022
-                    $this->debug('found no headers before EOF after length ' . strlen($data));
3023
-                    $this->debug("received before EOF:\n" . $data);
3022
+                    $this->debug('found no headers before EOF after length '.strlen($data));
3023
+                    $this->debug("received before EOF:\n".$data);
3024 3024
                     $this->setError('server failed to send headers');
3025 3025
                     return false;
3026 3026
                 }
3027 3027
 
3028 3028
                 $tmp = fgets($this->fp, 256);
3029 3029
                 $tmplen = strlen($tmp);
3030
-                $this->debug("read line of $tmplen bytes: " . trim($tmp));
3030
+                $this->debug("read line of $tmplen bytes: ".trim($tmp));
3031 3031
 
3032 3032
                 if ($tmplen == 0) {
3033 3033
                     $this->incoming_payload = $data;
3034
-                    $this->debug('socket read of headers timed out after length ' . strlen($data));
3035
-                    $this->debug("read before timeout: " . $data);
3034
+                    $this->debug('socket read of headers timed out after length '.strlen($data));
3035
+                    $this->debug("read before timeout: ".$data);
3036 3036
                     $this->setError('socket read of headers timed out');
3037 3037
                     return false;
3038 3038
                 }
@@ -3055,7 +3055,7 @@  discard block
 block discarded – undo
3055 3055
             }
3056 3056
             // store header data
3057 3057
             $this->incoming_payload .= $data;
3058
-            $this->debug('found end of headers after length ' . strlen($data));
3058
+            $this->debug('found end of headers after length '.strlen($data));
3059 3059
             // process headers
3060 3060
             $header_data = trim(substr($data, 0, $pos));
3061 3061
             $header_array = explode($lb, $header_data);
@@ -3071,20 +3071,20 @@  discard block
 block discarded – undo
3071 3071
                         $cookie = $this->parseCookie(trim($arr[1]));
3072 3072
                         if ($cookie) {
3073 3073
                             $this->incoming_cookies[] = $cookie;
3074
-                            $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3074
+                            $this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
3075 3075
                         } else {
3076
-                            $this->debug('did not find cookie in ' . trim($arr[1]));
3076
+                            $this->debug('did not find cookie in '.trim($arr[1]));
3077 3077
                         }
3078 3078
                     }
3079 3079
                 } elseif (isset($header_name)) {
3080 3080
                     // append continuation line to previous header
3081
-                    $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3081
+                    $this->incoming_headers[$header_name] .= $lb.' '.$header_line;
3082 3082
                 }
3083 3083
             }
3084 3084
 
3085 3085
             // loop until msg has been received
3086 3086
             if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3087
-                $content_length = 2147483647;    // ignore any content-length header
3087
+                $content_length = 2147483647; // ignore any content-length header
3088 3088
                 $chunked = true;
3089 3089
                 $this->debug("want to read chunked content");
3090 3090
             } elseif (isset($this->incoming_headers['content-length'])) {
@@ -3104,8 +3104,8 @@  discard block
 block discarded – undo
3104 3104
                     $this->debug("read chunk line of $tmplen bytes");
3105 3105
                     if ($tmplen == 0) {
3106 3106
                         $this->incoming_payload = $data;
3107
-                        $this->debug('socket read of chunk length timed out after length ' . strlen($data));
3108
-                        $this->debug("read before timeout:\n" . $data);
3107
+                        $this->debug('socket read of chunk length timed out after length '.strlen($data));
3108
+                        $this->debug("read before timeout:\n".$data);
3109 3109
                         $this->setError('socket read of chunk length timed out');
3110 3110
                         return false;
3111 3111
                     }
@@ -3120,8 +3120,8 @@  discard block
 block discarded – undo
3120 3120
                     $this->debug("read buffer of $tmplen bytes");
3121 3121
                     if (($tmplen == 0) && (!feof($this->fp))) {
3122 3122
                         $this->incoming_payload = $data;
3123
-                        $this->debug('socket read of body timed out after length ' . strlen($data));
3124
-                        $this->debug("read before timeout:\n" . $data);
3123
+                        $this->debug('socket read of body timed out after length '.strlen($data));
3124
+                        $this->debug("read before timeout:\n".$data);
3125 3125
                         $this->setError('socket read of body timed out');
3126 3126
                         return false;
3127 3127
                     }
@@ -3134,8 +3134,8 @@  discard block
 block discarded – undo
3134 3134
                     $this->debug("read chunk terminator of $tmplen bytes");
3135 3135
                     if ($tmplen == 0) {
3136 3136
                         $this->incoming_payload = $data;
3137
-                        $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3138
-                        $this->debug("read before timeout:\n" . $data);
3137
+                        $this->debug('socket read of chunk terminator timed out after length '.strlen($data));
3138
+                        $this->debug("read before timeout:\n".$data);
3139 3139
                         $this->setError('socket read of chunk terminator timed out');
3140 3140
                         return false;
3141 3141
                     }
@@ -3144,9 +3144,9 @@  discard block
 block discarded – undo
3144 3144
             if (feof($this->fp)) {
3145 3145
                 $this->debug('read to EOF');
3146 3146
             }
3147
-            $this->debug('read body of length ' . strlen($data));
3147
+            $this->debug('read body of length '.strlen($data));
3148 3148
             $this->incoming_payload .= $data;
3149
-            $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
3149
+            $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
3150 3150
 
3151 3151
             // close filepointer
3152 3152
             if (
@@ -3183,11 +3183,11 @@  discard block
 block discarded – undo
3183 3183
 
3184 3184
             $cErr = curl_error($this->ch);
3185 3185
             if ($cErr != '') {
3186
-                $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3186
+                $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
3187 3187
                 // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
3188 3188
                 foreach (curl_getinfo($this->ch) as $k => $v) {
3189 3189
                     if (is_array($v)) {
3190
-                        $this->debug("$k: " . json_encode($v));
3190
+                        $this->debug("$k: ".json_encode($v));
3191 3191
                     } else {
3192 3192
                         $this->debug("$k: $v<br>");
3193 3193
                     }
@@ -3238,7 +3238,7 @@  discard block
 block discarded – undo
3238 3238
             $header_array = explode($lb, $header_data);
3239 3239
             $data = ltrim(substr($data, $pos));
3240 3240
             $this->debug('found proper separation of headers and document');
3241
-            $this->debug('cleaned data, stringlen: ' . strlen($data));
3241
+            $this->debug('cleaned data, stringlen: '.strlen($data));
3242 3242
             // clean headers
3243 3243
             foreach ($header_array as $header_line) {
3244 3244
                 $arr = explode(':', $header_line, 2);
@@ -3250,14 +3250,14 @@  discard block
 block discarded – undo
3250 3250
                         $cookie = $this->parseCookie(trim($arr[1]));
3251 3251
                         if ($cookie) {
3252 3252
                             $this->incoming_cookies[] = $cookie;
3253
-                            $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3253
+                            $this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
3254 3254
                         } else {
3255
-                            $this->debug('did not find cookie in ' . trim($arr[1]));
3255
+                            $this->debug('did not find cookie in '.trim($arr[1]));
3256 3256
                         }
3257 3257
                     }
3258 3258
                 } elseif (isset($header_name)) {
3259 3259
                     // append continuation line to previous header
3260
-                    $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3260
+                    $this->incoming_headers[$header_name] .= $lb.' '.$header_line;
3261 3261
                 }
3262 3262
             }
3263 3263
         }
@@ -3269,7 +3269,7 @@  discard block
 block discarded – undo
3269 3269
 
3270 3270
         // see if we need to resend the request with http digest authentication
3271 3271
         if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3272
-            $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3272
+            $this->debug("Got $http_status $http_reason with Location: ".$this->incoming_headers['location']);
3273 3273
             $this->setURL($this->incoming_headers['location']);
3274 3274
             $this->tryagain = true;
3275 3275
             return false;
@@ -3277,7 +3277,7 @@  discard block
 block discarded – undo
3277 3277
 
3278 3278
         // see if we need to resend the request with http digest authentication
3279 3279
         if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3280
-            $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
3280
+            $this->debug("Got 401 $http_reason with WWW-Authenticate: ".$this->incoming_headers['www-authenticate']);
3281 3281
             if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3282 3282
                 $this->debug('Server wants digest authentication');
3283 3283
                 // remove "Digest " from our elements
@@ -3325,13 +3325,13 @@  discard block
 block discarded – undo
3325 3325
                     if ($this->incoming_headers['content-encoding'] == 'deflate') {
3326 3326
                         if ($degzdata = @gzinflate($data)) {
3327 3327
                             $data = $degzdata;
3328
-                            $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3328
+                            $this->debug('The payload has been inflated to '.strlen($data).' bytes');
3329 3329
                             if (strlen($data) < $datalen) {
3330 3330
                                 // test for the case that the payload has been compressed twice
3331 3331
                                 $this->debug('The inflated payload is smaller than the gzipped one; try again');
3332 3332
                                 if ($degzdata = @gzinflate($data)) {
3333 3333
                                     $data = $degzdata;
3334
-                                    $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3334
+                                    $this->debug('The payload has been inflated again to '.strlen($data).' bytes');
3335 3335
                                 }
3336 3336
                             }
3337 3337
                         } else {
@@ -3341,13 +3341,13 @@  discard block
 block discarded – undo
3341 3341
                     } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3342 3342
                         if ($degzdata = @gzinflate(substr($data, 10))) {    // do our best
3343 3343
                             $data = $degzdata;
3344
-                            $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3344
+                            $this->debug('The payload has been un-gzipped to '.strlen($data).' bytes');
3345 3345
                             if (strlen($data) < $datalen) {
3346 3346
                                 // test for the case that the payload has been compressed twice
3347 3347
                                 $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3348 3348
                                 if ($degzdata = @gzinflate(substr($data, 10))) {
3349 3349
                                     $data = $degzdata;
3350
-                                    $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3350
+                                    $this->debug('The payload has been un-gzipped again to '.strlen($data).' bytes');
3351 3351
                                 }
3352 3352
                             }
3353 3353
                         } else {
@@ -3358,14 +3358,14 @@  discard block
 block discarded – undo
3358 3358
                     //$timer->setMarker('finished decoding of gzip/deflated content');
3359 3359
                     //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3360 3360
                     // set decoded payload
3361
-                    $this->incoming_payload = $header_data . (isset ($lb) ? $lb : "") . (isset ($lb) ? $lb : "") . $data;
3361
+                    $this->incoming_payload = $header_data.(isset ($lb) ? $lb : "").(isset ($lb) ? $lb : "").$data;
3362 3362
                 } else {
3363 3363
                     $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3364 3364
                     $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3365 3365
                 }
3366 3366
             } else {
3367
-                $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3368
-                $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3367
+                $this->debug('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
3368
+                $this->setError('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
3369 3369
             }
3370 3370
         } else {
3371 3371
             $this->debug('No Content-Encoding header');
@@ -3389,7 +3389,7 @@  discard block
 block discarded – undo
3389 3389
      */
3390 3390
     function setContentType($type, $charset = false)
3391 3391
     {
3392
-        $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3392
+        $this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
3393 3393
     }
3394 3394
 
3395 3395
     /**
@@ -3421,8 +3421,8 @@  discard block
 block discarded – undo
3421 3421
 	 */
3422 3422
     function parseCookie($cookie_str)
3423 3423
     {
3424
-        $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3425
-        $data = explode (';', $cookie_str);
3424
+        $cookie_str = str_replace('; ', ';', $cookie_str).';';
3425
+        $data = explode(';', $cookie_str);
3426 3426
         $value_str = $data[0];
3427 3427
 
3428 3428
         $cookie_param = 'domain=';
@@ -3473,7 +3473,7 @@  discard block
 block discarded – undo
3473 3473
                      'secure' => $secure
3474 3474
           );
3475 3475
         }
3476
-        return array ();
3476
+        return array();
3477 3477
     }
3478 3478
 
3479 3479
     /**
@@ -3492,7 +3492,7 @@  discard block
 block discarded – undo
3492 3492
                 if (!is_array($cookie)) {
3493 3493
                     continue;
3494 3494
                 }
3495
-                $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3495
+                $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
3496 3496
                 if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
3497 3497
                     if (strtotime($cookie['expires']) <= time()) {
3498 3498
                         $this->debug('cookie has expired');
@@ -3517,8 +3517,8 @@  discard block
 block discarded – undo
3517 3517
                     $this->debug('cookie is secure, transport is not');
3518 3518
                     continue;
3519 3519
                 }
3520
-                $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3521
-                $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3520
+                $cookie_str .= $cookie['name'].'='.$cookie['value'].'; ';
3521
+                $this->debug('add cookie to Cookie-String: '.$cookie['name'].'='.$cookie['value']);
3522 3522
             }
3523 3523
         }
3524 3524
         return $cookie_str;
@@ -3664,7 +3664,7 @@  discard block
 block discarded – undo
3664 3664
      * @var string
3665 3665
      * @access private
3666 3666
      */
3667
-    var $attachments= '';
3667
+    var $attachments = '';
3668 3668
     /**
3669 3669
      * method return value to place in response
3670 3670
      *
@@ -3759,7 +3759,7 @@  discard block
 block discarded – undo
3759 3759
             $qs = explode('&', $_SERVER['QUERY_STRING']);
3760 3760
             foreach ($qs as $v) {
3761 3761
                 if (substr($v, 0, 6) == 'debug=') {
3762
-                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
3762
+                    $this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #1");
3763 3763
                     $this->debug_flag = substr($v, 6);
3764 3764
                 }
3765 3765
             }
@@ -3767,7 +3767,7 @@  discard block
 block discarded – undo
3767 3767
             $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
3768 3768
             foreach ($qs as $v) {
3769 3769
                 if (substr($v, 0, 6) == 'debug=') {
3770
-                    $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
3770
+                    $this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #2");
3771 3771
                     $this->debug_flag = substr($v, 6);
3772 3772
                 }
3773 3773
             }
@@ -3779,16 +3779,16 @@  discard block
 block discarded – undo
3779 3779
             if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
3780 3780
                 $this->wsdl = $wsdl;
3781 3781
                 $this->externalWSDLURL = $this->wsdl->wsdl;
3782
-                $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
3782
+                $this->debug('Use existing wsdl instance from '.$this->externalWSDLURL);
3783 3783
             } else {
3784
-                $this->debug('Create wsdl from ' . $wsdl);
3784
+                $this->debug('Create wsdl from '.$wsdl);
3785 3785
                 $this->wsdl = new wsdl($wsdl);
3786 3786
                 $this->externalWSDLURL = $wsdl;
3787 3787
             }
3788 3788
             $this->appendDebug($this->wsdl->getDebug());
3789 3789
             $this->wsdl->clearDebug();
3790 3790
             if ($err = $this->wsdl->getError()) {
3791
-                die('WSDL ERROR: ' . $err);
3791
+                die('WSDL ERROR: '.$err);
3792 3792
             }
3793 3793
         }
3794 3794
     }
@@ -3818,7 +3818,7 @@  discard block
 block discarded – undo
3818 3818
         } else {
3819 3819
             $qs = '';
3820 3820
         }
3821
-        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
3821
+        $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=".strlen($data));
3822 3822
 
3823 3823
         if ($rm == 'POST') {
3824 3824
             $this->debug("In service, invoke the request");
@@ -3835,7 +3835,7 @@  discard block
 block discarded – undo
3835 3835
             if ($this->externalWSDLURL) {
3836 3836
                 if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
3837 3837
                     $this->debug("In service, re-direct for WSDL");
3838
-                    header('Location: ' . $this->externalWSDLURL);
3838
+                    header('Location: '.$this->externalWSDLURL);
3839 3839
                 } else { // assume file
3840 3840
                     $this->debug("In service, use file passthru for WSDL");
3841 3841
                     header("Content-Type: text/xml\r\n");
@@ -3941,8 +3941,8 @@  discard block
 block discarded – undo
3941 3941
                 }
3942 3942
                 $this->headers[$k] = $v;
3943 3943
                 if (is_array($v)) {
3944
-                    $this->request .= "$k: " . json_encode($v) . "\r\n";
3945
-                    $this->debug("$k: " . json_encode($v));
3944
+                    $this->request .= "$k: ".json_encode($v)."\r\n";
3945
+                    $this->debug("$k: ".json_encode($v));
3946 3946
                 } else {
3947 3947
                     $this->request .= "$k: $v\r\n";
3948 3948
                     $this->debug("$k: $v");
@@ -4016,10 +4016,10 @@  discard block
 block discarded – undo
4016 4016
     {
4017 4017
         $this->debug('entering parse_request()');
4018 4018
         $this->parse_http_headers();
4019
-        $this->debug('got character encoding: ' . $this->xml_encoding);
4019
+        $this->debug('got character encoding: '.$this->xml_encoding);
4020 4020
         // uncompress if necessary
4021 4021
         if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
4022
-            $this->debug('got content encoding: ' . $this->headers['content-encoding']);
4022
+            $this->debug('got content encoding: '.$this->headers['content-encoding']);
4023 4023
             if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
4024 4024
                 // if decoding works, use it. else assume data wasn't gzencoded
4025 4025
                 if (function_exists('gzuncompress')) {
@@ -4037,7 +4037,7 @@  discard block
 block discarded – undo
4037 4037
                 }
4038 4038
             }
4039 4039
         }
4040
-        $this->request .= "\r\n" . $data;
4040
+        $this->request .= "\r\n".$data;
4041 4041
         $data = $this->parseRequest($this->headers, $data);
4042 4042
         $this->requestSOAP = $data;
4043 4043
         $this->debug('leaving parse_request');
@@ -4062,7 +4062,7 @@  discard block
 block discarded – undo
4062 4062
      */
4063 4063
     function invoke_method()
4064 4064
     {
4065
-        $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
4065
+        $this->debug('in invoke_method, methodname='.$this->methodname.' methodURI='.$this->methodURI.' SOAPAction='.$this->SOAPAction);
4066 4066
 
4067 4067
         //
4068 4068
         // if you are debugging in this area of the code, your service uses a class to implement methods,
@@ -4077,16 +4077,16 @@  discard block
 block discarded – undo
4077 4077
         $orig_methodname = $this->methodname;
4078 4078
         if ($this->wsdl) {
4079 4079
             if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
4080
-                $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
4081
-                $this->appendDebug('opData=' . $this->varDump($this->opData));
4080
+                $this->debug('in invoke_method, found WSDL operation='.$this->methodname);
4081
+                $this->appendDebug('opData='.$this->varDump($this->opData));
4082 4082
             } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
4083 4083
                 // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element
4084
-                $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
4085
-                $this->appendDebug('opData=' . $this->varDump($this->opData));
4084
+                $this->debug('in invoke_method, found WSDL soapAction='.$this->SOAPAction.' for operation='.$this->opData['name']);
4085
+                $this->appendDebug('opData='.$this->varDump($this->opData));
4086 4086
                 $this->methodname = $this->opData['name'];
4087 4087
             } else {
4088
-                $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
4089
-                $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
4088
+                $this->debug('in invoke_method, no WSDL for operation='.$this->methodname);
4089
+                $this->fault('SOAP-ENV:Client', "Operation '".$this->methodname."' is not defined in the WSDL for this service");
4090 4090
                 return;
4091 4091
             }
4092 4092
         } else {
@@ -4166,13 +4166,13 @@  discard block
 block discarded – undo
4166 4166
             } else {
4167 4167
                 if ($delim == '..') {
4168 4168
                     $this->debug('in invoke_method, calling class method using eval()');
4169
-                    $funcCall = "\$this->methodreturn = " . $class . "::" . $method . "(";
4169
+                    $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
4170 4170
                 } else {
4171 4171
                     $this->debug('in invoke_method, calling instance method using eval()');
4172 4172
                     // generate unique instance name
4173
-                    $instname = "\$inst_" . time();
4174
-                    $funcCall = $instname . " = new " . $class . "(); ";
4175
-                    $funcCall .= "\$this->methodreturn = " . $instname . "->" . $method . "(";
4173
+                    $instname = "\$inst_".time();
4174
+                    $funcCall = $instname." = new ".$class."(); ";
4175
+                    $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
4176 4176
                 }
4177 4177
             }
4178 4178
             if ($this->methodparams) {
@@ -4186,18 +4186,18 @@  discard block
 block discarded – undo
4186 4186
                 $funcCall = substr($funcCall, 0, -1);
4187 4187
             }
4188 4188
             $funcCall .= ');';
4189
-            $this->debug('in invoke_method, function call: ' . $funcCall);
4189
+            $this->debug('in invoke_method, function call: '.$funcCall);
4190 4190
             @eval($funcCall);
4191 4191
         } else {
4192 4192
             if ($class == '') {
4193 4193
                 $this->debug('in invoke_method, calling function using call_user_func_array()');
4194
-                $call_arg = "$this->methodname";    // straight assignment changes $this->methodname to lower case after call_user_func_array()
4194
+                $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array()
4195 4195
             } elseif ($delim == '..') {
4196 4196
                 $this->debug('in invoke_method, calling class method using call_user_func_array()');
4197 4197
                 $call_arg = array($class, $method);
4198 4198
             } else {
4199 4199
                 $this->debug('in invoke_method, calling instance method using call_user_func_array()');
4200
-                $instance = new $class ();
4200
+                $instance = new $class();
4201 4201
                 $call_arg = array(&$instance, $method);
4202 4202
             }
4203 4203
             if (is_array($this->methodparams)) {
@@ -4208,7 +4208,7 @@  discard block
 block discarded – undo
4208 4208
         }
4209 4209
         $this->debug('in invoke_method, methodreturn:');
4210 4210
         $this->appendDebug($this->varDump($this->methodreturn));
4211
-        $this->debug("in invoke_method, called method $this->methodname, received data of type " . gettype($this->methodreturn));
4211
+        $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
4212 4212
     }
4213 4213
 
4214 4214
     /**
@@ -4224,7 +4224,7 @@  discard block
 block discarded – undo
4224 4224
      */
4225 4225
     function serialize_return()
4226 4226
     {
4227
-        $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4227
+        $this->debug('Entering serialize_return methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
4228 4228
         // if fault
4229 4229
         if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
4230 4230
             $this->debug('got a fault object from method');
@@ -4234,7 +4234,7 @@  discard block
 block discarded – undo
4234 4234
             $return_val = $this->methodreturn;
4235 4235
             // returned value(s)
4236 4236
         } else {
4237
-            $this->debug('got a(n) ' . gettype($this->methodreturn) . ' from method');
4237
+            $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
4238 4238
             $this->debug('serializing return value');
4239 4239
             if ($this->wsdl) {
4240 4240
                 if (sizeof($this->opData['output']['parts']) > 1) {
@@ -4253,7 +4253,7 @@  discard block
 block discarded – undo
4253 4253
                 $this->appendDebug($this->wsdl->getDebug());
4254 4254
                 $this->wsdl->clearDebug();
4255 4255
                 if ($errstr = $this->wsdl->getError()) {
4256
-                    $this->debug('got wsdl error: ' . $errstr);
4256
+                    $this->debug('got wsdl error: '.$errstr);
4257 4257
                     $this->fault('SOAP-ENV:Server', 'unable to serialize result');
4258 4258
                     return;
4259 4259
                 }
@@ -4271,21 +4271,21 @@  discard block
 block discarded – undo
4271 4271
 
4272 4272
         $this->debug('serializing response');
4273 4273
         if ($this->wsdl) {
4274
-            $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
4274
+            $this->debug('have WSDL for serialization: style is '.$this->opData['style']);
4275 4275
             if ($this->opData['style'] == 'rpc') {
4276
-                $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
4276
+                $this->debug('style is rpc for serialization: use is '.$this->opData['output']['use']);
4277 4277
                 if ($this->opData['output']['use'] == 'literal') {
4278 4278
                     // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
4279 4279
                     if ($this->methodURI) {
4280
-                        $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4280
+                        $payload = '<ns1:'.$this->responseTagName.' xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->responseTagName.">";
4281 4281
                     } else {
4282
-                        $payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . 'Response>';
4282
+                        $payload = '<'.$this->responseTagName.'>'.$return_val.'</'.$this->responseTagName.'Response>';
4283 4283
                     }
4284 4284
                 } else {
4285 4285
                     if ($this->methodURI) {
4286
-                        $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4286
+                        $payload = '<ns1:'.$this->responseTagName.' xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->responseTagName.">";
4287 4287
                     } else {
4288
-                        $payload = '<' . $this->responseTagName . '>' . $return_val . '</' . $this->responseTagName . '>';
4288
+                        $payload = '<'.$this->responseTagName.'>'.$return_val.'</'.$this->responseTagName.'>';
4289 4289
                     }
4290 4290
                 }
4291 4291
             } else {
@@ -4294,7 +4294,7 @@  discard block
 block discarded – undo
4294 4294
             }
4295 4295
         } else {
4296 4296
             $this->debug('do not have WSDL for serialization: assume rpc/encoded');
4297
-            $payload = '<ns1:' . $this->responseTagName . ' xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->responseTagName . ">";
4297
+            $payload = '<ns1:'.$this->responseTagName.' xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->responseTagName.">";
4298 4298
         }
4299 4299
         $this->result = 'successful';
4300 4300
         if ($this->wsdl) {
@@ -4345,14 +4345,14 @@  discard block
 block discarded – undo
4345 4345
         }
4346 4346
         $this->outgoing_headers[] = "Server: $this->title Server v$this->version";
4347 4347
         $rev = array();
4348
-        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
4349
-        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (" . (isset($rev[1]) ? $rev[1] : '') . ")";
4348
+        preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
4349
+        $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".(isset($rev[1]) ? $rev[1] : '').")";
4350 4350
         // Let the Web server decide about this
4351 4351
         //$this->outgoing_headers[] = "Connection: Close\r\n";
4352 4352
         $payload = $this->getHTTPBody($payload);
4353 4353
         $type = $this->getHTTPContentType();
4354 4354
         $charset = $this->getHTTPContentTypeCharset();
4355
-        $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : '');
4355
+        $this->outgoing_headers[] = "Content-Type: $type".($charset ? '; charset='.$charset : '');
4356 4356
         //begin code to compress payload - by John
4357 4357
         // NOTE: there is no way to know whether the Web server will also compress
4358 4358
         // this data.
@@ -4387,13 +4387,13 @@  discard block
 block discarded – undo
4387 4387
             }
4388 4388
         }
4389 4389
         //end code
4390
-        $this->outgoing_headers[] = "Content-Length: " . strlen($payload);
4390
+        $this->outgoing_headers[] = "Content-Length: ".strlen($payload);
4391 4391
         reset($this->outgoing_headers);
4392 4392
         foreach ($this->outgoing_headers as $hdr) {
4393 4393
             header($hdr, false);
4394 4394
         }
4395 4395
         print $payload;
4396
-        $this->response = join("\r\n", $this->outgoing_headers) . "\r\n\r\n" . $payload;
4396
+        $this->response = join("\r\n", $this->outgoing_headers)."\r\n\r\n".$payload;
4397 4397
     }
4398 4398
 
4399 4399
     /**
@@ -4427,19 +4427,19 @@  discard block
 block discarded – undo
4427 4427
      */
4428 4428
     function parseRequest($headers, $data)
4429 4429
     {
4430
-        $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
4430
+        $this->debug('Entering parseRequest() for data of length '.strlen($data).' headers:');
4431 4431
         $this->appendDebug($this->varDump($headers));
4432 4432
         if (!isset($headers['content-type'])) {
4433 4433
             $this->setError('Request not of type '.$this->contentType.' (no content-type header)');
4434 4434
             return false;
4435 4435
         }
4436 4436
         if (!strstr($headers['content-type'], $this->contentType)) {
4437
-            $this->setError('Request not of type '.$this->contentType.': ' . $headers['content-type']);
4437
+            $this->setError('Request not of type '.$this->contentType.': '.$headers['content-type']);
4438 4438
             return false;
4439 4439
         }
4440 4440
         if (strpos($headers['content-type'], '=')) {
4441 4441
             $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
4442
-            $this->debug('Got response encoding: ' . $enc);
4442
+            $this->debug('Got response encoding: '.$enc);
4443 4443
             if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
4444 4444
                 $this->xml_encoding = strtoupper($enc);
4445 4445
             } else {
@@ -4449,26 +4449,26 @@  discard block
 block discarded – undo
4449 4449
             // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
4450 4450
             $this->xml_encoding = 'ISO-8859-1';
4451 4451
         }
4452
-        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
4452
+        $this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
4453 4453
         // parse response, get soap parser obj
4454 4454
         $parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8);
4455 4455
         // parser debug
4456
-        $this->debug("parser debug: \n" . $parser->getDebug());
4456
+        $this->debug("parser debug: \n".$parser->getDebug());
4457 4457
         // if fault occurred during message parsing
4458 4458
         if ($err = $parser->getError()) {
4459
-            $this->result = 'fault: error in msg parsing: ' . $err;
4460
-            $this->fault('SOAP-ENV:Client', "error in msg parsing:\n" . $err);
4459
+            $this->result = 'fault: error in msg parsing: '.$err;
4460
+            $this->fault('SOAP-ENV:Client', "error in msg parsing:\n".$err);
4461 4461
             // else successfully parsed request into soapval object
4462 4462
         } else {
4463 4463
             // get/set methodname
4464 4464
             $this->methodURI = $parser->root_struct_namespace;
4465 4465
             $this->methodname = $parser->root_struct_name;
4466
-            $this->debug('methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
4466
+            $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
4467 4467
 
4468 4468
             // get/set custom response tag name
4469 4469
             $outputMessage = $this->wsdl->getOperationData($this->methodname)['output']['message'];
4470 4470
             $this->responseTagName = $outputMessage;
4471
-            $this->debug('responseTagName: ' . $this->responseTagName . ' methodURI: ' . $this->methodURI);
4471
+            $this->debug('responseTagName: '.$this->responseTagName.' methodURI: '.$this->methodURI);
4472 4472
 
4473 4473
             $this->debug('calling parser->get_soapbody()');
4474 4474
             $this->methodparams = $parser->get_soapbody();
@@ -4597,7 +4597,7 @@  discard block
 block discarded – undo
4597 4597
             $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
4598 4598
         }
4599 4599
         if (!$customResponseTagName) {
4600
-            $customResponseTagName = $name . 'Response';
4600
+            $customResponseTagName = $name.'Response';
4601 4601
         }
4602 4602
 
4603 4603
         $this->operations[$name] = array(
@@ -4674,7 +4674,7 @@  discard block
 block discarded – undo
4674 4674
         if ($SERVER_PORT == 80) {
4675 4675
             $SERVER_PORT = '';
4676 4676
         } else {
4677
-            $SERVER_PORT = ':' . $SERVER_PORT;
4677
+            $SERVER_PORT = ':'.$SERVER_PORT;
4678 4678
         }
4679 4679
         if (!$namespace) {
4680 4680
             $namespace = "http://$SERVER_NAME/soap/$serviceName";
@@ -4709,13 +4709,13 @@  discard block
 block discarded – undo
4709 4709
         $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace;
4710 4710
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
4711 4711
         $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
4712
-        $this->wsdl->bindings[$serviceName . 'Binding'] = array(
4713
-            'name' => $serviceName . 'Binding',
4712
+        $this->wsdl->bindings[$serviceName.'Binding'] = array(
4713
+            'name' => $serviceName.'Binding',
4714 4714
             'style' => $style,
4715 4715
             'transport' => $transport,
4716
-            'portType' => $serviceName . 'PortType');
4717
-        $this->wsdl->ports[$serviceName . 'Port'] = array(
4718
-            'binding' => $serviceName . 'Binding',
4716
+            'portType' => $serviceName.'PortType');
4717
+        $this->wsdl->ports[$serviceName.'Port'] = array(
4718
+            'binding' => $serviceName.'Binding',
4719 4719
             'location' => $endpoint,
4720 4720
             'bindingType' => 'http://schemas.xmlsoap.org/wsdl/soap/');
4721 4721
     }
@@ -4774,13 +4774,13 @@  discard block
 block discarded – undo
4774 4774
     var $proxypassword = '';
4775 4775
     var $timeout = 0;
4776 4776
     var $response_timeout = 30;
4777
-    var $curl_options = array();    // User-specified cURL options
4778
-    var $use_curl = false;            // whether to always try to use cURL
4777
+    var $curl_options = array(); // User-specified cURL options
4778
+    var $use_curl = false; // whether to always try to use cURL
4779 4779
     // for HTTP authentication
4780
-    var $username = '';                // Username for HTTP authentication
4781
-    var $password = '';                // Password for HTTP authentication
4782
-    var $authtype = '';                // Type of HTTP authentication
4783
-    var $certRequest = array();        // Certificate for HTTP SSL authentication
4780
+    var $username = ''; // Username for HTTP authentication
4781
+    var $password = ''; // Password for HTTP authentication
4782
+    var $authtype = ''; // Type of HTTP authentication
4783
+    var $certRequest = array(); // Certificate for HTTP SSL authentication
4784 4784
 
4785 4785
     /** @var mixed */
4786 4786
     var $currentPortOperation;
@@ -4843,7 +4843,7 @@  discard block
 block discarded – undo
4843 4843
             // Schema imports
4844 4844
             foreach ($this->schemas as $ns => $list) {
4845 4845
                 foreach ($list as $xsKey => $xs) {
4846
-                    $wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4846
+                    $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4847 4847
                     foreach ($xs->imports as $ns2 => $list2) {
4848 4848
                         for ($ii = 0; $ii < count($list2); $ii++) {
4849 4849
                             if (array_key_exists($ii, $list2) && (!isset($list2[$ii]['loaded']) || !$list2[$ii]['loaded'])) {
@@ -4852,8 +4852,8 @@  discard block
 block discarded – undo
4852 4852
                                 if ($url != '') {
4853 4853
                                     $urlparts = parse_url($url);
4854 4854
                                     if (!isset($urlparts['host'])) {
4855
-                                        $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4856
-                                            substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4855
+                                        $url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
4856
+                                            substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
4857 4857
                                     }
4858 4858
                                     if (!in_array($url, $imported_urls)) {
4859 4859
                                         $this->parseWSDL($url);
@@ -4869,7 +4869,7 @@  discard block
 block discarded – undo
4869 4869
                 }
4870 4870
             }
4871 4871
             // WSDL imports
4872
-            $wsdlparts = parse_url($this->wsdl);    // this is bogusly simple!
4872
+            $wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
4873 4873
             foreach ($this->import as $ns => $list) {
4874 4874
                 for ($ii = 0; $ii < count($list); $ii++) {
4875 4875
                     if (!$list[$ii]['loaded']) {
@@ -4878,8 +4878,8 @@  discard block
 block discarded – undo
4878 4878
                         if ($url != '') {
4879 4879
                             $urlparts = parse_url($url);
4880 4880
                             if (!isset($urlparts['host'])) {
4881
-                                $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
4882
-                                    substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
4881
+                                $url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
4882
+                                    substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
4883 4883
                             }
4884 4884
                             if (!in_array($url, $imported_urls)) {
4885 4885
                                 $this->parseWSDL($url);
@@ -4897,15 +4897,13 @@  discard block
 block discarded – undo
4897 4897
         foreach ($this->bindings as $binding => $bindingData) {
4898 4898
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
4899 4899
                 foreach ($bindingData['operations'] as $operation => $data) {
4900
-                    $this->debug('post-parse data gathering for ' . $operation);
4900
+                    $this->debug('post-parse data gathering for '.$operation);
4901 4901
                     $this->bindings[$binding]['operations'][$operation]['input'] =
4902 4902
                         isset($this->bindings[$binding]['operations'][$operation]['input']) ?
4903
-                            array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) :
4904
-                            $this->portTypes[$bindingData['portType']][$operation]['input'];
4903
+                            array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input'];
4905 4904
                     $this->bindings[$binding]['operations'][$operation]['output'] =
4906 4905
                         isset($this->bindings[$binding]['operations'][$operation]['output']) ?
4907
-                            array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) :
4908
-                            $this->portTypes[$bindingData['portType']][$operation]['output'];
4906
+                            array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output'];
4909 4907
                     if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
4910 4908
                         $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
4911 4909
                     }
@@ -4944,7 +4942,7 @@  discard block
 block discarded – undo
4944 4942
         $wsdl_props = parse_url($wsdl);
4945 4943
 
4946 4944
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
4947
-            $this->debug('getting WSDL http(s) URL ' . $wsdl);
4945
+            $this->debug('getting WSDL http(s) URL '.$wsdl);
4948 4946
             // get wsdl
4949 4947
             $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
4950 4948
             $tr->request_method = 'GET';
@@ -4962,7 +4960,7 @@  discard block
 block discarded – undo
4962 4960
             $this->appendDebug($tr->getDebug());
4963 4961
             // catch errors
4964 4962
             if ($err = $tr->getError()) {
4965
-                $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err;
4963
+                $errstr = 'Getting '.$wsdl.' - HTTP ERROR: '.$err;
4966 4964
                 $this->debug($errstr);
4967 4965
                 $this->setError($errstr);
4968 4966
                 unset($tr);
@@ -4973,11 +4971,11 @@  discard block
 block discarded – undo
4973 4971
         } else {
4974 4972
             // $wsdl is not http(s), so treat it as a file URL or plain file path
4975 4973
             if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
4976
-                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
4974
+                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'].':'.$wsdl_props['path']) : $wsdl_props['path'];
4977 4975
             } else {
4978 4976
                 $path = $wsdl;
4979 4977
             }
4980
-            $this->debug('getting WSDL file ' . $path);
4978
+            $this->debug('getting WSDL file '.$path);
4981 4979
             if ($fp = @fopen($path, 'r')) {
4982 4980
                 $wsdl_string = '';
4983 4981
                 while ($data = fread($fp, 32768)) {
@@ -5013,7 +5011,7 @@  discard block
 block discarded – undo
5013 5011
                 xml_error_string(xml_get_error_code($this->parser))
5014 5012
             );
5015 5013
             $this->debug($errstr);
5016
-            $this->debug("XML payload:\n" . $wsdl_string);
5014
+            $this->debug("XML payload:\n".$wsdl_string);
5017 5015
             $this->setError($errstr);
5018 5016
             xml_parser_free($this->parser);
5019 5017
             unset($this->parser);
@@ -5067,16 +5065,16 @@  discard block
 block discarded – undo
5067 5065
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
5068 5066
                             $this->namespaces[$ns_prefix] = $v;
5069 5067
                         } else {
5070
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
5068
+                            $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v;
5071 5069
                         }
5072 5070
                         if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
5073 5071
                             $this->XMLSchemaVersion = $v;
5074
-                            $this->namespaces['xsi'] = $v . '-instance';
5072
+                            $this->namespaces['xsi'] = $v.'-instance';
5075 5073
                         }
5076 5074
                     }
5077 5075
                 }
5078 5076
                 // expand each attribute prefix to its namespace
5079
-                $eAttrs = array ();
5077
+                $eAttrs = array();
5080 5078
                 foreach ($attrs as $k => $v) {
5081 5079
                     $k = strpos($k, ':') ? $this->expandQname($k) : $k;
5082 5080
                     if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
@@ -5107,12 +5105,12 @@  discard block
 block discarded – undo
5107 5105
                 case 'message':
5108 5106
                     if ($name == 'part') {
5109 5107
                         if (isset($attrs['type'])) {
5110
-                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
5108
+                            $this->debug("msg ".$this->currentMessage.": found part (with type) $attrs[name]: ".implode(',', $attrs));
5111 5109
                             $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
5112 5110
                         }
5113 5111
                         if (isset($attrs['element'])) {
5114
-                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
5115
-                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
5112
+                            $this->debug("msg ".$this->currentMessage.": found part (with element) $attrs[name]: ".implode(',', $attrs));
5113
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'].'^';
5116 5114
                         }
5117 5115
                     }
5118 5116
                     break;
@@ -5181,7 +5179,7 @@  discard block
 block discarded – undo
5181 5179
                     switch ($name) {
5182 5180
                         case 'port':
5183 5181
                             $this->currentPort = $attrs['name'];
5184
-                            $this->debug('current port: ' . $this->currentPort);
5182
+                            $this->debug('current port: '.$this->currentPort);
5185 5183
                             $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
5186 5184
 
5187 5185
                             break;
@@ -5199,13 +5197,13 @@  discard block
 block discarded – undo
5199 5197
                 case 'import':
5200 5198
                     if (isset($attrs['location'])) {
5201 5199
                         $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
5202
-                        $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')');
5200
+                        $this->debug('parsing import '.$attrs['namespace'].' - '.$attrs['location'].' ('.count($this->import[$attrs['namespace']]).')');
5203 5201
                     } else {
5204 5202
                         $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
5205 5203
                         if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
5206
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace'];
5204
+                            $this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace'];
5207 5205
                         }
5208
-                        $this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')');
5206
+                        $this->debug('parsing import '.$attrs['namespace'].' - [no location] ('.count($this->import[$attrs['namespace']]).')');
5209 5207
                     }
5210 5208
                     break;
5211 5209
                 //wait for schema
@@ -5232,13 +5230,13 @@  discard block
 block discarded – undo
5232 5230
                         }
5233 5231
                         $this->status = 'binding';
5234 5232
                         $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
5235
-                        $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
5233
+                        $this->debug("current binding: $this->currentBinding of portType: ".$attrs['type']);
5236 5234
                     }
5237 5235
                     break;
5238 5236
                 case 'service':
5239 5237
                     $this->serviceName = $attrs['name'];
5240 5238
                     $this->status = 'service';
5241
-                    $this->debug('current service: ' . $this->serviceName);
5239
+                    $this->debug('current service: '.$this->serviceName);
5242 5240
                     break;
5243 5241
                 case 'definitions':
5244 5242
                     foreach ($attrs as $name => $value) {
@@ -5348,7 +5346,7 @@  discard block
 block discarded – undo
5348 5346
         $this->debug("getOperations for port '$portName' bindingType $bindingType");
5349 5347
         // loop thru ports
5350 5348
         foreach ($this->ports as $port => $portData) {
5351
-            $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
5349
+            $this->debug("getOperations checking port $port bindingType ".$portData['bindingType']);
5352 5350
             if ($portName == '' || $port == $portName) {
5353 5351
                 // binding type of port matches parameter
5354 5352
                 if ($portData['bindingType'] == $bindingType) {
@@ -5390,13 +5388,13 @@  discard block
 block discarded – undo
5390 5388
                 // get binding
5391 5389
                 //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
5392 5390
                 // note that we could/should also check the namespace here
5393
-                if (in_array ($operation, array_keys ($this->bindings[$portData['binding']]['operations'])))
5391
+                if (in_array($operation, array_keys($this->bindings[$portData['binding']]['operations'])))
5394 5392
                 {
5395 5393
                     return $this->bindings[$portData['binding']]['operations'][$operation];
5396 5394
                 }
5397 5395
             }
5398 5396
         }
5399
-        return array ();
5397
+        return array();
5400 5398
     }
5401 5399
 
5402 5400
     /**
@@ -5426,7 +5424,7 @@  discard block
 block discarded – undo
5426 5424
                 }
5427 5425
             }
5428 5426
         }
5429
-        return array ();
5427
+        return array();
5430 5428
     }
5431 5429
 
5432 5430
     /**
@@ -5521,7 +5519,7 @@  discard block
 block discarded – undo
5521 5519
         }
5522 5520
 
5523 5521
         $b = '
5524
-		<html><head><title>NuSOAP: ' . $this->serviceName . '</title>
5522
+		<html><head><title>NuSOAP: ' . $this->serviceName.'</title>
5525 5523
 		<style type="text/css">
5526 5524
 		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
5527 5525
 		    p       { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; }
@@ -5598,7 +5596,7 @@  discard block
 block discarded – undo
5598 5596
 		<body>
5599 5597
 		<div class=content>
5600 5598
 			<br><br>
5601
-			<div class=title>' . $this->serviceName . '</div>
5599
+			<div class=title>' . $this->serviceName.'</div>
5602 5600
 			<div class=nav>
5603 5601
 				<p>View the <a href="?wsdl">WSDL</a> for the service.
5604 5602
 				Click on an operation name to view it&apos;s details.</p>
@@ -5610,7 +5608,7 @@  discard block
 block discarded – undo
5610 5608
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
5611 5609
             foreach ($data as $donnie => $marie) { // loop through opdata
5612 5610
                 if ($donnie == 'input' || $donnie == 'output') { // show input/output data
5613
-                    $b .= "<font color='white'>" . ucfirst($donnie) . ':</font><br>';
5611
+                    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
5614 5612
                     foreach ($marie as $captain => $tenille) { // loop through data
5615 5613
                         if ($captain == 'parts') { // loop thru parts
5616 5614
                             $b .= "&nbsp;&nbsp;$captain:<br>";
@@ -5624,7 +5622,7 @@  discard block
 block discarded – undo
5624 5622
                         }
5625 5623
                     }
5626 5624
                 } else {
5627
-                    $b .= "<font color='white'>" . ucfirst($donnie) . ":</font> $marie<br>";
5625
+                    $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
5628 5626
                 }
5629 5627
             }
5630 5628
             $b .= '</div>';
@@ -5652,10 +5650,10 @@  discard block
 block discarded – undo
5652 5650
         }
5653 5651
         // 10.9.02 - add poulter fix for wsdl and tns declarations
5654 5652
         if (isset($this->namespaces['wsdl'])) {
5655
-            $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
5653
+            $xml .= " xmlns=\"".$this->namespaces['wsdl']."\"";
5656 5654
         }
5657 5655
         if (isset($this->namespaces['tns'])) {
5658
-            $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
5656
+            $xml .= " targetNamespace=\"".$this->namespaces['tns']."\"";
5659 5657
         }
5660 5658
         $xml .= '>';
5661 5659
         // imports
@@ -5663,9 +5661,9 @@  discard block
 block discarded – undo
5663 5661
             foreach ($this->import as $ns => $list) {
5664 5662
                 foreach ($list as $ii) {
5665 5663
                     if ($ii['location'] != '') {
5666
-                        $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
5664
+                        $xml .= '<import location="'.$ii['location'].'" namespace="'.$ns.'" />';
5667 5665
                     } else {
5668
-                        $xml .= '<import namespace="' . $ns . '" />';
5666
+                        $xml .= '<import namespace="'.$ns.'" />';
5669 5667
                     }
5670 5668
                 }
5671 5669
             }
@@ -5683,7 +5681,7 @@  discard block
 block discarded – undo
5683 5681
         // messages
5684 5682
         if (count($this->messages) >= 1) {
5685 5683
             foreach ($this->messages as $msgName => $msgParts) {
5686
-                $xml .= "\n<message name=\"" . $msgName . '">';
5684
+                $xml .= "\n<message name=\"".$msgName.'">';
5687 5685
                 if (is_array($msgParts)) {
5688 5686
                     foreach ($msgParts as $partName => $partType) {
5689 5687
                         // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
@@ -5713,7 +5711,7 @@  discard block
 block discarded – undo
5713 5711
                         } else {
5714 5712
                             $elementortype = 'type';
5715 5713
                         }
5716
-                        $xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
5714
+                        $xml .= "\n".'  <part name="'.$partName.'" '.$elementortype.'="'.$typePrefix.':'.$localPart.'" />';
5717 5715
                     }
5718 5716
                 }
5719 5717
                 $xml .= '</message>';
@@ -5724,53 +5722,53 @@  discard block
 block discarded – undo
5724 5722
             $binding_xml = '';
5725 5723
             $portType_xml = '';
5726 5724
             foreach ($this->bindings as $bindingName => $attrs) {
5727
-                $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
5728
-                $binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
5729
-                $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
5725
+                $binding_xml .= "\n<binding name=\"".$bindingName.'" type="tns:'.$attrs['portType'].'">';
5726
+                $binding_xml .= "\n".'  <soap:binding style="'.$attrs['style'].'" transport="'.$attrs['transport'].'"/>';
5727
+                $portType_xml .= "\n<portType name=\"".$attrs['portType'].'">';
5730 5728
                 foreach ($attrs['operations'] as $opName => $opParts) {
5731
-                    $binding_xml .= "\n" . '  <operation name="' . $opName . '">';
5732
-                    $binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="' . $opParts['style'] . '"/>';
5729
+                    $binding_xml .= "\n".'  <operation name="'.$opName.'">';
5730
+                    $binding_xml .= "\n".'    <soap:operation soapAction="'.$opParts['soapAction'].'" style="'.$opParts['style'].'"/>';
5733 5731
                     if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
5734
-                        $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
5732
+                        $enc_style = ' encodingStyle="'.$opParts['input']['encodingStyle'].'"';
5735 5733
                     } else {
5736 5734
                         $enc_style = '';
5737 5735
                     }
5738
-                    $binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
5736
+                    $binding_xml .= "\n".'    <input><soap:body use="'.$opParts['input']['use'].'" namespace="'.$opParts['input']['namespace'].'"'.$enc_style.'/></input>';
5739 5737
                     if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
5740
-                        $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
5738
+                        $enc_style = ' encodingStyle="'.$opParts['output']['encodingStyle'].'"';
5741 5739
                     } else {
5742 5740
                         $enc_style = '';
5743 5741
                     }
5744
-                    $binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
5745
-                    $binding_xml .= "\n" . '  </operation>';
5746
-                    $portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
5742
+                    $binding_xml .= "\n".'    <output><soap:body use="'.$opParts['output']['use'].'" namespace="'.$opParts['output']['namespace'].'"'.$enc_style.'/></output>';
5743
+                    $binding_xml .= "\n".'  </operation>';
5744
+                    $portType_xml .= "\n".'  <operation name="'.$opParts['name'].'"';
5747 5745
                     if (isset($opParts['parameterOrder'])) {
5748
-                        $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
5746
+                        $portType_xml .= ' parameterOrder="'.$opParts['parameterOrder'].'"';
5749 5747
                     }
5750 5748
                     $portType_xml .= '>';
5751 5749
                     if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
5752
-                        $portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
5750
+                        $portType_xml .= "\n".'    <documentation>'.htmlspecialchars($opParts['documentation']).'</documentation>';
5753 5751
                     }
5754
-                    $portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
5755
-                    $portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
5756
-                    $portType_xml .= "\n" . '  </operation>';
5752
+                    $portType_xml .= "\n".'    <input message="tns:'.$opParts['input']['message'].'"/>';
5753
+                    $portType_xml .= "\n".'    <output message="tns:'.$opParts['output']['message'].'"/>';
5754
+                    $portType_xml .= "\n".'  </operation>';
5757 5755
                 }
5758
-                $portType_xml .= "\n" . '</portType>';
5759
-                $binding_xml .= "\n" . '</binding>';
5756
+                $portType_xml .= "\n".'</portType>';
5757
+                $binding_xml .= "\n".'</binding>';
5760 5758
             }
5761
-            $xml .= $portType_xml . $binding_xml;
5759
+            $xml .= $portType_xml.$binding_xml;
5762 5760
         }
5763 5761
         // services
5764
-        $xml .= "\n<service name=\"" . $this->serviceName . '">';
5762
+        $xml .= "\n<service name=\"".$this->serviceName.'">';
5765 5763
         if (count($this->ports) >= 1) {
5766 5764
             foreach ($this->ports as $pName => $attrs) {
5767
-                $xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
5768
-                $xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
5769
-                $xml .= "\n" . '  </port>';
5765
+                $xml .= "\n".'  <port name="'.$pName.'" binding="tns:'.$attrs['binding'].'">';
5766
+                $xml .= "\n".'    <soap:address location="'.$attrs['location'].($debug ? '?debug=1' : '').'"/>';
5767
+                $xml .= "\n".'  </port>';
5770 5768
             }
5771 5769
         }
5772
-        $xml .= "\n" . '</service>';
5773
-        return $xml . "\n</definitions>";
5770
+        $xml .= "\n".'</service>';
5771
+        return $xml."\n</definitions>";
5774 5772
     }
5775 5773
 
5776 5774
     /**
@@ -5869,7 +5867,7 @@  discard block
 block discarded – undo
5869 5867
     function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap')
5870 5868
     {
5871 5869
         $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
5872
-        $this->appendDebug('parameters=' . $this->varDump($parameters));
5870
+        $this->appendDebug('parameters='.$this->varDump($parameters));
5873 5871
 
5874 5872
         if ($direction != 'input' && $direction != 'output') {
5875 5873
             $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -5877,8 +5875,8 @@  discard block
 block discarded – undo
5877 5875
             return false;
5878 5876
         }
5879 5877
         if (!$opData = $this->getOperationData($operation, $bindingType)) {
5880
-            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5881
-            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
5878
+            $this->debug('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
5879
+            $this->setError('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
5882 5880
             return false;
5883 5881
         }
5884 5882
         $this->debug('in serializeRPCParameters: opData:');
@@ -5969,7 +5967,7 @@  discard block
 block discarded – undo
5969 5967
     function serializeParameters($operation, $direction, $parameters)
5970 5968
     {
5971 5969
         $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
5972
-        $this->appendDebug('parameters=' . $this->varDump($parameters));
5970
+        $this->appendDebug('parameters='.$this->varDump($parameters));
5973 5971
 
5974 5972
         if ($direction != 'input' && $direction != 'output') {
5975 5973
             $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -5977,8 +5975,8 @@  discard block
 block discarded – undo
5977 5975
             return false;
5978 5976
         }
5979 5977
         if (!$opData = $this->getOperationData($operation)) {
5980
-            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
5981
-            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
5978
+            $this->debug('Unable to retrieve WSDL data for operation: '.$operation);
5979
+            $this->setError('Unable to retrieve WSDL data for operation: '.$operation);
5982 5980
             return false;
5983 5981
         }
5984 5982
         $this->debug('opData:');
@@ -5996,12 +5994,12 @@  discard block
 block discarded – undo
5996 5994
 
5997 5995
             $use = $opData[$direction]['use'];
5998 5996
             $this->debug("use=$use");
5999
-            $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
5997
+            $this->debug('got '.count($opData[$direction]['parts']).' part(s)');
6000 5998
             if (is_array($parameters)) {
6001 5999
                 $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
6002
-                $this->debug('have ' . $parametersArrayType . ' parameters');
6000
+                $this->debug('have '.$parametersArrayType.' parameters');
6003 6001
                 foreach ($opData[$direction]['parts'] as $name => $type) {
6004
-                    $this->debug('serializing part "' . $name . '" of type "' . $type . '"');
6002
+                    $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
6005 6003
                     // Track encoding style
6006 6004
                     if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
6007 6005
                         $encodingStyle = $opData[$direction]['encodingStyle'];
@@ -6046,16 +6044,16 @@  discard block
 block discarded – undo
6046 6044
      */
6047 6045
     function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false)
6048 6046
     {
6049
-        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
6050
-        $this->appendDebug("value=" . $this->varDump($value));
6047
+        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=".($unqualified ? "unqualified" : "qualified"));
6048
+        $this->appendDebug("value=".$this->varDump($value));
6051 6049
         if ($use == 'encoded' && $encodingStyle) {
6052
-            $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
6050
+            $encodingStyle = ' SOAP-ENV:encodingStyle="'.$encodingStyle.'"';
6053 6051
         }
6054 6052
 
6055 6053
         // if a soapval has been supplied, let its type override the WSDL
6056 6054
         if (is_object($value) && get_class($value) == 'soapval') {
6057 6055
             if ($value->type_ns) {
6058
-                $type = $value->type_ns . ':' . $value->type;
6056
+                $type = $value->type_ns.':'.$value->type;
6059 6057
                 $forceType = true;
6060 6058
                 $this->debug("in serializeType: soapval overrides type to $type");
6061 6059
             } elseif ($value->type) {
@@ -6074,7 +6072,7 @@  discard block
 block discarded – undo
6074 6072
                     $value['!'] = $value;
6075 6073
                 }
6076 6074
                 foreach ($attrs as $n => $v) {
6077
-                    $value['!' . $n] = $v;
6075
+                    $value['!'.$n] = $v;
6078 6076
                 }
6079 6077
                 $this->debug("in serializeType: soapval provides attributes");
6080 6078
             }
@@ -6105,7 +6103,7 @@  discard block
 block discarded – undo
6105 6103
                         $xml = "<$name$elementNS/>";
6106 6104
                     } else {
6107 6105
                         // TODO: depends on nillable, which should be checked before calling this method
6108
-                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6106
+                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
6109 6107
                     }
6110 6108
                     $this->debug("in serializeType: returning: $xml");
6111 6109
                     return $xml;
@@ -6133,12 +6131,12 @@  discard block
 block discarded – undo
6133 6131
                 if (!$this->getTypeDef($uqType, $ns)) {
6134 6132
                     if ($use == 'literal') {
6135 6133
                         if ($forceType) {
6136
-                            $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6134
+                            $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
6137 6135
                         } else {
6138 6136
                             $xml = "<$name$elementNS>$value</$name>";
6139 6137
                         }
6140 6138
                     } else {
6141
-                        $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6139
+                        $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
6142 6140
                     }
6143 6141
                     $this->debug("in serializeType: returning: $xml");
6144 6142
                     return $xml;
@@ -6150,7 +6148,7 @@  discard block
 block discarded – undo
6150 6148
                     $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
6151 6149
                     if (!$tt_prefix) {
6152 6150
                         $this->debug('in serializeType: Add namespace for Apache SOAP type');
6153
-                        $tt_prefix = 'ns' . rand(1000, 9999);
6151
+                        $tt_prefix = 'ns'.rand(1000, 9999);
6154 6152
                         $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
6155 6153
                         // force this to be added to usedNamespaces
6156 6154
                         $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
@@ -6165,12 +6163,12 @@  discard block
 block discarded – undo
6165 6163
                     }
6166 6164
                     if ($use == 'literal') {
6167 6165
                         if ($forceType) {
6168
-                            $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
6166
+                            $xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\">$contents</$name>";
6169 6167
                         } else {
6170 6168
                             $xml = "<$name>$contents</$name>";
6171 6169
                         }
6172 6170
                     } else {
6173
-                        $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
6171
+                        $xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\"$encodingStyle>$contents</$name>";
6174 6172
                     }
6175 6173
                     $this->debug("in serializeType: returning: $xml");
6176 6174
                     return $xml;
@@ -6190,7 +6188,7 @@  discard block
 block discarded – undo
6190 6188
             return false;
6191 6189
         } else {
6192 6190
             $this->debug("in serializeType: found typeDef");
6193
-            $this->appendDebug('typeDef=' . $this->varDump($typeDef));
6191
+            $this->appendDebug('typeDef='.$this->varDump($typeDef));
6194 6192
             if (substr($uqType, -1) == '^') {
6195 6193
                 $uqType = substr($uqType, 0, -1);
6196 6194
             }
@@ -6201,7 +6199,7 @@  discard block
 block discarded – undo
6201 6199
             return false;
6202 6200
         }
6203 6201
         $phpType = $typeDef['phpType'];
6204
-        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
6202
+        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: ".(isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
6205 6203
         // if php type == struct, map value to the <all> element names
6206 6204
         if ($phpType == 'struct') {
6207 6205
             if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
@@ -6224,7 +6222,7 @@  discard block
 block discarded – undo
6224 6222
                     // TODO: depends on minOccurs and nillable
6225 6223
                     $xml = "<$elementName$elementNS/>";
6226 6224
                 } else {
6227
-                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
6225
+                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
6228 6226
                 }
6229 6227
                 $this->debug("in serializeType: returning: $xml");
6230 6228
                 return $xml;
@@ -6236,12 +6234,12 @@  discard block
 block discarded – undo
6236 6234
                 $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
6237 6235
                 if ($use == 'literal') {
6238 6236
                     if ($forceType) {
6239
-                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
6237
+                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">";
6240 6238
                     } else {
6241 6239
                         $xml = "<$elementName$elementNS$elementAttrs>";
6242 6240
                     }
6243 6241
                 } else {
6244
-                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
6242
+                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>";
6245 6243
                 }
6246 6244
 
6247 6245
                 if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
@@ -6275,14 +6273,14 @@  discard block
 block discarded – undo
6275 6273
                     // TODO: depends on minOccurs
6276 6274
                     $xml = "<$name$elementNS/>";
6277 6275
                 } else {
6278
-                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
6279
-                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6280
-                        ":Array\" " .
6281
-                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
6282
-                        ':arrayType="' .
6283
-                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
6284
-                        ':' .
6285
-                        $this->getLocalPart($typeDef['arrayType']) . "[0]\"/>";
6276
+                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".
6277
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
6278
+                        ":Array\" ".
6279
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
6280
+                        ':arrayType="'.
6281
+                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])).
6282
+                        ':'.
6283
+                        $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
6286 6284
                 }
6287 6285
                 $this->debug("in serializeType: returning: $xml");
6288 6286
                 return $xml;
@@ -6291,7 +6289,7 @@  discard block
 block discarded – undo
6291 6289
             if (isset($typeDef['multidimensional'])) {
6292 6290
                 $nv = array();
6293 6291
                 foreach ($value as $v) {
6294
-                    $cols = ',' . sizeof($v);
6292
+                    $cols = ','.sizeof($v);
6295 6293
                     $nv = array_merge($nv, $v);
6296 6294
                 }
6297 6295
                 $value = $nv;
@@ -6321,11 +6319,11 @@  discard block
 block discarded – undo
6321 6319
                     . $contents
6322 6320
                     . "</$name>";
6323 6321
             } else {
6324
-                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':Array" ' .
6322
+                $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
6325 6323
                     $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
6326 6324
                     . ':arrayType="'
6327 6325
                     . $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
6328
-                    . ":" . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">"
6326
+                    . ":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
6329 6327
                     . $contents
6330 6328
                     . "</$name>";
6331 6329
             }
@@ -6341,12 +6339,12 @@  discard block
 block discarded – undo
6341 6339
             }
6342 6340
             if ($use == 'literal') {
6343 6341
                 if ($forceType) {
6344
-                    $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
6342
+                    $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
6345 6343
                 } else {
6346 6344
                     $xml = "<$name$elementNS>$value</$name>";
6347 6345
                 }
6348 6346
             } else {
6349
-                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
6347
+                $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
6350 6348
             }
6351 6349
         }
6352 6350
         $this->debug("in serializeType: returning: $xml");
@@ -6391,22 +6389,22 @@  discard block
 block discarded – undo
6391 6389
                 $xvalue = array();
6392 6390
             }
6393 6391
             foreach ($typeDef['attrs'] as $aName => $attrs) {
6394
-                if (isset($xvalue['!' . $aName])) {
6395
-                    $xname = '!' . $aName;
6392
+                if (isset($xvalue['!'.$aName])) {
6393
+                    $xname = '!'.$aName;
6396 6394
                     $this->debug("value provided for attribute $aName with key $xname");
6397 6395
                 } elseif (isset($xvalue[$aName])) {
6398 6396
                     $xname = $aName;
6399 6397
                     $this->debug("value provided for attribute $aName with key $xname");
6400 6398
                 } elseif (isset($attrs['default'])) {
6401
-                    $xname = '!' . $aName;
6399
+                    $xname = '!'.$aName;
6402 6400
                     $xvalue[$xname] = $attrs['default'];
6403
-                    $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
6401
+                    $this->debug('use default value of '.$xvalue[$aName].' for attribute '.$aName);
6404 6402
                 } else {
6405 6403
                     $xname = '';
6406 6404
                     $this->debug("no value provided for attribute $aName");
6407 6405
                 }
6408 6406
                 if ($xname) {
6409
-                    $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
6407
+                    $xml .= " $aName=\"".$this->expandEntities($xvalue[$xname])."\"";
6410 6408
                 }
6411 6409
             }
6412 6410
         } else {
@@ -6462,7 +6460,7 @@  discard block
 block discarded – undo
6462 6460
                 if (!isset($xvalue[$eName])) {
6463 6461
                     if (isset($attrs['default'])) {
6464 6462
                         $xvalue[$eName] = $attrs['default'];
6465
-                        $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
6463
+                        $this->debug('use default value of '.$xvalue[$eName].' for element '.$eName);
6466 6464
                     }
6467 6465
                 }
6468 6466
                 // if user took advantage of a minOccurs=0, then only serialize named parameters
@@ -6471,7 +6469,7 @@  discard block
 block discarded – undo
6471 6469
                     && ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
6472 6470
                 ) {
6473 6471
                     if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
6474
-                        $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
6472
+                        $this->debug("apparent error: no value provided for element $eName with minOccurs=".$attrs['minOccurs']);
6475 6473
                     }
6476 6474
                     // do nothing
6477 6475
                     $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
@@ -6500,27 +6498,27 @@  discard block
 block discarded – undo
6500 6498
                             }
6501 6499
                         }
6502 6500
                     } else {
6503
-                        if (!is_null ($v) || !isset($attrs['minOccurs']) || $attrs['minOccurs'] != '0')
6501
+                        if (!is_null($v) || !isset($attrs['minOccurs']) || $attrs['minOccurs'] != '0')
6504 6502
                         {
6505
-                            if (is_null ($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true')
6503
+                            if (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true')
6506 6504
                             {
6507 6505
                                 // TODO: serialize a nil correctly, but for now serialize schema-defined type
6508
-                                $xml .= $this->serializeType ($eName,
6506
+                                $xml .= $this->serializeType($eName,
6509 6507
                                                               isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6510 6508
                                                               $v, $use, $encodingStyle, $unqualified);
6511 6509
                             }
6512 6510
                             elseif (isset($attrs['type']) || isset($attrs['ref']))
6513 6511
                             {
6514 6512
                                 // serialize schema-defined type
6515
-                                $xml .= $this->serializeType ($eName,
6513
+                                $xml .= $this->serializeType($eName,
6516 6514
                                                               isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6517 6515
                                                               $v, $use, $encodingStyle, $unqualified);
6518 6516
                             }
6519 6517
                             else
6520 6518
                             {
6521 6519
                                 // serialize generic type (can this ever really happen?)
6522
-                                $this->debug ("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6523
-                                $xml .= $this->serialize_val ($v, $eName, false, false, false, false, $use);
6520
+                                $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
6521
+                                $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
6524 6522
                             }
6525 6523
                         }
6526 6524
                     }
@@ -6564,9 +6562,9 @@  discard block
 block discarded – undo
6564 6562
         }
6565 6563
 
6566 6564
         if (is_array($attrs) && count($attrs) > 0) {
6567
-            $eAttrs = array ();
6565
+            $eAttrs = array();
6568 6566
             foreach ($attrs as $n => $a) {
6569
-                $aa = array ();
6567
+                $aa = array();
6570 6568
                 // expand each attribute
6571 6569
                 foreach ($a as $k => $v) {
6572 6570
                     $k = strpos($k, ':') ? $this->expandQname($k) : $k;
@@ -6643,24 +6641,24 @@  discard block
 block discarded – undo
6643 6641
             foreach ($in as $n => $t) {
6644 6642
                 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6645 6643
             }
6646
-            $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
6647
-            $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
6648
-            $in = array('parameters' => 'tns:' . $name . '^');
6644
+            $this->addComplexType($name.'RequestType', 'complexType', 'struct', 'all', '', $elements);
6645
+            $this->addElement(array('name' => $name, 'type' => $name.'RequestType'));
6646
+            $in = array('parameters' => 'tns:'.$name.'^');
6649 6647
 
6650 6648
             $elements = array();
6651 6649
             foreach ($out as $n => $t) {
6652 6650
                 $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
6653 6651
             }
6654
-            $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
6655
-            $this->addElement(array('name' => $customResponseTagName, 'type' => $name . 'ResponseType', 'form' => 'qualified'));
6656
-            $out = array('parameters' => 'tns:' . $customResponseTagName . '^');
6652
+            $this->addComplexType($name.'ResponseType', 'complexType', 'struct', 'all', '', $elements);
6653
+            $this->addElement(array('name' => $customResponseTagName, 'type' => $name.'ResponseType', 'form' => 'qualified'));
6654
+            $out = array('parameters' => 'tns:'.$customResponseTagName.'^');
6657 6655
         }
6658 6656
 
6659 6657
         // get binding
6660
-        $this->bindings[$this->serviceName . 'Binding']['operations'][$name] =
6658
+        $this->bindings[$this->serviceName.'Binding']['operations'][$name] =
6661 6659
             array(
6662 6660
                 'name' => $name,
6663
-                'binding' => $this->serviceName . 'Binding',
6661
+                'binding' => $this->serviceName.'Binding',
6664 6662
                 'endpoint' => $this->endpoint,
6665 6663
                 'soapAction' => $soapaction,
6666 6664
                 'style' => $style,
@@ -6684,7 +6682,7 @@  discard block
 block discarded – undo
6684 6682
         if ($in) {
6685 6683
             foreach ($in as $pName => $pType) {
6686 6684
                 if (strpos($pType, ':')) {
6687
-                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6685
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
6688 6686
                 }
6689 6687
                 $this->messages[$name][$pName] = $pType;
6690 6688
             }
@@ -6694,7 +6692,7 @@  discard block
 block discarded – undo
6694 6692
         if ($out) {
6695 6693
             foreach ($out as $pName => $pType) {
6696 6694
                 if (strpos($pType, ':')) {
6697
-                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType);
6695
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
6698 6696
                 }
6699 6697
                 $this->messages[$customResponseTagName][$pName] = $pType;
6700 6698
             }
@@ -6727,7 +6725,7 @@  discard block
 block discarded – undo
6727 6725
     var $root_struct_name = '';
6728 6726
     var $root_struct_namespace = '';
6729 6727
     var $root_header = '';
6730
-    var $document = '';            // incoming SOAP body (text)
6728
+    var $document = ''; // incoming SOAP body (text)
6731 6729
     // determines where in the message we are (envelope,header,body,method)
6732 6730
     var $status = '';
6733 6731
     var $position = 0;
@@ -6742,9 +6740,9 @@  discard block
 block discarded – undo
6742 6740
     var $fault_detail = '';
6743 6741
     var $depth_array = array();
6744 6742
     var $debug_flag = true;
6745
-    var $soapresponse = null;    // parsed SOAP Body
6746
-    var $soapheader = null;        // parsed SOAP Header
6747
-    var $responseHeaders = '';    // incoming SOAP headers (text)
6743
+    var $soapresponse = null; // parsed SOAP Body
6744
+    var $soapheader = null; // parsed SOAP Header
6745
+    var $responseHeaders = ''; // incoming SOAP headers (text)
6748 6746
     var $body_position = 0;
6749 6747
     // for multiref parsing:
6750 6748
     // array of id => pos
@@ -6783,7 +6781,7 @@  discard block
 block discarded – undo
6783 6781
                 if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6784 6782
                     $xml_encoding = $res[1];
6785 6783
                     if (strtoupper($xml_encoding) != $encoding) {
6786
-                        $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6784
+                        $err = "Charset from HTTP Content-Type '".$encoding."' does not match encoding from XML declaration '".$xml_encoding."'";
6787 6785
                         $this->debug($err);
6788 6786
                         if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6789 6787
                             $this->setError($err);
@@ -6799,7 +6797,7 @@  discard block
 block discarded – undo
6799 6797
             } else {
6800 6798
                 $this->debug('No XML declaration');
6801 6799
             }
6802
-            $this->debug('Entering nusoap_parser(), length=' . strlen($xml) . ', encoding=' . $encoding);
6800
+            $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
6803 6801
             // Create an XML parser - why not xml_parser_create_ns?
6804 6802
             $this->parser = xml_parser_create($this->xml_encoding);
6805 6803
             // Set the options for parsing the XML data.
@@ -6813,9 +6811,9 @@  discard block
 block discarded – undo
6813 6811
             xml_set_character_data_handler($this->parser, 'character_data');
6814 6812
             $parseErrors = array();
6815 6813
             $chunkSize = 4096;
6816
-            for($pointer = 0; $pointer < strlen($xml) && empty($parseErrors); $pointer += $chunkSize) {
6814
+            for ($pointer = 0; $pointer < strlen($xml) && empty($parseErrors); $pointer += $chunkSize) {
6817 6815
             	$xmlString = substr($xml, $pointer, $chunkSize);
6818
-            	if(!xml_parse($this->parser, $xmlString)) {
6816
+            	if (!xml_parse($this->parser, $xmlString)) {
6819 6817
             		$parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6820 6818
             		$parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6821 6819
             	}
@@ -6825,23 +6823,23 @@  discard block
 block discarded – undo
6825 6823
 
6826 6824
             // Check if there is any attachment
6827 6825
             $this->attachments = array();
6828
-            foreach(preg_split("/((\r?\n)|(\r\n?))/", $xml) as $line){
6829
-                if(preg_match(("/^--(.*)/"), $line, $matches)) {
6830
-                    $this->attachments[] = array ();
6831
-                    $this->attachments[count($this->attachments)-1]['boundaryStr'] = $matches[1];
6832
-                } elseif(preg_match(("/Content-Type:(.*)/"), $line, $matches)) {
6833
-                    $this->attachments[count($this->attachments)-1]['Content-Type'] = $matches[1];
6834
-                } elseif(preg_match(("/Content-Id:(.*)/"), $line, $matches)) {
6835
-                    $this->attachments[count($this->attachments)-1]['Content-Id'] = $matches[1];
6836
-                } elseif(preg_match(("/Content-Transfer-Encoding:(.*)/"), $line, $matches)) {
6837
-                    $this->attachments[count($this->attachments)-1]['Content-Transfer-Encoding'] = $matches[1];
6826
+            foreach (preg_split("/((\r?\n)|(\r\n?))/", $xml) as $line) {
6827
+                if (preg_match(("/^--(.*)/"), $line, $matches)) {
6828
+                    $this->attachments[] = array();
6829
+                    $this->attachments[count($this->attachments) - 1]['boundaryStr'] = $matches[1];
6830
+                } elseif (preg_match(("/Content-Type:(.*)/"), $line, $matches)) {
6831
+                    $this->attachments[count($this->attachments) - 1]['Content-Type'] = $matches[1];
6832
+                } elseif (preg_match(("/Content-Id:(.*)/"), $line, $matches)) {
6833
+                    $this->attachments[count($this->attachments) - 1]['Content-Id'] = $matches[1];
6834
+                } elseif (preg_match(("/Content-Transfer-Encoding:(.*)/"), $line, $matches)) {
6835
+                    $this->attachments[count($this->attachments) - 1]['Content-Transfer-Encoding'] = $matches[1];
6838 6836
                 }
6839 6837
             }
6840 6838
 
6841
-            if(!empty($this->attachments)) {
6839
+            if (!empty($this->attachments)) {
6842 6840
                 // Extract the content of each attachments
6843 6841
                 $substrXml = $xml;
6844
-                foreach($this->attachments as $key => $attachment) {
6842
+                foreach ($this->attachments as $key => $attachment) {
6845 6843
                     $startPos = max(
6846 6844
                         stripos($substrXml, $attachment['boundaryStr']),
6847 6845
                         (array_key_exists('Content-Type', $attachment) ? stripos($substrXml, $attachment['Content-Type']) : 0),
@@ -6853,17 +6851,17 @@  discard block
 block discarded – undo
6853 6851
                     $substrXml = substr($substrXml, $startPos);
6854 6852
                     $substrXml = trim($substrXml);
6855 6853
                     $length = null;
6856
-                    if(array_key_exists($key+1, $this->attachments) && $this->attachments[$key+1] && !empty($this->attachments[$key+1]['boundaryStr'])) {
6857
-                        $length = stripos($substrXml, ('--' . $this->attachments[$key+1]['boundaryStr']))-1;
6854
+                    if (array_key_exists($key + 1, $this->attachments) && $this->attachments[$key + 1] && !empty($this->attachments[$key + 1]['boundaryStr'])) {
6855
+                        $length = stripos($substrXml, ('--'.$this->attachments[$key + 1]['boundaryStr'])) - 1;
6858 6856
                     }
6859 6857
                     $content = substr($substrXml, 0, $length);
6860 6858
                     $this->attachments[$key]['content'] = $content;
6861 6859
                 }
6862 6860
             }
6863 6861
 
6864
-            if(!empty($parseErrors) && !empty($this->attachments)){
6862
+            if (!empty($parseErrors) && !empty($this->attachments)) {
6865 6863
                 // Search the SOAP response message
6866
-                foreach($this->attachments as $key => $attachment) {
6864
+                foreach ($this->attachments as $key => $attachment) {
6867 6865
                     // Settings for xml_parse
6868 6866
                     $this->parser = xml_parser_create($this->xml_encoding);
6869 6867
                     xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
@@ -6872,11 +6870,11 @@  discard block
 block discarded – undo
6872 6870
                     xml_set_element_handler($this->parser, 'start_element', 'end_element');
6873 6871
                     xml_set_character_data_handler($this->parser, 'character_data');
6874 6872
 
6875
-                    if(!empty($attachment['content'])) {
6873
+                    if (!empty($attachment['content'])) {
6876 6874
                         $content = $attachment['content'];
6877
-                        foreach(preg_split("/((\r?\n)|(\r\n?))/", $content) as $line){
6878
-                            if(preg_match(("/:Envelope/"), $line, $matches)) {
6879
-                                if(!xml_parse($this->parser, $content, true)) {
6875
+                        foreach (preg_split("/((\r?\n)|(\r\n?))/", $content) as $line) {
6876
+                            if (preg_match(("/:Envelope/"), $line, $matches)) {
6877
+                                if (!xml_parse($this->parser, $content, true)) {
6880 6878
                                     $parseErrors['lineNumber'] = xml_get_current_line_number($this->parser);
6881 6879
                                     $parseErrors['errorString'] = xml_error_string(xml_get_error_code($this->parser));
6882 6880
                                 } else {
@@ -6890,7 +6888,7 @@  discard block
 block discarded – undo
6890 6888
                 }
6891 6889
             }
6892 6890
 
6893
-            if(!empty($parseErrors)){
6891
+            if (!empty($parseErrors)) {
6894 6892
             	// Display an error message.
6895 6893
             	$err = sprintf('XML error parsing SOAP payload on line %d: %s',
6896 6894
             			$parseErrors['lineNumber'],
@@ -6900,7 +6898,7 @@  discard block
 block discarded – undo
6900 6898
             } else {
6901 6899
                 $this->debug('in nusoap_parser ctor, message:');
6902 6900
                 $this->appendDebug($this->varDump($this->message));
6903
-                $this->debug('parsed successfully, found root struct: ' . $this->root_struct . ' of name ' . $this->root_struct_name);
6901
+                $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
6904 6902
                 // get final value
6905 6903
                 $this->soapresponse = $this->message[$this->root_struct]['result'];
6906 6904
                 // get header value
@@ -6910,13 +6908,13 @@  discard block
 block discarded – undo
6910 6908
                 // resolve hrefs/ids
6911 6909
                 if (sizeof($this->multirefs) > 0) {
6912 6910
                     foreach ($this->multirefs as $id => $hrefs) {
6913
-                        $this->debug('resolving multirefs for id: ' . $id);
6911
+                        $this->debug('resolving multirefs for id: '.$id);
6914 6912
                         $idVal = $this->buildVal($this->ids[$id]);
6915 6913
                         if (is_array($idVal) && isset($idVal['!id'])) {
6916 6914
                             unset($idVal['!id']);
6917 6915
                         }
6918 6916
                         foreach ($hrefs as $refPos => $ref) {
6919
-                            $this->debug('resolving href at pos ' . $refPos);
6917
+                            $this->debug('resolving href at pos '.$refPos);
6920 6918
                             $this->multirefs[$id][$refPos] = $idVal;
6921 6919
                         }
6922 6920
                     }
@@ -6951,7 +6949,7 @@  discard block
 block discarded – undo
6951 6949
 
6952 6950
         // else add self as child to whoever the current parent is
6953 6951
         if ($pos != 0) {
6954
-            $this->message[$this->parent]['children'] .= '|' . $pos;
6952
+            $this->message[$this->parent]['children'] .= '|'.$pos;
6955 6953
         }
6956 6954
         // set my parent
6957 6955
         $this->message[$pos]['parent'] = $this->parent;
@@ -7000,7 +6998,7 @@  discard block
 block discarded – undo
7000 6998
                 if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
7001 6999
                     $this->XMLSchemaVersion = $value;
7002 7000
                     $this->namespaces['xsd'] = $this->XMLSchemaVersion;
7003
-                    $this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
7001
+                    $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
7004 7002
                 }
7005 7003
                 $this->namespaces[$key_localpart] = $value;
7006 7004
                 // set method namespace
@@ -7011,17 +7009,17 @@  discard block
 block discarded – undo
7011 7009
             } elseif ($key_localpart == 'type') {
7012 7010
                 if (!isset($this->message[$pos]['type']) || $this->message[$pos]['type'] != 'array')
7013 7011
                 {
7014
-                    $value_prefix = $this->getPrefix ($value);
7015
-                    $value_localpart = $this->getLocalPart ($value);
7012
+                    $value_prefix = $this->getPrefix($value);
7013
+                    $value_localpart = $this->getLocalPart($value);
7016 7014
                     $this->message[$pos]['type'] = $value_localpart;
7017 7015
                     $this->message[$pos]['typePrefix'] = $value_prefix;
7018 7016
                     if (isset($this->namespaces[$value_prefix]))
7019 7017
                     {
7020 7018
                         $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
7021 7019
                     }
7022
-                    elseif (isset($attrs['xmlns:' . $value_prefix]))
7020
+                    elseif (isset($attrs['xmlns:'.$value_prefix]))
7023 7021
                     {
7024
-                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
7022
+                        $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
7025 7023
                     }
7026 7024
                     // should do something here with the namespace of specified type?
7027 7025
                 }
@@ -7041,8 +7039,8 @@  discard block
 block discarded – undo
7041 7039
                     $this->message[$pos]['arrayTypePrefix'] = $regs[1];
7042 7040
                     if (isset($this->namespaces[$regs[1]])) {
7043 7041
                         $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
7044
-                    } elseif (isset($attrs['xmlns:' . $regs[1]])) {
7045
-                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
7042
+                    } elseif (isset($attrs['xmlns:'.$regs[1]])) {
7043
+                        $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
7046 7044
                     }
7047 7045
                     $this->message[$pos]['arrayType'] = $regs[2];
7048 7046
                     $this->message[$pos]['arraySize'] = $regs[3];
@@ -7053,7 +7051,7 @@  discard block
 block discarded – undo
7053 7051
                 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
7054 7052
                 // some other attribute
7055 7053
             } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
7056
-                $this->message[$pos]['xattrs']['!' . $key] = $value;
7054
+                $this->message[$pos]['xattrs']['!'.$key] = $value;
7057 7055
             }
7058 7056
 
7059 7057
             if ($key == 'xmlns') {
@@ -7082,10 +7080,10 @@  discard block
 block discarded – undo
7082 7080
         }
7083 7081
         if ($this->status == 'header') {
7084 7082
             if ($this->root_header != $pos) {
7085
-                $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7083
+                $this->responseHeaders .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
7086 7084
             }
7087 7085
         } elseif ($this->root_struct_name != '') {
7088
-            $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
7086
+            $this->document .= "<".(isset($prefix) ? $prefix.':' : '')."$name$attstr>";
7089 7087
         }
7090 7088
     }
7091 7089
 
@@ -7118,7 +7116,7 @@  discard block
 block discarded – undo
7118 7116
                 // add placeholder to href array
7119 7117
                 $this->multirefs[$id][$pos] = 'placeholder';
7120 7118
                 // add set a reference to it as the result value
7121
-                $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
7119
+                $this->message[$pos]['result'] = & $this->multirefs[$id][$pos];
7122 7120
                 // build complexType values
7123 7121
             } elseif ($this->message[$pos]['children'] != '') {
7124 7122
                 // if result has already been generated (struct/array)
@@ -7174,10 +7172,10 @@  discard block
 block discarded – undo
7174 7172
         // for doclit
7175 7173
         if ($this->status == 'header') {
7176 7174
             if ($this->root_header != $pos) {
7177
-                $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7175
+                $this->responseHeaders .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
7178 7176
             }
7179 7177
         } elseif ($pos >= $this->root_struct) {
7180
-            $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
7178
+            $this->document .= "</".(isset($prefix) ? $prefix.':' : '')."$name>";
7181 7179
         }
7182 7180
         // switch status
7183 7181
         if ($pos == $this->root_struct) {
@@ -7328,7 +7326,7 @@  discard block
 block discarded – undo
7328 7326
         if (!isset($this->message[$pos]['type'])) {
7329 7327
             $this->message[$pos]['type'] = '';
7330 7328
         }
7331
-        $this->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos $pos) of type " . $this->message[$pos]['type']);
7329
+        $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
7332 7330
         // if there are children...
7333 7331
         if ($this->message[$pos]['children'] != '') {
7334 7332
             $params = [];
@@ -7350,13 +7348,13 @@  discard block
 block discarded – undo
7350 7348
                 }
7351 7349
                 // array
7352 7350
             } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7353
-                $this->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
7351
+                $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
7354 7352
                 foreach ($children as $child_pos) {
7355 7353
                     $params[] = &$this->message[$child_pos]['result'];
7356 7354
                 }
7357 7355
                 // apache Map type: java hashtable
7358 7356
             } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7359
-                $this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
7357
+                $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
7360 7358
                 foreach ($children as $child_pos) {
7361 7359
                     $kv = explode("|", $this->message[$child_pos]['children']);
7362 7360
                     $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
@@ -7365,7 +7363,7 @@  discard block
 block discarded – undo
7365 7363
                 //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
7366 7364
             } else {
7367 7365
                 // Apache Vector type: treat as an array
7368
-                $this->debug('in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos]['name']);
7366
+                $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']);
7369 7367
                 if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7370 7368
                     $notstruct = 1;
7371 7369
                 } else {
@@ -7469,37 +7467,37 @@  discard block
 block discarded – undo
7469 7467
     var $return = null;
7470 7468
     var $operation = '';
7471 7469
     var $opData = array();
7472
-    var $username = '';                // Username for HTTP authentication
7473
-    var $password = '';                // Password for HTTP authentication
7474
-    var $authtype = '';                // Type of HTTP authentication
7475
-    var $certRequest = array();        // Certificate for HTTP SSL authentication
7476
-    var $requestHeaders = false;    // SOAP headers in request (text)
7477
-    var $responseHeaders = '';        // SOAP headers from response (incomplete namespace resolution) (text)
7478
-    var $responseHeader = null;        // SOAP Header from response (parsed)
7479
-    var $document = '';                // SOAP body response portion (incomplete namespace resolution) (text)
7470
+    var $username = ''; // Username for HTTP authentication
7471
+    var $password = ''; // Password for HTTP authentication
7472
+    var $authtype = ''; // Type of HTTP authentication
7473
+    var $certRequest = array(); // Certificate for HTTP SSL authentication
7474
+    var $requestHeaders = false; // SOAP headers in request (text)
7475
+    var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text)
7476
+    var $responseHeader = null; // SOAP Header from response (parsed)
7477
+    var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text)
7480 7478
     var $endpoint;
7481
-    var $forceEndpoint = '';        // overrides WSDL endpoint
7479
+    var $forceEndpoint = ''; // overrides WSDL endpoint
7482 7480
     var $proxyhost = '';
7483 7481
     var $proxyport = '';
7484 7482
     var $proxyusername = '';
7485 7483
     var $proxypassword = '';
7486
-    var $portName = '';                // port name to use in WSDL
7487
-    var $xml_encoding = '';            // character set encoding of incoming (response) messages
7484
+    var $portName = ''; // port name to use in WSDL
7485
+    var $xml_encoding = ''; // character set encoding of incoming (response) messages
7488 7486
     var $http_encoding = false;
7489
-    var $timeout = 0;                // HTTP connection timeout
7490
-    var $response_timeout = 30;        // HTTP response timeout
7491
-    var $endpointType = '';            // soap|wsdl, empty for WSDL initialization error
7487
+    var $timeout = 0; // HTTP connection timeout
7488
+    var $response_timeout = 30; // HTTP response timeout
7489
+    var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error
7492 7490
     var $persistentConnection = false;
7493
-    var $defaultRpcParams = false;    // This is no longer used
7494
-    var $request = '';                // HTTP request
7495
-    var $response = '';                // HTTP response
7496
-    var $responseData = '';            // SOAP payload of response
7497
-    var $cookies = array();            // Cookies from response or for request
7498
-    var $decode_utf8 = true;        // toggles whether the parser decodes element content w/ utf8_decode()
7499
-    var $operations = array();        // WSDL operations, empty for WSDL initialization error
7500
-    var $curl_options = array();    // User-specified cURL options
7501
-    var $bindingType = '';            // WSDL operation binding type
7502
-    var $use_curl = false;            // whether to always try to use cURL
7491
+    var $defaultRpcParams = false; // This is no longer used
7492
+    var $request = ''; // HTTP request
7493
+    var $response = ''; // HTTP response
7494
+    var $responseData = ''; // SOAP payload of response
7495
+    var $cookies = array(); // Cookies from response or for request
7496
+    var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode()
7497
+    var $operations = array(); // WSDL operations, empty for WSDL initialization error
7498
+    var $curl_options = array(); // User-specified cURL options
7499
+    var $bindingType = ''; // WSDL operation binding type
7500
+    var $use_curl = false; // whether to always try to use cURL
7503 7501
 
7504 7502
     /*
7505 7503
 	 * fault related variables
@@ -7557,7 +7555,7 @@  discard block
 block discarded – undo
7557 7555
         $this->portName = $portName;
7558 7556
 
7559 7557
         $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
7560
-        $this->appendDebug('endpoint=' . $this->varDump($endpoint));
7558
+        $this->appendDebug('endpoint='.$this->varDump($endpoint));
7561 7559
 
7562 7560
         // make values
7563 7561
         if ($wsdl) {
@@ -7565,12 +7563,12 @@  discard block
 block discarded – undo
7565 7563
                 $this->wsdl = $endpoint;
7566 7564
                 $this->endpoint = $this->wsdl->wsdl;
7567 7565
                 $this->wsdlFile = $this->endpoint;
7568
-                $this->debug('existing wsdl instance created from ' . $this->endpoint);
7566
+                $this->debug('existing wsdl instance created from '.$this->endpoint);
7569 7567
                 $this->checkWSDL();
7570 7568
             } else {
7571 7569
                 $this->wsdlFile = $this->endpoint;
7572 7570
                 $this->wsdl = null;
7573
-                $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
7571
+                $this->debug('will use lazy evaluation of wsdl from '.$this->endpoint);
7574 7572
             }
7575 7573
             $this->endpointType = 'wsdl';
7576 7574
         } else {
@@ -7619,8 +7617,8 @@  discard block
 block discarded – undo
7619 7617
         $usewrapped = false;
7620 7618
 
7621 7619
         $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
7622
-        $this->appendDebug('params=' . $this->varDump($params));
7623
-        $this->appendDebug('headers=' . $this->varDump($headers));
7620
+        $this->appendDebug('params='.$this->varDump($params));
7621
+        $this->appendDebug('headers='.$this->varDump($headers));
7624 7622
         if ($headers) {
7625 7623
             $this->requestHeaders = $headers;
7626 7624
         }
@@ -7635,7 +7633,7 @@  discard block
 block discarded – undo
7635 7633
             // use WSDL for operation
7636 7634
             $this->opData = $opData;
7637 7635
             $this->debug("found operation");
7638
-            $this->appendDebug('opData=' . $this->varDump($opData));
7636
+            $this->appendDebug('opData='.$this->varDump($opData));
7639 7637
             if (isset($opData['soapAction'])) {
7640 7638
                 $soapAction = $opData['soapAction'];
7641 7639
             }
@@ -7649,7 +7647,7 @@  discard block
 block discarded – undo
7649 7647
             $use = $opData['input']['use'];
7650 7648
             // add ns to ns array
7651 7649
             if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
7652
-                $nsPrefix = 'ns' . rand(1000, 9999);
7650
+                $nsPrefix = 'ns'.rand(1000, 9999);
7653 7651
                 $this->wsdl->namespaces[$nsPrefix] = $namespace;
7654 7652
             }
7655 7653
             $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
@@ -7674,21 +7672,21 @@  discard block
 block discarded – undo
7674 7672
             $this->appendDebug($this->wsdl->getDebug());
7675 7673
             $this->wsdl->clearDebug();
7676 7674
             if ($errstr = $this->wsdl->getError()) {
7677
-                $this->debug('got wsdl error: ' . $errstr);
7678
-                $this->setError('wsdl error: ' . $errstr);
7675
+                $this->debug('got wsdl error: '.$errstr);
7676
+                $this->setError('wsdl error: '.$errstr);
7679 7677
                 return false;
7680 7678
             }
7681 7679
         } elseif ($this->endpointType == 'wsdl') {
7682 7680
             // operation not in WSDL
7683 7681
             $this->appendDebug($this->wsdl->getDebug());
7684 7682
             $this->wsdl->clearDebug();
7685
-            $this->setError('operation ' . $operation . ' not present in WSDL.');
7683
+            $this->setError('operation '.$operation.' not present in WSDL.');
7686 7684
             $this->debug("operation '$operation' not present in WSDL.");
7687 7685
             return false;
7688 7686
         } else {
7689 7687
             // no WSDL
7690 7688
             //$this->namespaces['ns1'] = $namespace;
7691
-            $nsPrefix = 'ns' . rand(1000, 9999);
7689
+            $nsPrefix = 'ns'.rand(1000, 9999);
7692 7690
             // serialize
7693 7691
             $payload = '';
7694 7692
 
@@ -7729,11 +7727,11 @@  discard block
 block discarded – undo
7729 7727
 			$this->debug("wrapping document request with literal method element");
7730 7728
 
7731 7729
 			if ($namespace) {
7732
-				$payload = "<$operation xmlns=\"$namespace\">" .
7733
-					$payload .
7730
+				$payload = "<$operation xmlns=\"$namespace\">".
7731
+					$payload.
7734 7732
                     "</$operation>";
7735 7733
 			} else {
7736
-				$payload = "<$operation>" . $payload . "</$operation>";
7734
+				$payload = "<$operation>".$payload."</$operation>";
7737 7735
 			}
7738 7736
 		}
7739 7737
 
@@ -7743,21 +7741,21 @@  discard block
 block discarded – undo
7743 7741
                 $this->debug("wrapping RPC request with literal method element");
7744 7742
                 if ($namespace) {
7745 7743
                     // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
7746
-                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7747
-                        $payload .
7744
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
7745
+                        $payload.
7748 7746
                         "</$nsPrefix:$operation>";
7749 7747
                 } else {
7750
-                    $payload = "<$operation>" . $payload . "</$operation>";
7748
+                    $payload = "<$operation>".$payload."</$operation>";
7751 7749
                 }
7752 7750
             } else {
7753 7751
                 $this->debug("wrapping RPC request with encoded method element");
7754 7752
                 if ($namespace) {
7755
-                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
7756
-                        $payload .
7753
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
7754
+                        $payload.
7757 7755
                         "</$nsPrefix:$operation>";
7758 7756
                 } else {
7759
-                    $payload = "<$operation>" .
7760
-                        $payload .
7757
+                    $payload = "<$operation>".
7758
+                        $payload.
7761 7759
                         "</$operation>";
7762 7760
                 }
7763 7761
             }
@@ -7765,26 +7763,26 @@  discard block
 block discarded – undo
7765 7763
         // serialize envelope
7766 7764
         $soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle);
7767 7765
         $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
7768
-        $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
7766
+        $this->debug('SOAP message length='.strlen($soapmsg).' contents (max 1000 bytes)='.substr($soapmsg, 0, 1000));
7769 7767
         // send
7770 7768
         $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
7771 7769
         if ($errstr = $this->getError()) {
7772
-            $this->debug('Error: ' . $errstr);
7770
+            $this->debug('Error: '.$errstr);
7773 7771
             return false;
7774 7772
         } else {
7775 7773
             $this->return = $return;
7776
-            $this->debug('sent message successfully and got a(n) ' . gettype($return));
7777
-            $this->appendDebug('return=' . $this->varDump($return));
7774
+            $this->debug('sent message successfully and got a(n) '.gettype($return));
7775
+            $this->appendDebug('return='.$this->varDump($return));
7778 7776
 
7779 7777
             // fault?
7780 7778
             if (is_array($return) && isset($return['faultcode'])) {
7781 7779
                 $this->debug('got fault');
7782
-                $this->setError($return['faultcode'] . ': ' . $return['faultstring']);
7780
+                $this->setError($return['faultcode'].': '.$return['faultstring']);
7783 7781
                 $this->fault = true;
7784 7782
                 foreach ($return as $k => $v) {
7785 7783
                     $this->$k = $v;
7786 7784
                     if (is_array($v)) {
7787
-                        $this->debug("$k = " . json_encode($v));
7785
+                        $this->debug("$k = ".json_encode($v));
7788 7786
                     } else {
7789 7787
                         $this->debug("$k = $v<br>");
7790 7788
                     }
@@ -7829,18 +7827,18 @@  discard block
 block discarded – undo
7829 7827
         if ($errstr = $this->wsdl->getError()) {
7830 7828
             $this->appendDebug($this->wsdl->getDebug());
7831 7829
             $this->wsdl->clearDebug();
7832
-            $this->debug('got wsdl error: ' . $errstr);
7833
-            $this->setError('wsdl error: ' . $errstr);
7830
+            $this->debug('got wsdl error: '.$errstr);
7831
+            $this->setError('wsdl error: '.$errstr);
7834 7832
         } elseif ($this->operations = $this->wsdl->getOperations($this->portName)) {
7835 7833
             $this->appendDebug($this->wsdl->getDebug());
7836 7834
             $this->wsdl->clearDebug();
7837 7835
             $this->bindingType = 'soap';
7838
-            $this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7836
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
7839 7837
         } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
7840 7838
             $this->appendDebug($this->wsdl->getDebug());
7841 7839
             $this->wsdl->clearDebug();
7842 7840
             $this->bindingType = 'soap12';
7843
-            $this->debug('got ' . count($this->operations) . ' operations from wsdl ' . $this->wsdlFile . ' for binding type ' . $this->bindingType);
7841
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
7844 7842
             $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
7845 7843
         } else {
7846 7844
             $this->appendDebug($this->wsdl->getDebug());
@@ -7857,7 +7855,7 @@  discard block
 block discarded – undo
7857 7855
      */
7858 7856
     function loadWSDL()
7859 7857
     {
7860
-        $this->debug('instantiating wsdl class with doc: ' . $this->wsdlFile);
7858
+        $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
7861 7859
         $this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
7862 7860
         $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7863 7861
         $this->wsdl->fetchWSDL($this->wsdlFile);
@@ -7909,7 +7907,7 @@  discard block
 block discarded – undo
7909 7907
             case preg_match('/^http/', $this->endpoint):
7910 7908
                 $this->debug('transporting via HTTP');
7911 7909
                 if ($this->persistentConnection && is_object($this->persistentConnection)) {
7912
-                    $http =& $this->persistentConnection;
7910
+                    $http = & $this->persistentConnection;
7913 7911
                 } else {
7914 7912
                     $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
7915 7913
                     if ($this->persistentConnection) {
@@ -7927,7 +7925,7 @@  discard block
 block discarded – undo
7927 7925
                 if ($this->http_encoding != '') {
7928 7926
                     $http->setEncoding($this->http_encoding);
7929 7927
                 }
7930
-                $this->debug('sending message, length=' . strlen($msg));
7928
+                $this->debug('sending message, length='.strlen($msg));
7931 7929
                 if (preg_match('/^http:/', $this->endpoint)) {
7932 7930
                     //if(strpos($this->endpoint,'http:')){
7933 7931
                     $this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
@@ -7956,12 +7954,12 @@  discard block
 block discarded – undo
7956 7954
                 }
7957 7955
 
7958 7956
                 if ($err = $http->getError()) {
7959
-                    $this->setError('HTTP Error: ' . $err);
7957
+                    $this->setError('HTTP Error: '.$err);
7960 7958
                     return false;
7961 7959
                 } elseif ($this->getError()) {
7962 7960
                     return false;
7963 7961
                 } else {
7964
-                    $this->debug('got response, length=' . strlen($this->responseData) . ' type=' . $http->incoming_headers['content-type']);
7962
+                    $this->debug('got response, length='.strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
7965 7963
                     return $this->parseResponse($http->incoming_headers, $this->responseData);
7966 7964
                 }
7967 7965
             default:
@@ -7980,19 +7978,19 @@  discard block
 block discarded – undo
7980 7978
      */
7981 7979
     function parseResponse($headers, $data)
7982 7980
     {
7983
-        $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
7981
+        $this->debug('Entering parseResponse() for data of length '.strlen($data).' headers:');
7984 7982
         $this->appendDebug($this->varDump($headers));
7985 7983
         if (!isset($headers['content-type'])) {
7986 7984
             $this->setError('Response not of type '.$this->contentType.' (no content-type header)');
7987 7985
             return false;
7988 7986
         }
7989 7987
         if (!strstr($headers['content-type'], $this->contentType)) {
7990
-            $this->setError('Response not of type '.$this->contentType.': ' . $headers['content-type']);
7988
+            $this->setError('Response not of type '.$this->contentType.': '.$headers['content-type']);
7991 7989
             return false;
7992 7990
         }
7993 7991
         if (strpos($headers['content-type'], '=')) {
7994 7992
             $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
7995
-            $this->debug('Got response encoding: ' . $enc);
7993
+            $this->debug('Got response encoding: '.$enc);
7996 7994
             if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
7997 7995
                 $this->xml_encoding = strtoupper($enc);
7998 7996
             } else {
@@ -8002,7 +8000,7 @@  discard block
 block discarded – undo
8002 8000
             // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
8003 8001
             $this->xml_encoding = 'ISO-8859-1';
8004 8002
         }
8005
-        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
8003
+        $this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
8006 8004
         $parser = new nusoap_parser($data, $this->xml_encoding, $this->operations, $this->decode_utf8);
8007 8005
         // add parser debug data to our debug
8008 8006
         $this->appendDebug($parser->getDebug());
@@ -8254,7 +8252,7 @@  discard block
 block discarded – undo
8254 8252
     function _getProxyClassCode($r)
8255 8253
     {
8256 8254
         $this->debug("in getProxy endpointType=$this->endpointType");
8257
-        $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
8255
+        $this->appendDebug("wsdl=".$this->varDump($this->wsdl));
8258 8256
         if ($this->endpointType != 'wsdl') {
8259 8257
             $evalStr = 'A proxy can only be created for a WSDL client';
8260 8258
             $this->setError($evalStr);
@@ -8264,7 +8262,7 @@  discard block
 block discarded – undo
8264 8262
         if (is_null($this->wsdl)) {
8265 8263
             $this->loadWSDL();
8266 8264
             if ($this->getError()) {
8267
-                return "echo \"" . $this->getError() . "\";";
8265
+                return "echo \"".$this->getError()."\";";
8268 8266
             }
8269 8267
         }
8270 8268
         $evalStr = '';
@@ -8288,9 +8286,9 @@  discard block
 block discarded – undo
8288 8286
                 }
8289 8287
                 $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
8290 8288
                 $evalStr .= "// $paramCommentStr
8291
-	function " . str_replace('.', '__', $operation) . "($paramStr) {
8289
+	function ".str_replace('.', '__', $operation)."($paramStr) {
8292 8290
 		\$params = array($paramArrayStr);
8293
-		return \$this->call('$operation', \$params, '" . $opData['namespace'] . "', '" . (isset($opData['soapAction']) ? $opData['soapAction'] : '') . "');
8291
+		return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
8294 8292
 	}
8295 8293
 	";
8296 8294
                 unset($paramStr);
@@ -8298,8 +8296,8 @@  discard block
 block discarded – undo
8298 8296
             }
8299 8297
         }
8300 8298
 
8301
-      return 'class nusoap_proxy_' . $r . ' extends nusoap_client {
8302
-' . $evalStr . '
8299
+      return 'class nusoap_proxy_'.$r.' extends nusoap_client {
8300
+' . $evalStr.'
8303 8301
 }';
8304 8302
     }
8305 8303
 
@@ -8346,7 +8344,7 @@  discard block
 block discarded – undo
8346 8344
      * @param   string $contentTypeNew
8347 8345
      * @return  void
8348 8346
      */
8349
-    function setHTTPContentType($contentTypeNew = "text/xml"){
8347
+    function setHTTPContentType($contentTypeNew = "text/xml") {
8350 8348
         $this->contentType = $contentTypeNew;
8351 8349
     }
8352 8350
 
@@ -8415,7 +8413,7 @@  discard block
 block discarded – undo
8415 8413
         if (sizeof($this->cookies) == 0) {
8416 8414
             return true;
8417 8415
         }
8418
-        $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
8416
+        $this->debug('checkCookie: check '.sizeof($this->cookies).' cookies');
8419 8417
         $curr_cookies = $this->cookies;
8420 8418
         $this->cookies = array();
8421 8419
         foreach ($curr_cookies as $cookie) {
@@ -8427,13 +8425,13 @@  discard block
 block discarded – undo
8427 8425
                 if (strtotime($cookie['expires']) > time()) {
8428 8426
                     $this->cookies[] = $cookie;
8429 8427
                 } else {
8430
-                    $this->debug('Remove expired cookie ' . $cookie['name']);
8428
+                    $this->debug('Remove expired cookie '.$cookie['name']);
8431 8429
                 }
8432 8430
             } else {
8433 8431
                 $this->cookies[] = $cookie;
8434 8432
             }
8435 8433
         }
8436
-        $this->debug('checkCookie: ' . sizeof($this->cookies) . ' cookies left in array');
8434
+        $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
8437 8435
         return true;
8438 8436
     }
8439 8437
 
@@ -8492,11 +8490,11 @@  discard block
 block discarded – undo
8492 8490
                 }
8493 8491
                 $this->cookies[$i] = $newCookie;
8494 8492
                 $found = true;
8495
-                $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
8493
+                $this->debug('Update cookie '.$newName.'='.$newCookie['value']);
8496 8494
                 break;
8497 8495
             }
8498 8496
             if (!$found) {
8499
-                $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
8497
+                $this->debug('Add cookie '.$newName.'='.$newCookie['value']);
8500 8498
                 $this->cookies[] = $newCookie;
8501 8499
             }
8502 8500
         }
@@ -8551,7 +8549,7 @@  discard block
 block discarded – undo
8551 8549
      * @param integer $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited
8552 8550
      * @access public
8553 8551
      */
8554
-    function __construct($cache_dir='.', $cache_lifetime=0) {
8552
+    function __construct($cache_dir = '.', $cache_lifetime = 0) {
8555 8553
         $this->fplock = array();
8556 8554
         $this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
8557 8555
         $this->cache_lifetime = $cache_lifetime;
@@ -8565,7 +8563,7 @@  discard block
 block discarded – undo
8565 8563
      * @access private
8566 8564
      */
8567 8565
     function createFilename($wsdl) {
8568
-        return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
8566
+        return $this->cache_dir.'/wsdlcache-'.md5($wsdl);
8569 8567
     }
8570 8568
 
8571 8569
     /**
@@ -8574,7 +8572,7 @@  discard block
 block discarded – undo
8574 8572
      * @param    string $string debug data
8575 8573
      * @access   private
8576 8574
      */
8577
-    function debug($string){
8575
+    function debug($string) {
8578 8576
         $this->debug_str .= get_class($this).": $string\n";
8579 8577
     }
8580 8578
 
@@ -8653,7 +8651,7 @@  discard block
 block discarded – undo
8653 8651
         $s = serialize($wsdl_instance);
8654 8652
         if ($this->obtainMutex($filename, "w")) {
8655 8653
             $fp = fopen($filename, "w");
8656
-            if (! $fp) {
8654
+            if (!$fp) {
8657 8655
                 $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache");
8658 8656
                 $this->releaseMutex($filename);
8659 8657
                 return false;
@@ -8680,7 +8678,7 @@  discard block
 block discarded – undo
8680 8678
         $ret = flock($this->fplock[md5($filename)], LOCK_UN);
8681 8679
         fclose($this->fplock[md5($filename)]);
8682 8680
         unset($this->fplock[md5($filename)]);
8683
-        if (! $ret) {
8681
+        if (!$ret) {
8684 8682
             $this->debug("Not able to release lock for $filename");
8685 8683
         }
8686 8684
         return $ret;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -6508,15 +6508,13 @@  discard block
 block discarded – undo
6508 6508
                                 $xml .= $this->serializeType ($eName,
6509 6509
                                                               isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6510 6510
                                                               $v, $use, $encodingStyle, $unqualified);
6511
-                            }
6512
-                            elseif (isset($attrs['type']) || isset($attrs['ref']))
6511
+                            } elseif (isset($attrs['type']) || isset($attrs['ref']))
6513 6512
                             {
6514 6513
                                 // serialize schema-defined type
6515 6514
                                 $xml .= $this->serializeType ($eName,
6516 6515
                                                               isset($attrs['type']) ? $attrs['type'] : $attrs['ref'],
6517 6516
                                                               $v, $use, $encodingStyle, $unqualified);
6518
-                            }
6519
-                            else
6517
+                            } else
6520 6518
                             {
6521 6519
                                 // serialize generic type (can this ever really happen?)
6522 6520
                                 $this->debug ("calling serialize_val() for $v, $eName, false, false, false, false, $use");
@@ -7018,8 +7016,7 @@  discard block
 block discarded – undo
7018 7016
                     if (isset($this->namespaces[$value_prefix]))
7019 7017
                     {
7020 7018
                         $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
7021
-                    }
7022
-                    elseif (isset($attrs['xmlns:' . $value_prefix]))
7019
+                    } elseif (isset($attrs['xmlns:' . $value_prefix]))
7023 7020
                     {
7024 7021
                         $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
7025 7022
                     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2028,7 +2028,7 @@  discard block
 block discarded – undo
2028 2028
             'arrayType' => $arrayType
2029 2029
         );
2030 2030
 
2031
-        $this->xdebug("addComplexType $name:");
2031
+        $this->xdebug("addcomplextype $name:");
2032 2032
         $this->appendDebug($this->varDump($this->complexTypes[$name]));
2033 2033
     }
2034 2034
 
@@ -2054,7 +2054,7 @@  discard block
 block discarded – undo
2054 2054
             'enumeration' => $enumeration
2055 2055
         );
2056 2056
 
2057
-        $this->xdebug("addSimpleType $name:");
2057
+        $this->xdebug("addsimpletype $name:");
2058 2058
         $this->appendDebug($this->varDump($this->simpleTypes[$name]));
2059 2059
     }
2060 2060
 
@@ -3269,7 +3269,7 @@  discard block
 block discarded – undo
3269 3269
 
3270 3270
         // see if we need to resend the request with http digest authentication
3271 3271
         if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3272
-            $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3272
+            $this->debug("got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3273 3273
             $this->setURL($this->incoming_headers['location']);
3274 3274
             $this->tryagain = true;
3275 3275
             return false;
@@ -5120,7 +5120,7 @@  discard block
 block discarded – undo
5120 5120
                     switch ($name) {
5121 5121
                         case 'operation':
5122 5122
                             $this->currentPortOperation = $attrs['name'];
5123
-                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
5123
+                            $this->debug("porttype $this->currentPortType operation: $this->currentPortOperation");
5124 5124
                             if (isset($attrs['parameterOrder'])) {
5125 5125
                                 $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
5126 5126
                             }
@@ -8592,7 +8592,7 @@  discard block
 block discarded – undo
8592 8592
             if ($this->cache_lifetime > 0) {
8593 8593
                 if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
8594 8594
                     unlink($filename);
8595
-                    $this->debug("Expired $wsdl ($filename) from cache");
8595
+                    $this->debug("expired $wsdl ($filename) from cache");
8596 8596
                     $this->releaseMutex($filename);
8597 8597
                     return null;
8598 8598
                 }
@@ -8607,7 +8607,7 @@  discard block
 block discarded – undo
8607 8607
             if ($fp) {
8608 8608
                 $s = implode("", @file($filename));
8609 8609
                 fclose($fp);
8610
-                $this->debug("Got $wsdl ($filename) from cache");
8610
+                $this->debug("got $wsdl ($filename) from cache");
8611 8611
             } else {
8612 8612
                 $s = null;
8613 8613
                 $this->debug("$wsdl ($filename) not in cache (2)");
@@ -8660,7 +8660,7 @@  discard block
 block discarded – undo
8660 8660
             }
8661 8661
             fputs($fp, $s);
8662 8662
             fclose($fp);
8663
-            $this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
8663
+            $this->debug("put $wsdl_instance->wsdl ($filename) in cache");
8664 8664
             $this->releaseMutex($filename);
8665 8665
             return true;
8666 8666
         } else {
Please login to merge, or discard this patch.
htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -232,12 +232,12 @@
 block discarded – undo
232 232
 		if ($response != '') {
233 233
 			libxml_clear_errors();
234 234
 			libxml_use_internal_errors(true);
235
-			libxml_disable_entity_loader(true);	// Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900
235
+			libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900
236 236
 
237 237
 			if (!function_exists('simplexml_load_string')) {
238 238
 				throw new PrestaShopWebserviceException('Method simplexml_load_string not available. Your PHP does not support xml.');
239 239
 			}
240
-			$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA|LIBXML_NONET);
240
+			$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA | LIBXML_NONET);
241 241
 			if (libxml_get_errors()) {
242 242
 				$msg = var_export(libxml_get_errors(), true);
243 243
 				libxml_clear_errors();
Please login to merge, or discard this patch.
htdocs/core/class/rssparser.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -260,9 +260,9 @@
 block discarded – undo
260 260
 			if (getDolGlobalString('EXTERNALRSS_USE_SIMPLEXML')) {
261 261
 				//print 'xx'.LIBXML_NOCDATA;
262 262
 				libxml_use_internal_errors(false);
263
-				libxml_disable_entity_loader(true);	// Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900
263
+				libxml_disable_entity_loader(true); // Avoid load of external entities (security problem). Required only if LIBXML_VERSION < 20900
264 264
 
265
-				$rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA|LIBXML_NOCDATA);
265
+				$rss = simplexml_load_string($str, "SimpleXMLElement", LIBXML_NOCDATA | LIBXML_NOCDATA);
266 266
 			} else {
267 267
 				if (!function_exists('xml_parser_create')) {
268 268
 					$this->error = 'Function xml_parser_create are not supported by your PHP';
Please login to merge, or discard this patch.