File indexing completed on 2024-06-16 05:30:28

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Soap
0017  * @subpackage Client
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /** Zend_Soap_Server */
0024 // require_once 'Zend/Soap/Server.php';
0025 
0026 /** Zend_Soap_Client */
0027 // require_once 'Zend/Soap/Client.php';
0028 
0029 if (extension_loaded('soap')) {
0030 
0031 /**
0032  * Zend_Soap_Client_Local
0033  *
0034  * Class is intended to be used as local SOAP client which works
0035  * with a provided Server object.
0036  *
0037  * Could be used for development or testing purposes.
0038  *
0039  * @category   Zend
0040  * @package    Zend_Soap
0041  * @subpackage Client
0042  */
0043 class Zend_Soap_Client_Local extends Zend_Soap_Client
0044 {
0045     /**
0046      * Server object
0047      *
0048      * @var Zend_Soap_Server
0049      */
0050     protected $_server;
0051 
0052     /**
0053      * Local client constructor
0054      *
0055      * @param Zend_Soap_Server $server
0056      * @param string $wsdl
0057      * @param array $options
0058      */
0059     function __construct(Zend_Soap_Server $server, $wsdl, $options = null)
0060     {
0061         $this->_server = $server;
0062 
0063         // Use Server specified SOAP version as default
0064         $this->setSoapVersion($server->getSoapVersion());
0065 
0066         parent::__construct($wsdl, $options);
0067     }
0068 
0069     /**
0070      * Actual "do request" method.
0071      *
0072      * @internal
0073      * @param Zend_Soap_Client_Common $client
0074      * @param string $request
0075      * @param string $location
0076      * @param string $action
0077      * @param int    $version
0078      * @param int    $one_way
0079      * @return mixed
0080      */
0081     public function _doRequest(Zend_Soap_Client_Common $client, $request, $location, $action, $version, $one_way = null)
0082     {
0083         // Perform request as is
0084         ob_start();
0085         $this->_server->handle($request);
0086         $response = ob_get_clean();
0087  
0088         if ($response === null || $response === '') {
0089             $serverResponse = $this->server->getResponse();
0090             if ($serverResponse !== null) {
0091                 $response = $serverResponse;
0092             }
0093         }
0094 
0095         return $response;
0096     }
0097 }
0098 
0099 } // end if (extension_loaded('soap')