Transport.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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,v 1.22 2003/04/20 01:05:34 shane Exp $
  21. //
  22. require_once 'SOAP/Base.php';
  23. /**
  24. * SOAP Transport Layer
  25. *
  26. * This layer can use different protocols dependant on the endpoint url provided
  27. * no knowlege of the SOAP protocol is available at this level
  28. * no knowlege of the transport protocols is available at this level
  29. *
  30. * @access public
  31. * @version $Id: Transport.php,v 1.22 2003/04/20 01:05:34 shane Exp $
  32. * @package SOAP::Transport
  33. * @author Shane Caraveo <shane@php.net>
  34. */
  35. class SOAP_Transport
  36. {
  37. function &getTransport($url, $encoding = SOAP_DEFAULT_ENCODING)
  38. {
  39. $urlparts = @parse_url($url);
  40. if (!$urlparts['scheme']) {
  41. return SOAP_Base_Object::_raiseSoapFault("Invalid transport URI: $url");
  42. }
  43. if (strcasecmp($urlparts['scheme'], 'mailto') == 0) {
  44. $transport_type = 'SMTP';
  45. } else if (strcasecmp($urlparts['scheme'], 'https') == 0) {
  46. $transport_type = 'HTTP';
  47. } else {
  48. /* handle other transport types */
  49. $transport_type = strtoupper($urlparts['scheme']);
  50. }
  51. $transport_include = 'SOAP/Transport/'.$transport_type.'.php';
  52. $res = @include_once($transport_include);
  53. if(!$res && !in_array($transport_include, get_included_files())) {
  54. return SOAP_Base_Object::_raiseSoapFault("No Transport for {$urlparts['scheme']}");
  55. }
  56. $transport_class = "SOAP_Transport_$transport_type";
  57. if (!class_exists($transport_class)) {
  58. return SOAP_Base_Object::_raiseSoapFault("No Transport class $transport_class");
  59. }
  60. return new $transport_class($url, $encoding);
  61. }
  62. } // end SOAP_Transport
  63. ?>