This file is indexed.

/usr/share/php/SOAP/Client.php is in php-soap 0.13.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
<?php
/**
 * This file contains the code for the SOAP client.
 *
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 2.02 of the PHP license,
 * that is bundled with this package in the file LICENSE, and is available at
 * through the world-wide-web at http://www.php.net/license/2_02.txt.  If you
 * did not receive a copy of the PHP license and are unable to obtain it
 * through the world-wide-web, please send a note to license@php.net so we can
 * mail you a copy immediately.
 *
 * @category   Web Services
 * @package    SOAP
 * @author     Dietrich Ayala <dietrich@ganx4.com> Original Author
 * @author     Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
 * @author     Chuck Hagenbuch <chuck@horde.org>   Maintenance
 * @author     Jan Schneider <jan@horde.org>       Maintenance
 * @copyright  2003-2005 The PHP Group
 * @license    http://www.php.net/license/2_02.txt  PHP License 2.02
 * @link       http://pear.php.net/package/SOAP
 */

/** SOAP_Value */
require_once 'SOAP/Value.php';
require_once 'SOAP/Base.php';
require_once 'SOAP/Transport.php';
require_once 'SOAP/WSDL.php';
require_once 'SOAP/Fault.php';
require_once 'SOAP/Parser.php';

// Arnaud: the following code was taken from DataObject and adapted to suit

// this will be horrifically slow!!!!
// NOTE: Overload SEGFAULTS ON PHP4 + Zend Optimizer
// these two are BC/FC handlers for call in PHP4/5

/**
 * @package SOAP
 */
if (!class_exists('SOAP_Client_Overload')) {
    if (substr(zend_version(), 0, 1) > 1) {
        class SOAP_Client_Overload extends SOAP_Base {
            function __call($method, $args)
            {
                $return = null;
                $this->_call($method, $args, $return);
                return $return;
            }
        }
    } else {
        if (!function_exists('clone')) {
            eval('function clone($t) { return $t; }');
        }
        eval('
            class SOAP_Client_Overload extends SOAP_Base {
                function __call($method, $args, &$return)
                {
                    return $this->_call($method, $args, $return);
                }
            }');
    }
}

/**
 * SOAP Client Class
 *
 * This class is the main interface for making soap requests.
 *
 * basic usage:<code>
 *   $soapclient = new SOAP_Client( string path [ , boolean wsdl] );
 *   echo $soapclient->call( string methodname [ , array parameters] );
 * </code>
 * or, if using PHP 5+ or the overload extension:<code>
 *   $soapclient = new SOAP_Client( string path [ , boolean wsdl] );
 *   echo $soapclient->methodname( [ array parameters] );
 * </code>
 *
 * Originally based on SOAPx4 by Dietrich Ayala
 * http://dietrich.ganx4.com/soapx4
 *
 * @access   public
 * @package  SOAP
 * @author   Shane Caraveo <shane@php.net> Conversion to PEAR and updates
 * @author   Stig Bakken <ssb@fast.no> Conversion to PEAR
 * @author   Dietrich Ayala <dietrich@ganx4.com> Original Author
 */
class SOAP_Client extends SOAP_Client_Overload
{
    /**
     * Communication endpoint.
     *
     * Currently the following transport formats are supported:
     *  - HTTP
     *  - SMTP
     *
     * Example endpoints:
     *   http://www.example.com/soap/server.php
     *   https://www.example.com/soap/server.php
     *   mailto:soap@example.com
     *
     * @see SOAP_Client()
     * @var string
     */
    var $_endpoint = '';

    /**
     * The SOAP PORT name that is used by the client.
     *
     * @var string
     */
    var $_portName = '';

    /**
     * Endpoint type e.g. 'wdsl'.
     *
     * @var string
     */
    var $_endpointType = '';

    /**
     * The received xml.
     *
     * @var string
     */
    var $xml;

    /**
     * The outgoing and incoming data stream for debugging.
     *
     * @var string
     */
    var $wire;

    /**
     * The outgoing data stream for debugging.
     *
     * @var string
     */
    var $_last_request = null;

    /**
     * The incoming data stream for debugging.
     *
     * @var string
     */
    var $_last_response = null;

    /**
     * Options.
     *
     * @var array
     */
    var $_options = array('trace' => false);

    /**
     * The character encoding used for XML parser, etc.
     *
     * @var string
     */
    var $_encoding = SOAP_DEFAULT_ENCODING;

    /**
     * The array of SOAP_Headers that we are sending.
     *
     * @var array
     */
    var $headersOut = null;

    /**
     * The headers we recieved back in the response.
     *
     * @var array
     */
    var $headersIn = null;

    /**
     * Options for the HTTP_Request class (see HTTP/Request.php).
     *
     * @var array
     */
    var $_proxy_params = array();

    /**
     * The SOAP_Transport instance.
     *
     * @var SOAP_Transport
     */
    var $_soap_transport = null;

    /**
     * Constructor.
     *
     * @access public
     *
     * @param string $endpoint       An URL.
     * @param boolean $wsdl          Whether the endpoint is a WSDL file.
     * @param string $portName       The service's port name to use.
     * @param array $proxy_params    Options for the HTTP_Request class
     *                               @see HTTP_Request
     * @param boolean|string $cache  Use WSDL caching? The cache directory if
     *                               a string.
     */
    function SOAP_Client($endpoint, $wsdl = false, $portName = false,
                         $proxy_params = array(), $cache = false)
    {
        parent::SOAP_Base('Client');

        $this->_endpoint = $endpoint;
        $this->_portName = $portName;
        $this->_proxy_params = $proxy_params;

        // This hack should perhaps be removed as it might cause unexpected
        // behaviour.
        $wsdl = $wsdl
            ? $wsdl
            : strtolower(substr($endpoint, -4)) == 'wsdl';

        // make values
        if ($wsdl) {
            $this->_endpointType = 'wsdl';
            // instantiate wsdl class
            $this->_wsdl = new SOAP_WSDL($this->_endpoint,
                                         $this->_proxy_params,
                                         $cache);
            if ($this->_wsdl->fault) {
                $this->_raiseSoapFault($this->_wsdl->fault);
            }
        }
    }

    function _reset()
    {
        $this->xml = null;
        $this->wire = null;
        $this->_last_request = null;
        $this->_last_response = null;
        $this->headersIn = null;
        $this->headersOut = null;
    }

    /**
     * Sets the character encoding.
     *
     * Limited to 'UTF-8', 'US_ASCII' and 'ISO-8859-1'.
     *
     * @access public
     *
     * @param string encoding
     *
     * @return mixed  SOAP_Fault on error.
     */
    function setEncoding($encoding)
    {
        if (in_array($encoding, $this->_encodings)) {
            $this->_encoding = $encoding;
            return;
        }
        return $this->_raiseSoapFault('Invalid Encoding');
    }

    /**
     * Adds a header to the envelope.
     *
     * @access public
     *
     * @param SOAP_Header $soap_value  A SOAP_Header or an array with the
     *                                 elements 'name', 'namespace',
     *                                 'mustunderstand', and 'actor' to send
     *                                 as a header.
     */
    function addHeader($soap_value)
    {
        // Add a new header to the message.
        if (is_a($soap_value, 'SOAP_Header')) {
            $this->headersOut[] = $soap_value;
        } elseif (is_array($soap_value)) {
            // name, value, namespace, mustunderstand, actor
            $this->headersOut[] = new SOAP_Header($soap_value[0],
                                                  null,
                                                  $soap_value[1],
                                                  $soap_value[2],
                                                  $soap_value[3]);
        } else {
            $this->_raiseSoapFault('Invalid parameter provided to addHeader().  Must be an array or a SOAP_Header.');
        }
    }

    /**
     * Calls a method on the SOAP endpoint.
     *
     * The namespace parameter is overloaded to accept an array of options
     * that can contain data necessary for various transports if it is used as
     * an array, it MAY contain a namespace value and a soapaction value.  If
     * it is overloaded, the soapaction parameter is ignored and MUST be
     * placed in the options array.  This is done to provide backwards
     * compatibility with current clients, but may be removed in the future.
     * The currently supported values are:
     * - 'namespace'
     * - 'soapaction'
     * - 'timeout': HTTP socket timeout
     * - 'transfer-encoding': SMTP transport, Content-Transfer-Encoding: header
     * - 'from': SMTP transport, From: header
     * - 'subject': SMTP transport, Subject: header
     * - 'headers': SMTP transport, hash of extra SMTP headers
     * - 'attachments': what encoding to use for attachments (Mime, Dime)
     * - 'trace': whether to trace the SOAP communication
     * - 'style': 'document' or 'rpc'; when set to 'document' the parameters
     *   are not wrapped inside a tag with the SOAP action name
     * - 'use': 'literal' for literal encoding, anything else for section 5
     *   encoding; when set to 'literal' SOAP types will be omitted.
     * - 'keep_arrays_flat': use the tag name multiple times for each element
     *   when passing in an array in literal mode
     * - 'no_type_prefix': supress adding of the namespace prefix
     *
     * @access public
     *
     * @param string $method           The method to call.
     * @param array $params            The method parameters.
     * @param string|array $namespace  Namespace or hash with options. Note:
     *                                 most options need to be repeated for
     *                                 SOAP_Value instances.
     * @param string $soapAction
     *
     * @return mixed  The method result or a SOAP_Fault on error.
     */
    function call($method, $params, $namespace = false, $soapAction = false)
    {
        $this->headersIn = null;
        $this->_last_request = null;
        $this->_last_response = null;
        $this->wire = null;
        $this->xml = null;

        $soap_data = $this->_generate($method, $params, $namespace, $soapAction);
        if (PEAR::isError($soap_data)) {
            $fault = $this->_raiseSoapFault($soap_data);
            return $fault;
        }

        // _generate() may have changed the endpoint if the WSDL has more
        // than one service, so we need to see if we need to generate a new
        // transport to hook to a different URI.  Since the transport protocol
        // can also change, we need to get an entirely new object.  This could
        // probably be optimized.
        if (!$this->_soap_transport ||
            $this->_endpoint != $this->_soap_transport->url) {
            $this->_soap_transport = SOAP_Transport::getTransport($this->_endpoint);
            if (PEAR::isError($this->_soap_transport)) {
                $fault = $this->_raiseSoapFault($this->_soap_transport);
                $this->_soap_transport = null;
                return $fault;
            }
        }
        $this->_soap_transport->encoding = $this->_encoding;

        // Send the message.
        $transport_options = array_merge_recursive($this->_proxy_params,
                                                   $this->_options);
        $this->xml = $this->_soap_transport->send($soap_data, $transport_options);

        // Save the wire information for debugging.
        if ($this->_options['trace']) {
            $this->_last_request = $this->_soap_transport->outgoing_payload;
            $this->_last_response = $this->_soap_transport->incoming_payload;
            $this->wire = $this->getWire();
        }
        if ($this->_soap_transport->fault) {
            $fault = $this->_raiseSoapFault($this->xml);
            return $fault;
        }

        if (isset($this->_options['result']) &&
            $this->_options['result'] != 'parse') {
            return $this->xml;
        }

        $this->__result_encoding = $this->_soap_transport->result_encoding;

        $result = $this->parseResponse($this->xml, $this->__result_encoding,
                                       $this->_soap_transport->attachments);
        return $result;
    }

    /**
     * Sets an option to use with the transport layers.
     *
     * For example:
     * <code>
     * $soapclient->setOpt('curl', CURLOPT_VERBOSE, 1)
     * </code>
     * to pass a specific option to curl if using an SSL connection.
     *
     * @access public
     *
     * @param string $category  Category to which the option applies or option
     *                          name.
     * @param string $option    An option name if $category is a category name,
     *                          an option value if $category is an option name.
     * @param string $value     An option value if $category is a category
     *                          name.
     */
    function setOpt($category, $option, $value = null)
    {
        if (!is_null($value)) {
            if (!isset($this->_options[$category])) {
                $this->_options[$category] = array();
            }
            $this->_options[$category][$option] = $value;
        } else {
            $this->_options[$category] = $option;
        }
    }

    /**
     * Call method supporting the overload extension.
     *
     * If the overload extension is loaded, you can call the client class with
     * a soap method name:
     * <code>
     * $soap = new SOAP_Client(....);
     * $value = $soap->getStockQuote('MSFT');
     * </code>
     *
     * @access public
     *
     * @param string $method        The method to call.
     * @param array $params         The method parameters.
     * @param mixed $return_value   Will get the method's return value
     *                              assigned.
     *
     * @return boolean  Always true.
     */
    function _call($method, $params, &$return_value)
    {
        // Overloading lowercases the method name, we need to look into the
        // WSDL and try to find the correct method name to get the correct
        // case for the call.
        if ($this->_wsdl) {
            $this->_wsdl->matchMethod($method);
        }

        $return_value = $this->call($method, $params);

        return true;
    }

    /**
     * Returns the XML content of the last SOAP request.
     *
     * @return string  The last request.
     */
    function getLastRequest()
    {
        return $this->_last_request;
    }

    /**
     * Returns the XML content of the last SOAP response.
     *
     * @return string  The last response.
     */
    function getLastResponse()
    {
        return $this->_last_response;
    }

    /**
     * Sets the SOAP encoding.
     *
     * The default encoding is section 5 encoded.
     *
     * @param string $use  Either 'literal' or 'encoded' (section 5).
     */
    function setUse($use)
    {
        $this->_options['use'] = $use;
    }

    /**
     * Sets the SOAP encoding style.
     *
     * The default style is rpc.
     *
     * @param string $style  Either 'document' or 'rpc'.
     */
    function setStyle($style)
    {
        $this->_options['style'] = $style;
    }

    /**
     * Sets whether to trace the traffic on the transport level.
     *
     * @see getWire()
     *
     * @param boolean $trace
     */
    function setTrace($trace)
    {
        $this->_options['trace'] = $trace;
    }

    /**
     * Generates the complete XML SOAP message for an RPC call.
     *
     * @see call()
     *
     * @param string $method           The method to call.
     * @param array $params            The method parameters.
     * @param string|array $namespace  Namespace or hash with options. Note:
     *                                 most options need to be repeated for
     *                                 SOAP_Value instances.
     * @param string $soapAction
     *
     * @return string  The SOAP message including envelope.
     */
    function _generate($method, $params, $namespace = false,
                       $soapAction = false)
    {
        $this->fault = null;
        $this->_options['input'] = 'parse';
        $this->_options['result'] = 'parse';
        $this->_options['parameters'] = false;

        if ($params && !is_array($params)) {
            $params = array($params);
        }

        if (is_array($namespace)) {
            // Options passed as a hash.
            foreach ($namespace as $optname => $opt) {
                $this->_options[strtolower($optname)] = $opt;
            }
        } else {
            // We'll place $soapAction into our array for usage in the
            // transport.
            if ($soapAction) {
                $this->_options['soapaction'] = $soapAction;
            }
            if ($namespace) {
                $this->_options['namespace'] = $namespace;
            }
        }
        if (isset($this->_options['namespace'])) {
            $namespace = $this->_options['namespace'];
        } else {
            $namespace = false;
        }

        if ($this->_endpointType == 'wsdl') {
            $this->_setSchemaVersion($this->_wsdl->xsd);

            // Get port name.
            if (!$this->_portName) {
                $this->_portName = $this->_wsdl->getPortName($method);
            }
            if (PEAR::isError($this->_portName)) {
                return $this->_raiseSoapFault($this->_portName);
            }

            // Get endpoint.
            $this->_endpoint = $this->_wsdl->getEndpoint($this->_portName);
            if (PEAR::isError($this->_endpoint)) {
                return $this->_raiseSoapFault($this->_endpoint);
            }

            // Get operation data.
            $opData = $this->_wsdl->getOperationData($this->_portName, $method);

            if (PEAR::isError($opData)) {
                return $this->_raiseSoapFault($opData);
            }
            $namespace                    = $opData['namespace'];
            $this->_options['style']      = $opData['style'];
            $this->_options['use']        = $opData['input']['use'];
            $this->_options['soapaction'] = $opData['soapAction'];

            // Set input parameters.
            if ($this->_options['input'] == 'parse') {
                $this->_options['parameters'] = $opData['parameters'];
                $nparams = array();
                if (isset($opData['input']['parts']) &&
                    count($opData['input']['parts'])) {
                    foreach ($opData['input']['parts'] as $name => $part) {
                        $xmlns = '';
                        $attrs = array();
                        // Is the name a complex type?
                        if (isset($part['element'])) {
                            $xmlns = $this->_wsdl->namespaces[$part['namespace']];
                            $part = $this->_wsdl->elements[$part['namespace']][$part['type']];
                            $name = $part['name'];
                        }
                        if (isset($params[$name]) ||
                            $this->_wsdl->getDataHandler($name, $part['namespace'])) {
                            $nparams[$name] =& $params[$name];
                        } else {
                            // We now force an associative array for
                            // parameters if using WSDL.
                            return $this->_raiseSoapFault("The named parameter $name is not in the call parameters.");
                        }
                        if (gettype($nparams[$name]) != 'object' ||
                            !is_a($nparams[$name], 'SOAP_Value')) {
                            // Type is likely a qname, split it apart, and get
                            // the type namespace from WSDL.
                            $qname = new QName($part['type']);
                            if ($qname->prefix) {
                                $type_namespace = $this->_wsdl->namespaces[$qname->prefix];
                            } elseif (isset($part['namespace'])) {
                                $type_namespace = $this->_wsdl->namespaces[$part['namespace']];
                            } else {
                                $type_namespace = null;
                            }
                            $qname->namespace = $type_namespace;
                            $pqname = $name;
                            if ($xmlns) {
                                $pqname = '{' . $xmlns . '}' . $name;
                            }
                            $nparams[$name] = new SOAP_Value($pqname,
                                                              $qname->fqn(),
                                                              $nparams[$name],
                                                              $attrs);
                        } else {
                            // WSDL fixups to the SOAP value.
                        }
                    }
                }
                $params =& $nparams;
                unset($nparams);
            }
        } else {
            $this->_setSchemaVersion(SOAP_XML_SCHEMA_VERSION);
        }

        // Serialize the message.
        $this->_section5 = (!isset($this->_options['use']) ||
                            $this->_options['use'] != 'literal');

        if (!isset($this->_options['style']) ||
            $this->_options['style'] == 'rpc') {
            $this->_options['style'] = 'rpc';
            $this->docparams = true;
            $mqname = new QName($method, $namespace);
            $methodValue = new SOAP_Value($mqname->fqn(), 'Struct', $params,
                                          array(), $this->_options);
            $soap_msg = $this->makeEnvelope($methodValue,
                                            $this->headersOut,
                                            $this->_encoding,
                                            $this->_options);
        } else {
            if (!$params) {
                $mqname = new QName($method, $namespace);
                $params = new SOAP_Value($mqname->fqn(), 'Struct', null);
            } elseif ($this->_options['input'] == 'parse') {
                if (is_array($params)) {
                    $nparams = array();
                    $keys = array_keys($params);
                    foreach ($keys as $k) {
                        if (gettype($params[$k]) != 'object') {
                            $nparams[] = new SOAP_Value($k,
                                                        false,
                                                        $params[$k]);
                        } else {
                            $nparams[] =& $params[$k];
                        }
                    }
                    $params =& $nparams;
                }
                if ($this->_options['parameters']) {
                    $mqname = new QName($method, $namespace);
                    $params = new SOAP_Value($mqname->fqn(),
                                             'Struct',
                                             $params);
                }
            }
            $soap_msg = $this->makeEnvelope($params,
                                            $this->headersOut,
                                            $this->_encoding,
                                            $this->_options);
        }
        $this->headersOut = null;

        if (PEAR::isError($soap_msg)) {
            return $this->_raiseSoapFault($soap_msg);
        }

        // Handle MIME or DIME encoding.
        // TODO: DIME encoding should move to the transport, do it here for
        // now and for ease of getting it done.
        if (count($this->_attachments)) {
            if ((isset($this->_options['attachments']) &&
                 $this->_options['attachments'] == 'Mime') ||
                isset($this->_options['Mime'])) {
                $soap_msg = $this->_makeMimeMessage($soap_msg, $this->_encoding);
            } else {
                // default is dime
                $soap_msg = $this->_makeDIMEMessage($soap_msg, $this->_encoding);
                $this->_options['headers']['Content-Type'] = 'application/dime';
            }
            if (PEAR::isError($soap_msg)) {
                return $this->_raiseSoapFault($soap_msg);
            }
        }

        // Instantiate client.
        if (is_array($soap_msg)) {
            $soap_data = $soap_msg['body'];
            if (count($soap_msg['headers'])) {
                if (isset($this->_options['headers'])) {
                    $this->_options['headers'] = array_merge($this->_options['headers'], $soap_msg['headers']);
                } else {
                    $this->_options['headers'] = $soap_msg['headers'];
                }
            }
        } else {
            $soap_data = $soap_msg;
        }

        return $soap_data;
    }

    /**
     * Parses a SOAP response.
     *
     * @see SOAP_Parser::
     *
     * @param string $response    XML content of SOAP response.
     * @param string $encoding    Character set encoding, defaults to 'UTF-8'.
     * @param array $attachments  List of attachments.
     */
    function parseResponse($response, $encoding, $attachments)
    {
        // Parse the response.
        $response = new SOAP_Parser($response, $encoding, $attachments);
        if ($response->fault) {
            $fault = $this->_raiseSoapFault($response->fault);
            return $fault;
        }

        // Return array of parameters.
        $return = $response->getResponse();
        $headers = $response->getHeaders();
        if ($headers) {
            $this->headersIn = $this->_decodeResponse($headers, false);
        }

        $decoded = $this->_decodeResponse($return);
        return $decoded;
    }

    /**
     * Converts a complex SOAP_Value into a PHP Array
     *
     * @param SOAP_Value $response  Value object.
     * @param boolean $shift
     *
     * @return array
     */
    function _decodeResponse($response, $shift = true)
    {
        if (!$response) {
            $decoded = null;
            return $decoded;
        }

        // Check for valid response.
        if (PEAR::isError($response)) {
            $fault = $this->_raiseSoapFault($response);
            return $fault;
        } elseif (!is_a($response, 'soap_value')) {
            $fault = $this->_raiseSoapFault("Didn't get SOAP_Value object back from client");
            return $fault;
        }

        // Decode to native php datatype.
        $returnArray = $this->_decode($response);

        // Fault?
        if (PEAR::isError($returnArray)) {
            $fault = $this->_raiseSoapFault($returnArray);
            return $fault;
        }

        if (is_object($returnArray) &&
            strcasecmp(get_class($returnArray), 'stdClass') == 0) {
            $returnArray = get_object_vars($returnArray);
        }

        if (is_array($returnArray)) {
            if (isset($returnArray['faultcode']) ||
                isset($returnArray[SOAP_BASE::SOAPENVPrefix().':faultcode'])) {
                $faultcode = $faultstring = $faultdetail = $faultactor = '';
                foreach ($returnArray as $k => $v) {
                    if (stristr($k, 'faultcode')) $faultcode = $v;
                    if (stristr($k, 'faultstring')) $faultstring = $v;
                    if (stristr($k, 'detail')) $faultdetail = $v;
                    if (stristr($k, 'faultactor')) $faultactor = $v;
                }
                $fault = $this->_raiseSoapFault($faultstring, $faultdetail,
                                                $faultactor, $faultcode);
                return $fault;
            }
            // Return array of return values.
            if ($shift && count($returnArray) == 1) {
                $decoded = array_shift($returnArray);
                return $decoded;
            }
            return $returnArray;
        }

        return $returnArray;
    }

    /**
     * Returns the outgoing and incoming traffic on the transport level.
     *
     * Tracing has to be enabled.
     *
     * @see setTrace()
     *
     * @return string  The complete traffic between the client and the server.
     */
    function getWire()
    {
        if ($this->_options['trace'] &&
            ($this->_last_request || $this->_last_response)) {
            return "OUTGOING:\n\n" .
                $this->_last_request .
                "\n\nINCOMING\n\n" .
                preg_replace("/></",">\r\n<", $this->_last_response);
        }

        return null;
    }

}