cvs: pear /SOAP Transport.php /SOAP/Transport SMTP.php /SOAP/test smtp.php

From: Date: Sat, 23 Feb 2002 19:57:26 +0000
Subject: cvs: pear /SOAP Transport.php /SOAP/Transport SMTP.php /SOAP/test smtp.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2575@lists.php.net to get a copy of this message
shane Sat Feb 23 14:57:26 2002 EDT Added files: /pear/SOAP/Transport SMTP.php /pear/SOAP/test smtp.php Modified files: /pear/SOAP Transport.php Log: Index: pear/SOAP/Transport.php diff -u pear/SOAP/Transport.php:1.2 pear/SOAP/Transport.php:1.3 --- pear/SOAP/Transport.php:1.2 Tue Feb 19 19:47:30 2002 +++ pear/SOAP/Transport.php Sat Feb 23 14:57:25 2002 @@ -17,9 +17,8 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Transport.php,v 1.2 2002/02/20 00:47:30 ssb Exp $ +// $Id: Transport.php,v 1.3 2002/02/23 19:57:25 shane Exp $ // -require_once("SOAP/Transport/HTTP.php"); /** * SOAP Transport Layer @@ -28,7 +27,7 @@ * no knowlege of the transport protocols is available at this level * * @access public -* @version $Id: Transport.php,v 1.2 2002/02/20 00:47:30 ssb Exp $ +* @version $Id: Transport.php,v 1.3 2002/02/23 19:57:25 shane Exp $ * @package SOAP::Transport * @author Shane Caraveo <shane@php.net> */ @@ -52,7 +51,12 @@ $this->debug_flag = $debug; $urlparts = @parse_url($url); if (strcasecmp($urlparts['scheme'],"http")==0) { + require_once("SOAP/Transport/HTTP.php"); $this->transport = new SOAP_Transport_HTTP($url); + return; + } else if (strcasecmp($urlparts['scheme'],"mailto")==0) { + require_once("SOAP/Transport/SMTP.php"); + $this->transport = new SOAP_Transport_SMTP($url); return; } $this->errmsg = "No Transport for {$urlparts['scheme']}"; Index: pear/SOAP/Transport/SMTP.php +++ pear/SOAP/Transport/SMTP.php <?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> | // +----------------------------------------------------------------------+ // // $Id: SMTP.php,v 1.1 2002/02/23 19:57:26 shane Exp $ // // Status: rough draft, untested // // TODO: // switch to pear mail stuff // smtp authentication // smtp ssl support // ability to define smtp options (encoding, from, etc.) // require_once("SOAP/globals.php"); # we have to use the message class to return a proper soap response require_once("SOAP/Message.php"); /** * SMTP Transport for SOAP * * @access public * @version $Id: SMTP.php,v 1.1 2002/02/23 19:57:26 shane Exp $ * @package SOAP::Transport::SMTP * @author Shane Caraveo <shane@php.net> */ class SOAP_Transport_SMTP { var $credentials = ""; var $_userAgent; var $timeout = 4; // connect timeout var $errno = 0; var $errmsg = ""; var $urlparts = NULL; var $url = ""; var $incoming_payload = ""; /** * SOAP_Transport_SMTP Constructor * * @param string $URL mailto:address * * @access public */ function SOAP_Transport_SMTP($URL) { global $SOAP_LibraryName; $this->urlparts = @parse_url($URL); $this->url = $URL; $this->_userAgent = $SOAP_LibraryName; } /** * send and receive soap data * * @param string &$msg outgoing post data * @param string &$response response data, minus http headers * @param string $action SOAP Action header data * @param int $timeout socket timeout, default 0 or off * * @return boolean (success or failure) * @access public */ function send(&$msg, &$response, $action = "", $timeout=0) { if (!$this->_validateUrl()) { return FALSE; } $headers = "From: $action\n". "X-Mailer: $this->_userAgent\n". "MIME-Version: 1.0\n". "Content-Type: text/xml; charset=\"utf-8\"\n". "Content-Transfer-Encoding: quoted-printable\n"; $subject = "SOAP Message"; # we want to return a proper XML message $result = mail($this->urlparts['path'], $subject, $msg, $headers); if ($result) { $val = new SOAP_Value("return","boolean",TRUE); } else { $val = new SOAP_Value("Fault","struct",array( new SOAP_Value("faultcode","string","SOAP-ENV:Transport"), new SOAP_Value("faultstring","string","couldn't send message to $action") )); } $return_msg = new SOAP_Message("Response",array($val),"smtp"); $response = $return_msg->serialize(); return $result; } /** * set data for http authentication * creates Authorization header * * @param string $username username * @param string $password response data, minus http headers * * @return none * @access public */ function setCredentials($username, $password) { $this->username = $username; $this->password = $password; } // private members /** * validate url data passed to constructor * * @return boolean * @access private */ function _validateUrl() { if ( ! is_array($this->urlparts) ) { $this->errno=2; $this->errmsg="Unable to parse URL $url"; return FALSE; } if (!isset($this->urlparts['scheme']) || strcasecmp($this->urlparts['scheme'], 'mailto') != 0) { return FALSE; } if (!isset($this->urlparts['path'])) { return FALSE; } return TRUE; } }; // end SOAP_Transport_HTTP ?> Index: pear/SOAP/test/smtp.php +++ pear/SOAP/test/smtp.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> | // +----------------------------------------------------------------------+ // // $Id: smtp.php,v 1.1 2002/02/23 19:57:26 shane Exp $ // // include soap client class include("SOAP/Client.php"); $soapclient = new SOAP_Client("mailto:shane@caraveo.com"); $return = $soapclient->call("getQuote",array("symbol"=>"ibm"), "", "shane@caraveo.com"); print_r($return); unset($soapclient); ?>

« previous php.pear.cvs (#2575) next »