Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/**
3
 * This file contains the code for an abstract transport layer.
4
 *
5
 * PHP versions 4 and 5
6
 *
7
 * LICENSE: This source file is subject to version 2.02 of the PHP license,
8
 * that is bundled with this package in the file LICENSE, and is available at
9
 * through the world-wide-web at http://www.php.net/license/2_02.txt.  If you
10
 * did not receive a copy of the PHP license and are unable to obtain it
11
 * through the world-wide-web, please send a note to license@php.net so we can
12
 * mail you a copy immediately.
13
 *
14
 * @category   Web Services
15
 * @package    SOAP
16
 * @author     Dietrich Ayala <dietrich@ganx4.com>
17
 * @author     Shane Caraveo <Shane@Caraveo.com>
18
 * @author     Jan Schneider <jan@horde.org>
19
 * @copyright  2003-2006 The PHP Group
20
 * @license    http://www.php.net/license/2_02.txt  PHP License 2.02
21
 * @link       http://pear.php.net/package/SOAP
22
 */
23
 
24
require_once 'SOAP/Base.php';
25
 
26
/**
27
 * SOAP Transport Layer
28
 *
29
 * This layer can use different protocols dependant on the endpoint url
30
 * provided.
31
 *
32
 * No knowlege of the SOAP protocol is available at this level.
33
 * No knowlege of the transport protocols is available at this level.
34
 *
35
 * @access   public
36
 * @package  SOAP
37
 * @author   Shane Caraveo <shane@php.net>
38
 * @author   Jan Schneider <jan@horde.org>
39
 */
40
class SOAP_Transport extends SOAP_Base
41
{
42
    /**
43
     * Connection endpoint URL.
44
     *
45
     * @var string
46
     */
47
    var $url = '';
48
 
49
    /**
50
     * Array containing urlparts.
51
     *
52
     * @see parse_url()
53
     *
54
     * @var mixed
55
     */
56
    var $urlparts = null;
57
 
58
    /**
59
     * Incoming payload.
60
     *
61
     * @var string
62
     */
63
    var $incoming_payload = '';
64
 
65
    /**
66
     * Outgoing payload.
67
     *
68
     * @var string
69
     */
70
    var $outgoing_payload = '';
71
 
72
    /**
73
     * Request encoding.
74
     *
75
     * @var string
76
     */
77
    var $encoding = SOAP_DEFAULT_ENCODING;
78
 
79
    /**
80
     * Response encoding.
81
     *
82
     * We assume UTF-8 if no encoding is set.
83
     *
84
     * @var string
85
     */
86
    var $result_encoding = 'UTF-8';
87
 
88
    /**
89
     * Decoded attachments from the reponse.
90
     *
91
     * @var array
92
     */
93
    var $attachments;
94
 
95
    /**
96
     * Request User-Agent.
97
     *
98
     * @var string
99
     */
100
    var $_userAgent = SOAP_LIBRARY_NAME;
101
 
102
    /**
103
     * Sends and receives SOAP data.
104
     *
105
     * @access public
106
     * @abstract
107
     *
108
     * @param string  Outgoing SOAP data.
109
     * @param array   Options.
110
     *
111
     * @return string|SOAP_Fault
112
     */
113
    function send($msg, $options = null)
114
    {
115
        return $this->_raiseSoapFault('SOAP_Transport::send() not implemented.');
116
    }
117
 
118
    function getTransport($url, $encoding = SOAP_DEFAULT_ENCODING)
119
    {
120
        $urlparts = @parse_url($url);
121
 
122
        if (!$urlparts['scheme']) {
123
            return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url");
124
        }
125
 
126
        if (strcasecmp($urlparts['scheme'], 'mailto') == 0) {
127
            $transport_type = 'SMTP';
128
        } elseif (strcasecmp($urlparts['scheme'], 'https') == 0) {
129
            $transport_type = 'HTTP';
130
        } else {
131
            /* Handle other transport types */
132
            $transport_type = strtoupper($urlparts['scheme']);
133
        }
134
        $transport_class = "SOAP_Transport_$transport_type";
135
        if (!class_exists($transport_class)) {
136
            if (!(@include_once('SOAP/Transport/' . basename($transport_type) . '.php'))) {
137
                return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}");
138
            }
139
        }
140
        if (!class_exists($transport_class)) {
141
            return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class");
142
        }
143
 
144
        return new $transport_class($url, $encoding);
145
    }
146
 
147
}