Transport.php
4.12 KB
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
<?php
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | 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. |
// +----------------------------------------------------------------------+
// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more |
// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author |
// +----------------------------------------------------------------------+
//
// $Id: Transport.php,v 1.1.1.2 2006/06/08 14:56:39 06292871800 Exp $
//
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
* @version $Id: Transport.php,v 1.1.1.2 2006/06/08 14:56:39 06292871800 Exp $
* @package SOAP::Transport
* @author Shane Caraveo <shane@php.net>
*/
class SOAP_Transport extends SOAP_Base
{
/**
* Transport object - build using the constructor as a factory
*
* @var object SOAP_Transport_SMTP|HTTP
*/
var $transport = NULL;
/**
* Error message
*
* Used to communicate between SOAP_Transport() and send()
*
* @var string
*/
var $errmsg = '';
/**
* SOAP::Transport constructor
*
* @param string $url soap endpoint url
*
* @access public
*/
function SOAP_Transport($url, $debug = SOAP_DEBUG)
{
parent::SOAP_Base('TRANSPORT');
/* only HTTP transport for now, later look at url for scheme */
$this->debug_flag = $debug;
$urlparts = @parse_url($url);
if (strcasecmp($urlparts['scheme'], 'http') == 0 || strcasecmp($urlparts['scheme'], 'http') == 0) {
include_once('SOAP/Transport/HTTP.php');
$this->transport = new SOAP_Transport_HTTP($url);
return;
} else if (strcasecmp($urlparts['scheme'], 'mailto') == 0) {
include_once('SOAP/Transport/SMTP.php');
$this->transport = new SOAP_Transport_SMTP($url);
return;
}
$this->errmsg = "No Transport for {$urlparts['scheme']}";
$this->raiseSoapFault($this->errmsg);
}
/**
* send a soap package, get a soap response
*
* @param string &$soap_data soap data to be sent (in xml)
* @param string $action SOAP Action
* @param int $timeout protocol timeout in seconds
*
* @return string &$response soap response (in xml)
* @access public
*/
function &send(&$soap_data, $action = '', $timeout = 0)
{
if (!$this->transport) {
return $this->raiseSoapFault($this->errmsg);
}
$response = $this->transport->send($soap_data, $action, $timeout);
if (PEAR::isError($response)) {
return $this->raiseSoapFault($response);
}
$this->debug("OUTGOING: ".$this->transport->outgoing_payload);
$this->debug("INCOMING: ".$this->transport->incoming_payload);
#echo "\n OUTGOING: ".$this->transport->outgoing_payload."\n\n";
#echo "\n INCOMING: ".preg_replace("/>/",">\n",$this->transport->incoming_payload)."\n\n";
return $response;
}
} // end SOAP_Transport
?>