/
Transport.php
147 lines (132 loc) · 3.64 KB
/
Transport.php
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
<?php
/**
* This file contains the code for an abstract transport layer.
*
* 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>
* @author Shane Caraveo <Shane@Caraveo.com>
* @author Jan Schneider <jan@horde.org>
* @copyright 2003-2006 The PHP Group
* @license http://www.php.net/license/2_02.txt PHP License 2.02
* @link http://pear.php.net/package/SOAP
*/
require_once 'SOAP/Base.php';
/**
* SOAP Transport Layer
*
* This layer can use different protocols dependant on the endpoint url
* provided.
*
* No knowlege of the SOAP protocol is available at this level.
* No knowlege of the transport protocols is available at this level.
*
* @access public
* @package SOAP
* @author Shane Caraveo <shane@php.net>
* @author Jan Schneider <jan@horde.org>
*/
class SOAP_Transport extends SOAP_Base
{
/**
* Connection endpoint URL.
*
* @var string
*/
var $url = '';
/**
* Array containing urlparts.
*
* @see parse_url()
*
* @var mixed
*/
var $urlparts = null;
/**
* Incoming payload.
*
* @var string
*/
var $incoming_payload = '';
/**
* Outgoing payload.
*
* @var string
*/
var $outgoing_payload = '';
/**
* Request encoding.
*
* @var string
*/
var $encoding = SOAP_DEFAULT_ENCODING;
/**
* Response encoding.
*
* We assume UTF-8 if no encoding is set.
*
* @var string
*/
var $result_encoding = 'UTF-8';
/**
* Decoded attachments from the reponse.
*
* @var array
*/
var $attachments;
/**
* Request User-Agent.
*
* @var string
*/
var $_userAgent = SOAP_LIBRARY_NAME;
/**
* Sends and receives SOAP data.
*
* @access public
* @abstract
*
* @param string Outgoing SOAP data.
* @param array Options.
*
* @return string|SOAP_Fault
*/
function send($msg, $options = null)
{
return $this->_raiseSoapFault('SOAP_Transport::send() not implemented.');
}
function getTransport($url, $encoding = SOAP_DEFAULT_ENCODING)
{
$urlparts = @parse_url($url);
if (!$urlparts['scheme']) {
return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url");
}
if (strcasecmp($urlparts['scheme'], 'mailto') == 0) {
$transport_type = 'SMTP';
} elseif (strcasecmp($urlparts['scheme'], 'https') == 0) {
$transport_type = 'HTTP';
} else {
/* Handle other transport types */
$transport_type = strtoupper($urlparts['scheme']);
}
$transport_class = "SOAP_Transport_$transport_type";
if (!class_exists($transport_class)) {
if (!(@include_once('SOAP/Transport/' . basename($transport_type) . '.php'))) {
return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}");
}
}
if (!class_exists($transport_class)) {
return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class");
}
return new $transport_class($url, $encoding);
}
}