import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -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 {
}
}
}