| 1 |
lars |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// +----------------------------------------------------------------------+
|
|
|
4 |
// | PHP Version 4 |
|
|
|
5 |
// +----------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (c) 1997-2003 The PHP Group |
|
|
|
7 |
// +----------------------------------------------------------------------+
|
|
|
8 |
// | This source file is subject to version 2.02 of the PHP license, |
|
|
|
9 |
// | that is bundled with this package in the file LICENSE, and is |
|
|
|
10 |
// | available at through the world-wide-web at |
|
|
|
11 |
// | http://www.php.net/license/2_02.txt. |
|
|
|
12 |
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
13 |
// | obtain it through the world-wide-web, please send a note to |
|
|
|
14 |
// | license@php.net so we can mail you a copy immediately. |
|
|
|
15 |
// +----------------------------------------------------------------------+
|
|
|
16 |
// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more |
|
|
|
17 |
// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author |
|
|
|
18 |
// +----------------------------------------------------------------------+
|
|
|
19 |
//
|
|
|
20 |
// $Id: Transport.php 696 2011-09-08 09:08:23Z tiefland $
|
|
|
21 |
//
|
|
|
22 |
|
|
|
23 |
require_once 'PayPal/SOAP/Base.php';
|
|
|
24 |
|
|
|
25 |
/**
|
|
|
26 |
* SOAP Transport Layer
|
|
|
27 |
*
|
|
|
28 |
* This layer can use different protocols dependant on the endpoint url provided
|
|
|
29 |
* no knowlege of the SOAP protocol is available at this level
|
|
|
30 |
* no knowlege of the transport protocols is available at this level
|
|
|
31 |
*
|
|
|
32 |
* @access public
|
|
|
33 |
* @package SOAP::Transport
|
|
|
34 |
* @author Shane Caraveo <shane@php.net>
|
|
|
35 |
*/
|
|
|
36 |
class SOAP_Transport
|
|
|
37 |
{
|
|
|
38 |
function &getTransport($url, $encoding = SOAP_DEFAULT_ENCODING)
|
|
|
39 |
{
|
|
|
40 |
$urlparts = @parse_url($url);
|
|
|
41 |
|
|
|
42 |
if (!$urlparts['scheme']) {
|
|
|
43 |
return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url");
|
|
|
44 |
}
|
|
|
45 |
|
|
|
46 |
if (strcasecmp($urlparts['scheme'], 'mailto') == 0) {
|
|
|
47 |
$transport_type = 'SMTP';
|
|
|
48 |
} elseif (strcasecmp($urlparts['scheme'], 'https') == 0) {
|
|
|
49 |
$transport_type = 'HTTP';
|
|
|
50 |
} else {
|
|
|
51 |
/* handle other transport types */
|
|
|
52 |
$transport_type = strtoupper($urlparts['scheme']);
|
|
|
53 |
}
|
|
|
54 |
$transport_include = 'PayPal/SOAP/Transport/' . $transport_type . '.php';
|
|
|
55 |
$res = @include_once($transport_include);
|
|
|
56 |
if (!$res && !in_array($transport_include, get_included_files())) {
|
|
|
57 |
return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}");
|
|
|
58 |
}
|
|
|
59 |
$transport_class = "SOAP_Transport_$transport_type";
|
|
|
60 |
if (!class_exists($transport_class)) {
|
|
|
61 |
return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class");
|
|
|
62 |
}
|
|
|
63 |
$t =& new $transport_class($url, $encoding);
|
|
|
64 |
return $t;
|
|
|
65 |
}
|
|
|
66 |
|
|
|
67 |
}
|