import v1.1.0_beta1 | 2009-08-21
This commit is contained in:
@ -14,15 +14,15 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage AutoDiscover
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: AutoDiscover.php 12355 2008-11-07 08:20:41Z beberlei $
|
||||
* @version $Id: AutoDiscover.php 14918 2009-04-15 16:07:53Z beberlei $
|
||||
*/
|
||||
|
||||
require_once 'Zend/Server/Interface.php';
|
||||
require_once 'Zend/Soap/Wsdl.php';
|
||||
require_once 'Zend/Server/Reflection.php';
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
require_once 'Zend/Server/Abstract.php';
|
||||
require_once 'Zend/Uri.php';
|
||||
|
||||
@ -31,27 +31,28 @@ require_once 'Zend/Uri.php';
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage AutoDiscover
|
||||
*/
|
||||
class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
/**
|
||||
* @var Zend_Soap_Wsdl
|
||||
*/
|
||||
private $_wsdl = null;
|
||||
protected $_wsdl = null;
|
||||
|
||||
/**
|
||||
* @var Zend_Server_Reflection
|
||||
*/
|
||||
private $_reflection = null;
|
||||
protected $_reflection = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $_functions = array();
|
||||
protected $_functions = array();
|
||||
|
||||
/**
|
||||
* @var boolean
|
||||
*/
|
||||
private $_strategy;
|
||||
protected $_strategy;
|
||||
|
||||
/**
|
||||
* Url where the WSDL file will be available at.
|
||||
@ -60,6 +61,20 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
*/
|
||||
protected $_uri;
|
||||
|
||||
/**
|
||||
* soap:body operation style options
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_operationBodyStyle = array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/");
|
||||
|
||||
/**
|
||||
* soap:operation style
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -86,9 +101,7 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
if(is_string($uri)) {
|
||||
$uri = Zend_Uri::factory($uri);
|
||||
} else if(!($uri instanceof Zend_Uri)) {
|
||||
if(!is_string($uri) && !($uri instanceof Zend_Uri)) {
|
||||
require_once "Zend/Soap/AutoDiscover/Exception.php";
|
||||
throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance.");
|
||||
}
|
||||
@ -109,7 +122,7 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
if($this->_uri instanceof Zend_Uri) {
|
||||
if($this->_uri !== null) {
|
||||
$uri = $this->_uri;
|
||||
} else {
|
||||
$schema = $this->getSchema();
|
||||
@ -121,6 +134,45 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options for all the binding operations soap:body elements.
|
||||
*
|
||||
* By default the options are set to 'use' => 'encoded' and
|
||||
* 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/".
|
||||
*
|
||||
* @see Zend_Soap_AutoDiscover_Exception
|
||||
* @param array $operationStyle
|
||||
* @return Zend_Soap_AutoDiscover
|
||||
*/
|
||||
public function setOperationBodyStyle(array $operationStyle=array())
|
||||
{
|
||||
if(!isset($operationStyle['use'])) {
|
||||
require_once "Zend/Soap/AutoDiscover/Exception.php";
|
||||
throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style.");
|
||||
}
|
||||
$this->_operationBodyStyle = $operationStyle;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Binding soap:binding style.
|
||||
*
|
||||
* By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'.
|
||||
*
|
||||
* @param array $bindingStyle
|
||||
* @return Zend_Soap_AutoDiscover
|
||||
*/
|
||||
public function setBindingStyle(array $bindingStyle=array())
|
||||
{
|
||||
if(isset($bindingStyle['style'])) {
|
||||
$this->_bindingStyle['style'] = $bindingStyle['style'];
|
||||
}
|
||||
if(isset($bindingStyle['transport'])) {
|
||||
$this->_bindingStyle['transport'] = $bindingStyle['transport'];
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect and returns the current HTTP/HTTPS Schema
|
||||
*
|
||||
@ -205,7 +257,7 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
$port = $wsdl->addPortType($class . 'Port');
|
||||
$binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port');
|
||||
|
||||
$wsdl->addSoapBinding($binding, 'rpc');
|
||||
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
|
||||
$wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri);
|
||||
foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) {
|
||||
/* <wsdl:portType>'s */
|
||||
@ -240,12 +292,13 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
//$wsdl->addDocumentation($message, $desc);
|
||||
}
|
||||
if ($prototype->getReturnType() != "void") {
|
||||
$message = $wsdl->addMessage($method->getName() . 'Response', array($method->getName() . 'Return' => $wsdl->getType($prototype->getReturnType())));
|
||||
$returnName = 'return';
|
||||
$message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType())));
|
||||
}
|
||||
|
||||
/* <wsdl:binding>'s */
|
||||
$operation = $wsdl->addBindingOperation($binding, $method->getName(), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"));
|
||||
$wsdl->addSoapOperation($operation, $uri->getUri() . '#' .$method->getName());
|
||||
$operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
|
||||
$wsdl->addSoapOperation($operation, $uri . '#' .$method->getName());
|
||||
/* </wsdl:binding>'s */
|
||||
}
|
||||
}
|
||||
@ -278,7 +331,7 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
$port = $wsdl->addPortType($name . 'Port');
|
||||
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port');
|
||||
|
||||
$wsdl->addSoapBinding($binding, 'rpc');
|
||||
$wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
|
||||
$wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
|
||||
} else {
|
||||
$wsdl = $this->_wsdl;
|
||||
@ -296,8 +349,9 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
if (strlen($desc) > 0) {
|
||||
//$wsdl->addDocumentation($message, $desc);
|
||||
}
|
||||
if ($prototype->getReturnType() != "void") {
|
||||
$message = $wsdl->addMessage($method->getName() . 'Response', array($method->getName() . 'Return' => $wsdl->getType($prototype->getReturnType())));
|
||||
if($prototype->getReturnType() != "void") {
|
||||
$returnName = "return";
|
||||
$message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType())));
|
||||
}
|
||||
/* <wsdl:portType>'s */
|
||||
$portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response');
|
||||
@ -307,8 +361,8 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
/* </wsdl:portType>'s */
|
||||
|
||||
/* <wsdl:binding>'s */
|
||||
$operation = $wsdl->addBindingOperation($binding, $method->getName(), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"), array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/"));
|
||||
$wsdl->addSoapOperation($operation, $uri->getUri() . '#' .$method->getName());
|
||||
$operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
|
||||
$wsdl->addSoapOperation($operation, $uri . '#' .$method->getName());
|
||||
/* </wsdl:binding>'s */
|
||||
|
||||
$this->_functions[] = $method->getName();
|
||||
@ -345,6 +399,40 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
$this->_wsdl->dump();
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy to WSDL dump function
|
||||
*
|
||||
* @param string $filename
|
||||
*/
|
||||
public function dump($filename)
|
||||
{
|
||||
if($this->_wsdl !== null) {
|
||||
return $this->_wsdl->dump($filename);
|
||||
} else {
|
||||
/**
|
||||
* @see Zend_Soap_AutoDiscover_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/AutoDiscover/Exception.php";
|
||||
throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Proxy to WSDL toXml() function
|
||||
*/
|
||||
public function toXml()
|
||||
{
|
||||
if($this->_wsdl !== null) {
|
||||
return $this->_wsdl->toXml();
|
||||
} else {
|
||||
/**
|
||||
* @see Zend_Soap_AutoDiscover_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/AutoDiscover/Exception.php";
|
||||
throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of functions in the WSDL
|
||||
*
|
||||
@ -395,4 +483,3 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,17 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage AutoDiscover
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
require_once "Zend/Exception.php";
|
||||
|
||||
class Zend_Soap_AutoDiscover_Exception extends Zend_Exception {}
|
||||
/**
|
||||
* @package Zend_Soap
|
||||
* @subpackage AutoDiscover
|
||||
*/
|
||||
class Zend_Soap_AutoDiscover_Exception extends Zend_Exception
|
||||
{
|
||||
}
|
@ -14,13 +14,11 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Soap_Client_Exception */
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
|
||||
/** Zend_Soap_Server */
|
||||
require_once 'Zend/Soap/Server.php';
|
||||
|
||||
@ -30,12 +28,12 @@ require_once 'Zend/Soap/Client/Local.php';
|
||||
/** Zend_Soap_Client_Common */
|
||||
require_once 'Zend/Soap/Client/Common.php';
|
||||
|
||||
|
||||
/**
|
||||
* Zend_Soap_Client
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -80,6 +78,9 @@ class Zend_Soap_Client
|
||||
protected $_passphrase = null;
|
||||
protected $_compression = null;
|
||||
protected $_connection_timeout = null;
|
||||
protected $_stream_context = null;
|
||||
protected $_features = null;
|
||||
protected $_cache_wsdl = null;
|
||||
|
||||
/**
|
||||
* WSDL used to access server
|
||||
@ -103,6 +104,33 @@ class Zend_Soap_Client
|
||||
*/
|
||||
protected $_lastMethod = '';
|
||||
|
||||
/**
|
||||
* SOAP request headers.
|
||||
*
|
||||
* Array of SoapHeader objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_soapInputHeaders = array();
|
||||
|
||||
/**
|
||||
* Permanent SOAP request headers (shared between requests).
|
||||
*
|
||||
* Array of SoapHeader objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_permanentSoapInputHeaders = array();
|
||||
|
||||
/**
|
||||
* Output SOAP headers.
|
||||
*
|
||||
* Array of SoapHeader objects
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_soapOutputHeaders = array();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@ -112,6 +140,7 @@ class Zend_Soap_Client
|
||||
public function __construct($wsdl = null, $options = null)
|
||||
{
|
||||
if (!extension_loaded('soap')) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('SOAP extension is not loaded.');
|
||||
}
|
||||
|
||||
@ -152,12 +181,16 @@ class Zend_Soap_Client
|
||||
*
|
||||
* Allows setting options as an associative array of option => value pairs.
|
||||
*
|
||||
* @param array $options
|
||||
* @param array|Zend_Config $options
|
||||
* @return Zend_Soap_Client
|
||||
* @throws Zend_SoapClient_Exception
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
public function setOptions($options)
|
||||
{
|
||||
if($options instanceof Zend_Config) {
|
||||
$options = $options->toArray();
|
||||
}
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'classmap':
|
||||
@ -213,6 +246,15 @@ class Zend_Soap_Client
|
||||
case 'compression':
|
||||
$this->setCompressionOptions($value);
|
||||
break;
|
||||
case 'stream_context':
|
||||
$this->setStreamContext($value);
|
||||
break;
|
||||
case 'features':
|
||||
$this->setSoapFeatures($value);
|
||||
break;
|
||||
case 'cache_wsdl':
|
||||
$this->setWsdlCache($value);
|
||||
break;
|
||||
|
||||
// Not used now
|
||||
// case 'connection_timeout':
|
||||
@ -220,6 +262,7 @@ class Zend_Soap_Client
|
||||
// break;
|
||||
|
||||
default:
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Unknown SOAP client option');
|
||||
break;
|
||||
}
|
||||
@ -254,7 +297,10 @@ class Zend_Soap_Client
|
||||
$options['local_cert'] = $this->getHttpsCertificate();
|
||||
$options['passphrase'] = $this->getHttpsCertPassphrase();
|
||||
$options['compression'] = $this->getCompressionOptions();
|
||||
// $options['connection_timeout'] = $this->_connection_timeout;
|
||||
//$options['connection_timeout'] = $this->_connection_timeout;
|
||||
$options['stream_context'] = $this->getStreamContext();
|
||||
$options['cache_wsdl'] = $this->getWsdlCache();
|
||||
$options['features'] = $this->getSoapFeatures();
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
if ($value == null) {
|
||||
@ -275,6 +321,7 @@ class Zend_Soap_Client
|
||||
public function setSoapVersion($version)
|
||||
{
|
||||
if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid soap version specified. Use SOAP_1_1 or SOAP_1_2 constants.');
|
||||
}
|
||||
$this->_soapVersion = $version;
|
||||
@ -305,6 +352,7 @@ class Zend_Soap_Client
|
||||
{
|
||||
foreach ($classmap as $type => $class) {
|
||||
if (!class_exists($class)) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid class in class map');
|
||||
}
|
||||
}
|
||||
@ -336,6 +384,7 @@ class Zend_Soap_Client
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (!is_string($encoding)) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid encoding specified');
|
||||
}
|
||||
|
||||
@ -370,6 +419,7 @@ class Zend_Soap_Client
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid URN');
|
||||
}
|
||||
|
||||
@ -441,6 +491,7 @@ class Zend_Soap_Client
|
||||
public function setStyle($style)
|
||||
{
|
||||
if (!in_array($style, array(SOAP_RPC, SOAP_DOCUMENT))) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid request style specified. Use SOAP_RPC or SOAP_DOCUMENT constants.');
|
||||
}
|
||||
|
||||
@ -471,6 +522,7 @@ class Zend_Soap_Client
|
||||
public function setEncodingMethod($use)
|
||||
{
|
||||
if (!in_array($use, array(SOAP_ENCODED, SOAP_LITERAL))) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid message encoding method. Use SOAP_ENCODED or SOAP_LITERAL constants.');
|
||||
}
|
||||
|
||||
@ -641,6 +693,7 @@ class Zend_Soap_Client
|
||||
public function setHttpsCertificate($localCert)
|
||||
{
|
||||
if (!is_readable($localCert)) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('Invalid HTTPS client certificate path.');
|
||||
}
|
||||
|
||||
@ -721,6 +774,79 @@ class Zend_Soap_Client
|
||||
return $this->_proxy_password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Stream Context
|
||||
*
|
||||
* @return Zend_Soap_Client
|
||||
*/
|
||||
public function setStreamContext($context)
|
||||
{
|
||||
if(!is_resource($context) || get_resource_type($context) !== "stream-context") {
|
||||
/**
|
||||
* @see Zend_Soap_Client_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/Client/Exception.php";
|
||||
throw new Zend_Soap_Client_Exception(
|
||||
"Invalid stream context resource given."
|
||||
);
|
||||
}
|
||||
|
||||
$this->_stream_context = $context;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Stream Context
|
||||
*
|
||||
* @return resource
|
||||
*/
|
||||
public function getStreamContext()
|
||||
{
|
||||
return $this->_stream_context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SOAP Feature options.
|
||||
*
|
||||
* @param string|int $feature
|
||||
* @return Zend_Soap_Client
|
||||
*/
|
||||
public function setSoapFeatures($feature)
|
||||
{
|
||||
$this->_features = $feature;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current SOAP Features options
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSoapFeatures()
|
||||
{
|
||||
return $this->_features;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SOAP Wsdl Caching Options
|
||||
*
|
||||
* @param string|int|boolean $caching
|
||||
* @return Zend_Soap_Client
|
||||
*/
|
||||
public function setWsdlCache($options)
|
||||
{
|
||||
$this->_cache_wsdl = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current SOAP Wsdl Caching option
|
||||
*/
|
||||
public function getWsdlCache()
|
||||
{
|
||||
return $this->_cache_wsdl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve request XML
|
||||
*
|
||||
@ -764,7 +890,7 @@ class Zend_Soap_Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve response headers
|
||||
* Retrieve response headers (as string)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -821,19 +947,22 @@ class Zend_Soap_Client
|
||||
$wsdl = $this->getWsdl();
|
||||
$options = array_merge($this->getOptions(), array('trace' => true));
|
||||
|
||||
|
||||
if ($wsdl == null) {
|
||||
if (!isset($options['location'])) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'location\' parameter is required in non-WSDL mode.');
|
||||
}
|
||||
if (!isset($options['uri'])) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'uri\' parameter is required in non-WSDL mode.');
|
||||
}
|
||||
} else {
|
||||
if (isset($options['use'])) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'use\' parameter only works in non-WSDL mode.');
|
||||
}
|
||||
if (isset($options['style'])) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'style\' parameter only works in non-WSDL mode.');
|
||||
}
|
||||
}
|
||||
@ -869,6 +998,47 @@ class Zend_Soap_Client
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add SOAP input header
|
||||
*
|
||||
* @param SoapHeader $header
|
||||
* @param boolean $permanent
|
||||
* @return Zend_Soap_Client
|
||||
*/
|
||||
public function addSoapInputHeader(SoapHeader $header, $permanent = false)
|
||||
{
|
||||
if ($permanent) {
|
||||
$this->_permanentSoapInputHeaders[] = $header;
|
||||
} else {
|
||||
$this->_soapInputHeaders[] = $header;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset SOAP input headers
|
||||
*
|
||||
* @return Zend_Soap_Client
|
||||
*/
|
||||
public function resetSoapInputHeaders()
|
||||
{
|
||||
$this->_permanentSoapInputHeaders = array();
|
||||
$this->_soapInputHeaders = array();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last SOAP output headers
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLastSoapOutputHeaderObjects()
|
||||
{
|
||||
return $this->_soapOutputHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform a SOAP call
|
||||
*
|
||||
@ -882,9 +1052,17 @@ class Zend_Soap_Client
|
||||
$this->_initSoapClientObject();
|
||||
}
|
||||
|
||||
$this->_lastMethod = $name;
|
||||
|
||||
$result = call_user_func_array(array($this->_soapClient, $name), $this->_preProcessArguments($arguments));
|
||||
$this->_lastMethod = $name;
|
||||
|
||||
$soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders);
|
||||
$result = $this->_soapClient->__soapCall($name,
|
||||
$this->_preProcessArguments($arguments),
|
||||
null, /* Options are already set to the SOAP client object */
|
||||
(count($soapHeaders) > 0)? $soapHeaders : null,
|
||||
$this->_soapOutputHeaders);
|
||||
|
||||
// Reset non-permanent input headers
|
||||
$this->_soapInputHeaders = array();
|
||||
|
||||
return $this->_preProcessResult($result);
|
||||
}
|
||||
@ -899,6 +1077,7 @@ class Zend_Soap_Client
|
||||
public function getFunctions()
|
||||
{
|
||||
if ($this->getWsdl() == null) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.');
|
||||
}
|
||||
|
||||
@ -925,6 +1104,7 @@ class Zend_Soap_Client
|
||||
public function getTypes()
|
||||
{
|
||||
if ($this->getWsdl() == null) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.');
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -24,6 +25,7 @@ if (extension_loaded('soap')) {
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
*/
|
||||
class Zend_Soap_Client_Common extends SoapClient
|
||||
{
|
||||
|
@ -14,30 +14,28 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Soap_Client_Exception */
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
|
||||
/** Zend_Soap_Client */
|
||||
require_once 'Zend/Soap/Client.php';
|
||||
|
||||
|
||||
if (extension_loaded('soap')) {
|
||||
|
||||
/**
|
||||
* Zend_Soap_Client_Local
|
||||
*
|
||||
*
|
||||
* Class is intended to be used with .Net Web Services.
|
||||
*
|
||||
*
|
||||
* Important! Class is at experimental stage now.
|
||||
* Please leave your notes, compatiblity issues reports or
|
||||
* suggestions in fw-webservices@lists.zend.com or fw-general@lists.com
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
*/
|
||||
class Zend_Soap_Client_DotNet extends Zend_Soap_Client
|
||||
{
|
||||
@ -62,9 +60,17 @@ class Zend_Soap_Client_DotNet extends Zend_Soap_Client
|
||||
* My be overridden in descendant classes
|
||||
*
|
||||
* @param array $arguments
|
||||
* @throws Zend_Soap_Client_Exception
|
||||
*/
|
||||
protected function _preProcessArguments($arguments)
|
||||
{
|
||||
if (count($arguments) > 1 ||
|
||||
(count($arguments) == 1 && !is_array(reset($arguments)))
|
||||
) {
|
||||
require_once 'Zend/Soap/Client/Exception.php';
|
||||
throw new Zend_Soap_Client_Exception('.Net webservice arguments have to be grouped into array: array(\'a\' => $a, \'b\' => $b, ...).');
|
||||
}
|
||||
|
||||
// Do nothing
|
||||
return array($arguments);
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -24,6 +25,7 @@ require_once 'Zend/Exception.php';
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
|
@ -14,21 +14,17 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Soap_Client_Exception */
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
|
||||
|
||||
/** Zend_Soap_Server */
|
||||
require_once 'Zend/Soap/Server.php';
|
||||
|
||||
/** Zend_Soap_Client */
|
||||
require_once 'Zend/Soap/Client.php';
|
||||
|
||||
|
||||
if (extension_loaded('soap')) {
|
||||
|
||||
/**
|
||||
@ -41,6 +37,7 @@ if (extension_loaded('soap')) {
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Client
|
||||
*/
|
||||
class Zend_Soap_Client_Local extends Zend_Soap_Client
|
||||
{
|
||||
|
@ -14,25 +14,26 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
/** Zend_Server_Interface */
|
||||
/**
|
||||
* @see Zend_Server_Interface
|
||||
*/
|
||||
require_once 'Zend/Server/Interface.php';
|
||||
|
||||
/** Zend_Soap_Server_Exception */
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
|
||||
/**
|
||||
* Zend_Soap_Server
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Server
|
||||
* @uses Zend_Server_Interface
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Server.php 12627 2008-11-13 17:04:56Z alexander $
|
||||
* @version $Id: Server.php 14918 2009-04-15 16:07:53Z beberlei $
|
||||
*/
|
||||
class Zend_Soap_Server implements Zend_Server_Interface
|
||||
{
|
||||
@ -71,6 +72,21 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
*/
|
||||
protected $_encoding;
|
||||
|
||||
/**
|
||||
* SOAP Server Features
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_features;
|
||||
|
||||
/**
|
||||
* WSDL Caching Options of SOAP Server
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $_wsdlCache;
|
||||
|
||||
|
||||
/**
|
||||
* Registered fault exceptions
|
||||
* @var array
|
||||
@ -144,6 +160,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function __construct($wsdl = null, array $options = null)
|
||||
{
|
||||
if (!extension_loaded('soap')) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('SOAP extension is not loaded.');
|
||||
}
|
||||
|
||||
@ -161,11 +178,15 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
*
|
||||
* Allows setting options as an associative array of option => value pairs.
|
||||
*
|
||||
* @param array $options
|
||||
* @param array|Zend_Config $options
|
||||
* @return Zend_Soap_Server
|
||||
*/
|
||||
public function setOptions(array $options)
|
||||
public function setOptions($options)
|
||||
{
|
||||
if($options instanceof Zend_Config) {
|
||||
$options = $options->toArray();
|
||||
}
|
||||
|
||||
foreach ($options as $key => $value) {
|
||||
switch ($key) {
|
||||
case 'actor':
|
||||
@ -188,6 +209,12 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
case 'wsdl':
|
||||
$this->setWsdl($value);
|
||||
break;
|
||||
case 'featues':
|
||||
$this->setSoapFeatures($value);
|
||||
break;
|
||||
case 'cache_wsdl':
|
||||
$this->setWsdlCache($value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -224,6 +251,14 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
$options['uri'] = $this->_uri;
|
||||
}
|
||||
|
||||
if(null !== $this->_features) {
|
||||
$options['features'] = $this->_features;
|
||||
}
|
||||
|
||||
if(null !== $this->_wsdlCache) {
|
||||
$options['cache_wsdl'] = $this->_wsdlCache;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
@ -237,6 +272,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setEncoding($encoding)
|
||||
{
|
||||
if (!is_string($encoding)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid encoding specified');
|
||||
}
|
||||
|
||||
@ -264,6 +300,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setSoapVersion($version)
|
||||
{
|
||||
if (!in_array($version, array(SOAP_1_1, SOAP_1_2))) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid soap version specified');
|
||||
}
|
||||
|
||||
@ -295,6 +332,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid URN');
|
||||
}
|
||||
|
||||
@ -359,10 +397,18 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setClassmap($classmap)
|
||||
{
|
||||
if (!is_array($classmap)) {
|
||||
/**
|
||||
* @see Zend_Soap_Server_Exception
|
||||
*/
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Classmap must be an array');
|
||||
}
|
||||
foreach ($classmap as $type => $class) {
|
||||
if (!class_exists($class)) {
|
||||
/**
|
||||
* @see Zend_Soap_Server_Exception
|
||||
*/
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid class in class map');
|
||||
}
|
||||
}
|
||||
@ -389,8 +435,6 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
*/
|
||||
public function setWsdl($wsdl)
|
||||
{
|
||||
is_readable($wsdl);
|
||||
|
||||
$this->_wsdl = $wsdl;
|
||||
return $this;
|
||||
}
|
||||
@ -405,6 +449,48 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
return $this->_wsdl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SOAP Feature options.
|
||||
*
|
||||
* @param string|int $feature
|
||||
* @return Zend_Soap_Server
|
||||
*/
|
||||
public function setSoapFeatures($feature)
|
||||
{
|
||||
$this->_features = $feature;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current SOAP Features options
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSoapFeatures()
|
||||
{
|
||||
return $this->_features;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the SOAP Wsdl Caching Options
|
||||
*
|
||||
* @param string|int|boolean $caching
|
||||
* @return Zend_Soap_Server
|
||||
*/
|
||||
public function setWsdlCache($options)
|
||||
{
|
||||
$this->_wsdlCache = $options;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current SOAP Wsdl Caching option
|
||||
*/
|
||||
public function getWsdlCache()
|
||||
{
|
||||
return $this->_wsdlCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attach a function as a server method
|
||||
*
|
||||
@ -426,6 +512,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
if (is_string($func) && function_exists($func)) {
|
||||
$this->_functions[] = $func;
|
||||
} else {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('One or more invalid functions specified in array');
|
||||
}
|
||||
}
|
||||
@ -435,6 +522,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
} elseif ($function == SOAP_FUNCTIONS_ALL) {
|
||||
$this->_functions = SOAP_FUNCTIONS_ALL;
|
||||
} else {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid function specified');
|
||||
}
|
||||
|
||||
@ -463,14 +551,17 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setClass($class, $arg1 = null, $arg2 = null)
|
||||
{
|
||||
if (isset($this->_class)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('A class has already been registered with this soap server instance');
|
||||
}
|
||||
|
||||
if (!is_string($class)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid class argument (' . gettype($class) . ')');
|
||||
}
|
||||
|
||||
if (!class_exists($class)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Class "' . $class . '" does not exist');
|
||||
}
|
||||
|
||||
@ -495,10 +586,12 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setObject($object)
|
||||
{
|
||||
if(!is_object($object)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid object argument ('.gettype($object).')');
|
||||
}
|
||||
|
||||
if(isset($this->_object)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('An object has already been registered with this soap server instance');
|
||||
}
|
||||
|
||||
@ -538,6 +631,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
*/
|
||||
public function loadFunctions($definition)
|
||||
{
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Unimplemented');
|
||||
}
|
||||
|
||||
@ -550,6 +644,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
public function setPersistence($mode)
|
||||
{
|
||||
if (!in_array($mode, array(SOAP_PERSISTENCE_SESSION, SOAP_PERSISTENCE_REQUEST))) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid persistence mode specified');
|
||||
}
|
||||
|
||||
@ -596,7 +691,8 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
}
|
||||
|
||||
$dom = new DOMDocument();
|
||||
if (!$dom->loadXML($xml)) {
|
||||
if(strlen($xml) == 0 || !$dom->loadXML($xml)) {
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
throw new Zend_Soap_Server_Exception('Invalid XML');
|
||||
}
|
||||
}
|
||||
@ -712,20 +808,23 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
}
|
||||
|
||||
// Set Zend_Soap_Server error handler
|
||||
$displayErrorsOriginalState = ini_get('display_errors');
|
||||
ini_set('display_errors', false);
|
||||
set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR);
|
||||
$displayErrorsOriginalState = $this->_initializeSoapErrorContext();
|
||||
|
||||
$setRequestException = null;
|
||||
/**
|
||||
* @see Zend_Soap_Server_Exception
|
||||
*/
|
||||
require_once 'Zend/Soap/Server/Exception.php';
|
||||
try {
|
||||
$this->_setRequest($request);
|
||||
} catch (Zend_Soap_Server_Exception $setRequestException) {
|
||||
// Do nothing. Catch exception and store it in the $setRequestException variable is all what we need.
|
||||
} catch (Zend_Soap_Server_Exception $e) {
|
||||
$setRequestException = $e;
|
||||
}
|
||||
|
||||
$soap = $this->_getSoap();
|
||||
|
||||
ob_start();
|
||||
if (isset($setRequestException)) {
|
||||
if($setRequestException instanceof Exception) {
|
||||
// Send SOAP fault message if we've catched exception
|
||||
$soap->fault("Sender", $setRequestException->getMessage());
|
||||
} else {
|
||||
@ -750,6 +849,19 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
return $this->_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method initalizes the error context that the SOAPServer enviroment will run in.
|
||||
*
|
||||
* @return boolean display_errors original value
|
||||
*/
|
||||
protected function _initializeSoapErrorContext()
|
||||
{
|
||||
$displayErrorsOriginalState = ini_get('display_errors');
|
||||
ini_set('display_errors', false);
|
||||
set_error_handler(array($this, 'handlePhpErrors'), E_USER_ERROR);
|
||||
return $displayErrorsOriginalState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a valid fault exception
|
||||
*
|
||||
@ -803,7 +915,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
* @param string $code SOAP Fault Codes
|
||||
* @return SoapFault
|
||||
*/
|
||||
public function fault($fault = null, $code = "Reciever")
|
||||
public function fault($fault = null, $code = "Receiver")
|
||||
{
|
||||
if ($fault instanceof Exception) {
|
||||
$class = get_class($fault);
|
||||
@ -825,7 +937,7 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
'Sender', 'Receiver', 'Server'
|
||||
);
|
||||
if(!in_array($code, $allowedFaultModes)) {
|
||||
$code = "Reciever";
|
||||
$code = "Receiver";
|
||||
}
|
||||
|
||||
return new SoapFault($code, $message);
|
||||
@ -844,6 +956,6 @@ class Zend_Soap_Server implements Zend_Server_Interface
|
||||
*/
|
||||
public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null)
|
||||
{
|
||||
throw $this->fault($errstr, "Reciever");
|
||||
throw $this->fault($errstr, "Receiver");
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
@ -26,9 +27,10 @@ require_once 'Zend/Exception.php';
|
||||
/**
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Server
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Exception.php 8064 2008-02-16 10:58:39Z thomas $
|
||||
* @version $Id: Exception.php 14918 2009-04-15 16:07:53Z beberlei $
|
||||
*/
|
||||
class Zend_Soap_Server_Exception extends Zend_Exception
|
||||
{}
|
||||
|
@ -16,11 +16,9 @@
|
||||
* @package Zend_Soap
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Wsdl.php 12622 2008-11-13 15:43:54Z alexander $
|
||||
* @version $Id: Wsdl.php 15829 2009-05-30 19:04:57Z beberlei $
|
||||
*/
|
||||
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
|
||||
require_once "Zend/Soap/Wsdl/Strategy/Interface.php";
|
||||
require_once "Zend/Soap/Wsdl/Strategy/Abstract.php";
|
||||
|
||||
@ -93,6 +91,7 @@ class Zend_Soap_Wsdl
|
||||
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'></definitions>";
|
||||
$this->_dom = new DOMDocument();
|
||||
if (!$this->_dom->loadXML($wsdl)) {
|
||||
require_once 'Zend/Server/Exception.php';
|
||||
throw new Zend_Server_Exception('Unable to create DomDocument');
|
||||
} else {
|
||||
$this->_wsdl = $this->_dom->documentElement;
|
||||
@ -391,11 +390,15 @@ class Zend_Soap_Wsdl
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a {@link http://www.w3.org/TR/wsdl#_documentation document} element to any element in the WSDL
|
||||
* Add a documentation element to any element in the WSDL.
|
||||
*
|
||||
* @param object $input_node An XML_Tree_Node returned by another method to add the document to
|
||||
* @param string $document Human readable documentation for the node
|
||||
* @return boolean
|
||||
* Note that the WSDL {@link http://www.w3.org/TR/wsdl#_documentation specification} uses 'document',
|
||||
* but the WSDL {@link http://schemas.xmlsoap.org/wsdl/ schema} uses 'documentation' instead.
|
||||
* The {@link http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html#WSDL_documentation_Element WS-I Basic Profile 1.1} recommends using 'documentation'.
|
||||
*
|
||||
* @param object $input_node An XML_Tree_Node returned by another method to add the documentation to
|
||||
* @param string $documentation Human readable documentation for the node
|
||||
* @return DOMElement The documentation element
|
||||
*/
|
||||
public function addDocumentation($input_node, $documentation)
|
||||
{
|
||||
@ -405,11 +408,15 @@ class Zend_Soap_Wsdl
|
||||
$node = $input_node;
|
||||
}
|
||||
|
||||
/** @todo Check if 'documentation' is a correct name for the element (WSDL spec uses 'document') */
|
||||
$doc = $this->_dom->createElement('documentation');
|
||||
$doc_cdata = $this->_dom->createTextNode($documentation);
|
||||
$doc->appendChild($doc_cdata);
|
||||
$node->appendChild($doc);
|
||||
|
||||
if($node->hasChildNodes()) {
|
||||
$node->insertBefore($doc, $node->firstChild);
|
||||
} else {
|
||||
$node->appendChild($doc);
|
||||
}
|
||||
|
||||
return $doc;
|
||||
}
|
||||
@ -461,6 +468,10 @@ class Zend_Soap_Wsdl
|
||||
*/
|
||||
public function getSchema()
|
||||
{
|
||||
if($this->_schema == null) {
|
||||
$this->addSchemaTypeSection();
|
||||
}
|
||||
|
||||
return $this->_schema;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Wsdl
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once "Interface.php";
|
||||
|
||||
/**
|
||||
* Abstract class for Zend_Soap_Wsdl_Strategy.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Wsdl
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
abstract class Zend_Soap_Wsdl_Strategy_Abstract implements Zend_Soap_Wsdl_Strategy_Interface
|
||||
{
|
||||
/**
|
||||
* Context object
|
||||
*
|
||||
* @var Zend_Soap_Wsdl
|
||||
*/
|
||||
protected $_context;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once "Interface.php";
|
||||
|
||||
class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface
|
||||
{
|
||||
/**
|
||||
|
@ -22,8 +22,10 @@
|
||||
|
||||
require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php";
|
||||
|
||||
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_Abstract
|
||||
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy_DefaultComplexType
|
||||
{
|
||||
protected $_inProcess = array();
|
||||
|
||||
/**
|
||||
* Add an ArrayOfType based on the xsd:complexType syntax if type[] is detected in return value doc comment.
|
||||
*
|
||||
@ -32,6 +34,12 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
|
||||
*/
|
||||
public function addComplexType($type)
|
||||
{
|
||||
if(in_array($type, $this->_inProcess)) {
|
||||
require_once "Zend/Soap/Wsdl/Exception.php";
|
||||
throw new Zend_Soap_Wsdl_Exception("Infinite recursion, cannot nest '".$type."' into itsself.");
|
||||
}
|
||||
$this->_inProcess[$type] = $type;
|
||||
|
||||
$nestingLevel = $this->_getNestedCount($type);
|
||||
|
||||
if($nestingLevel > 1) {
|
||||
@ -60,8 +68,11 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
|
||||
}
|
||||
|
||||
// The array for the objects has been created, now build the object definition:
|
||||
$this->_addObjectComplexType($singularType);
|
||||
if(!in_array($singularType, $this->getContext()->getTypes())) {
|
||||
parent::addComplexType($singularType);
|
||||
}
|
||||
|
||||
unset($this->_inProcess[$type]);
|
||||
return "tns:".$xsdComplexTypeName;
|
||||
}
|
||||
|
||||
@ -70,40 +81,30 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex extends Zend_Soap_Wsdl_Strategy
|
||||
$dom = $this->getContext()->toDomDocument();
|
||||
|
||||
$xsdComplexTypeName = $this->_getXsdComplexTypeName($singularType);
|
||||
$complexType = $dom->createElement('xsd:complexType');
|
||||
$complexType->setAttribute('name', $xsdComplexTypeName);
|
||||
|
||||
$complexContent = $dom->createElement("xsd:complexContent");
|
||||
$complexType->appendChild($complexContent);
|
||||
if(!in_array($xsdComplexTypeName, $this->getContext()->getTypes())) {
|
||||
$complexType = $dom->createElement('xsd:complexType');
|
||||
$complexType->setAttribute('name', $xsdComplexTypeName);
|
||||
|
||||
$xsdRestriction = $dom->createElement("xsd:restriction");
|
||||
$xsdRestriction->setAttribute('base', 'soapenc:Array');
|
||||
$complexContent->appendChild($xsdRestriction);
|
||||
$complexContent = $dom->createElement("xsd:complexContent");
|
||||
$complexType->appendChild($complexContent);
|
||||
|
||||
$xsdAttribute = $dom->createElement("xsd:attribute");
|
||||
$xsdAttribute->setAttribute("ref", "soapenc:arrayType");
|
||||
$xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType));
|
||||
$xsdRestriction->appendChild($xsdAttribute);
|
||||
$xsdRestriction = $dom->createElement("xsd:restriction");
|
||||
$xsdRestriction->setAttribute('base', 'soap-enc:Array');
|
||||
$complexContent->appendChild($xsdRestriction);
|
||||
|
||||
$this->getContext()->getSchema()->appendChild($complexType);
|
||||
$this->getContext()->addType($type);
|
||||
$xsdAttribute = $dom->createElement("xsd:attribute");
|
||||
$xsdAttribute->setAttribute("ref", "soap-enc:arrayType");
|
||||
$xsdAttribute->setAttribute("wsdl:arrayType", sprintf("tns:%s[]", $singularType));
|
||||
$xsdRestriction->appendChild($xsdAttribute);
|
||||
|
||||
$this->getContext()->getSchema()->appendChild($complexType);
|
||||
$this->getContext()->addType($xsdComplexTypeName);
|
||||
}
|
||||
|
||||
return $xsdComplexTypeName;
|
||||
}
|
||||
|
||||
protected function _addObjectComplexType($singularType)
|
||||
{
|
||||
$complexStrategy = $this->getContext()->getComplexTypeStrategy();
|
||||
|
||||
// Override strategy to stay DRY
|
||||
$objectStrategy = new Zend_Soap_Wsdl_Strategy_DefaultComplexType();
|
||||
$this->getContext()->setComplexTypeStrategy($objectStrategy);
|
||||
$this->getContext()->addComplexType($singularType);
|
||||
|
||||
// Reset strategy
|
||||
$this->getContext()->setComplexTypeStrategy($complexStrategy);
|
||||
}
|
||||
|
||||
protected function _getXsdComplexTypeName($type)
|
||||
{
|
||||
return sprintf('ArrayOf%s', $type);
|
||||
|
@ -19,6 +19,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once "Abstract.php";
|
||||
|
||||
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_Abstract
|
||||
{
|
||||
/**
|
||||
@ -41,7 +43,7 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
|
||||
$this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName);
|
||||
}
|
||||
// adding the PHP type which is resolved to a nested XSD type. therefore add only once.
|
||||
$this->getContext()->addType($type);
|
||||
$this->getContext()->addType($complexTypeName);
|
||||
|
||||
return "tns:$complexTypeName";
|
||||
} else {
|
||||
|
174
libs/Zend/Soap/Wsdl/Strategy/Composite.php
Normal file
174
libs/Zend/Soap/Wsdl/Strategy/Composite.php
Normal file
@ -0,0 +1,174 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework
|
||||
*
|
||||
* LICENSE
|
||||
*
|
||||
* This source file is subject to the new BSD license that is bundled
|
||||
* with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://framework.zend.com/license/new-bsd
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@zend.com so we can send you a copy immediately.
|
||||
*
|
||||
* @category Zend
|
||||
* @package Zend_Soap
|
||||
* @subpackage Wsdl
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface
|
||||
{
|
||||
/**
|
||||
* Typemap of Complex Type => Strategy pairs.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_typeMap = array();
|
||||
|
||||
/**
|
||||
* Default Strategy of this composite
|
||||
*
|
||||
* @var string|Zend_Soap_Wsdl_Strategy_Interface
|
||||
*/
|
||||
protected $_defaultStrategy;
|
||||
|
||||
/**
|
||||
* Context WSDL file that this composite serves
|
||||
*
|
||||
* @var Zend_Soap_Wsdl|null
|
||||
*/
|
||||
protected $_context;
|
||||
|
||||
/**
|
||||
* Construct Composite WSDL Strategy.
|
||||
*
|
||||
* @throws Zend_Soap_Wsdl_Exception
|
||||
* @param array $typeMap
|
||||
* @param string|Zend_Soap_Wsdl_Strategy_Interface $defaultStrategy
|
||||
*/
|
||||
public function __construct(array $typeMap=array(), $defaultStrategy="Zend_Soap_Wsdl_Strategy_DefaultComplexType")
|
||||
{
|
||||
foreach($typeMap AS $type => $strategy) {
|
||||
$this->connectTypeToStrategy($type, $strategy);
|
||||
}
|
||||
$this->_defaultStrategy = $defaultStrategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect a complex type to a given strategy.
|
||||
*
|
||||
* @throws Zend_Soap_Wsdl_Exception
|
||||
* @param string $type
|
||||
* @param string|Zend_Soap_Wsdl_Strategy_Interface $strategy
|
||||
* @return Zend_Soap_Wsdl_Strategy_Composite
|
||||
*/
|
||||
public function connectTypeToStrategy($type, $strategy)
|
||||
{
|
||||
if(!is_string($type)) {
|
||||
/**
|
||||
* @see Zend_Soap_Wsdl_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/Wsdl/Exception.php";
|
||||
throw new Zend_Soap_Wsdl_Exception("Invalid type given to Composite Type Map.");
|
||||
}
|
||||
$this->_typeMap[$type] = $strategy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return default strategy of this composite
|
||||
*
|
||||
* @throws Zend_Soap_Wsdl_Exception
|
||||
* @param string $type
|
||||
* @return Zend_Soap_Wsdl_Strategy_Interface
|
||||
*/
|
||||
public function getDefaultStrategy()
|
||||
{
|
||||
$strategy = $this->_defaultStrategy;
|
||||
if(is_string($strategy) && class_exists($strategy)) {
|
||||
$strategy = new $strategy;
|
||||
}
|
||||
if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) {
|
||||
/**
|
||||
* @see Zend_Soap_Wsdl_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/Wsdl/Exception.php";
|
||||
throw new Zend_Soap_Wsdl_Exception(
|
||||
"Default Strategy for Complex Types is not a valid strategy object."
|
||||
);
|
||||
}
|
||||
$this->_defaultStrategy = $strategy;
|
||||
return $strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return specific strategy or the default strategy of this type.
|
||||
*
|
||||
* @throws Zend_Soap_Wsdl_Exception
|
||||
* @param string $type
|
||||
* @return Zend_Soap_Wsdl_Strategy_Interface
|
||||
*/
|
||||
public function getStrategyOfType($type)
|
||||
{
|
||||
if(isset($this->_typeMap[$type])) {
|
||||
$strategy = $this->_typeMap[$type];
|
||||
|
||||
if(is_string($strategy) && class_exists($strategy)) {
|
||||
$strategy = new $strategy();
|
||||
}
|
||||
|
||||
if( !($strategy instanceof Zend_Soap_Wsdl_Strategy_Interface) ) {
|
||||
/**
|
||||
* @see Zend_Soap_Wsdl_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/Wsdl/Exception.php";
|
||||
throw new Zend_Soap_Wsdl_Exception(
|
||||
"Strategy for Complex Type '".$type."' is not a valid strategy object."
|
||||
);
|
||||
}
|
||||
$this->_typeMap[$type] = $strategy;
|
||||
} else {
|
||||
$strategy = $this->getDefaultStrategy();
|
||||
}
|
||||
return $strategy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method accepts the current WSDL context file.
|
||||
*
|
||||
* @param Zend_Soap_Wsdl $context
|
||||
*/
|
||||
public function setContext(Zend_Soap_Wsdl $context)
|
||||
{
|
||||
$this->_context = $context;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a complex type based on a strategy
|
||||
*
|
||||
* @throws Zend_Soap_Wsdl_Exception
|
||||
* @param string $type
|
||||
* @return string XSD type
|
||||
*/
|
||||
public function addComplexType($type)
|
||||
{
|
||||
if(!($this->_context instanceof Zend_Soap_Wsdl) ) {
|
||||
/**
|
||||
* @see Zend_Soap_Wsdl_Exception
|
||||
*/
|
||||
require_once "Zend/Soap/Wsdl/Exception.php";
|
||||
throw new Zend_Soap_Wsdl_Exception(
|
||||
"Cannot add complex type '".$type."', no context is set for this composite strategy."
|
||||
);
|
||||
}
|
||||
|
||||
$strategy = $this->getStrategyOfType($type);
|
||||
$strategy->setContext($this->_context);
|
||||
return $strategy->addComplexType($type);
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
require_once "Abstract.php";
|
||||
|
||||
class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract
|
||||
{
|
||||
/**
|
||||
@ -47,7 +49,7 @@ class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy
|
||||
$all = $dom->createElement('xsd:all');
|
||||
|
||||
foreach ($class->getProperties() as $property) {
|
||||
if (preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
|
||||
if ($property->isPublic() && preg_match_all('/@var\s+([^\s]+)/m', $property->getDocComment(), $matches)) {
|
||||
|
||||
/**
|
||||
* @todo check if 'xsd:element' must be used here (it may not be compatible with using 'complexType'
|
||||
|
@ -23,6 +23,11 @@
|
||||
|
||||
interface Zend_Soap_Wsdl_Strategy_Interface
|
||||
{
|
||||
/**
|
||||
* Method accepts the current WSDL context file.
|
||||
*
|
||||
* @param <type> $context
|
||||
*/
|
||||
public function setContext(Zend_Soap_Wsdl $context);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user