import v1.1.0_RC2 | 2009-09-20

This commit is contained in:
2019-07-17 22:19:00 +02:00
parent 3b7ba80568
commit 38c146901c
2504 changed files with 101817 additions and 62316 deletions

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage AutoDiscover
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: AutoDiscover.php 14918 2009-04-15 16:07:53Z beberlei $
* @version $Id: AutoDiscover.php 16210 2009-06-21 19:22:17Z thomas $
*/
require_once 'Zend/Server/Interface.php';
@ -254,53 +254,16 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
$wsdl = new Zend_Soap_Wsdl($class, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($class . 'Port');
$binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port');
$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 */
$portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' .$method->getName(). 'Request', 'tns:' .$method->getName(). 'Response');
$desc = $method->getDescription();
if (strlen($desc) > 0) {
/** @todo check, what should be done for portoperation documentation */
//$wsdl->addDocumentation($portOperation, $desc);
}
/* </wsdl:portType>'s */
$this->_functions[] = $method->getName();
$selectedPrototype = null;
$maxNumArgumentsOfPrototype = -1;
foreach ($method->getPrototypes() as $prototype) {
$numParams = count($prototype->getParameters());
if($numParams > $maxNumArgumentsOfPrototype) {
$maxNumArgumentsOfPrototype = $numParams;
$selectedPrototype = $prototype;
}
}
if($selectedPrototype != null) {
$prototype = $selectedPrototype;
$args = array();
foreach($prototype->getParameters() as $param) {
$args[$param->getName()] = $wsdl->getType($param->getType());
}
$message = $wsdl->addMessage($method->getName() . 'Request', $args);
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($message, $desc);
}
if ($prototype->getReturnType() != "void") {
$returnName = 'return';
$message = $wsdl->addMessage($method->getName() . 'Response', array($returnName => $wsdl->getType($prototype->getReturnType())));
}
/* <wsdl:binding>'s */
$operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
$wsdl->addSoapOperation($operation, $uri . '#' .$method->getName());
/* </wsdl:binding>'s */
}
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
}
@ -328,6 +291,9 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
$name = $parts[0];
$wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
// The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
$wsdl->addSchemaTypeSection();
$port = $wsdl->addPortType($name . 'Port');
$binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port');
@ -339,41 +305,122 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface {
foreach ($function as $func) {
$method = $this->_reflection->reflectFunction($func);
foreach ($method->getPrototypes() as $prototype) {
$args = array();
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = $wsdl->getType($param->getType());
}
$message = $wsdl->addMessage($method->getName() . 'Request', $args);
$desc = $method->getDescription();
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($message, $desc);
}
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');
if (strlen($desc) > 0) {
//$wsdl->addDocumentation($portOperation, $desc);
}
/* </wsdl:portType>'s */
/* <wsdl:binding>'s */
$operation = $wsdl->addBindingOperation($binding, $method->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
$wsdl->addSoapOperation($operation, $uri . '#' .$method->getName());
/* </wsdl:binding>'s */
$this->_functions[] = $method->getName();
// We will only add one prototype
break;
}
$this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
}
$this->_wsdl = $wsdl;
}
/**
* Add a function to the WSDL document.
*
* @param $function Zend_Server_Reflection_Function_Abstract function to add
* @param $wsdl Zend_Soap_Wsdl WSDL document
* @param $port object wsdl:portType
* @param $binding object wsdl:binding
* @return void
*/
protected function _addFunctionToWsdl($function, $wsdl, $port, $binding)
{
$uri = $this->getUri();
// We only support one prototype: the one with the maximum number of arguments
$prototype = null;
$maxNumArgumentsOfPrototype = -1;
foreach ($function->getPrototypes() as $tmpPrototype) {
$numParams = count($tmpPrototype->getParameters());
if ($numParams > $maxNumArgumentsOfPrototype) {
$maxNumArgumentsOfPrototype = $numParams;
$prototype = $tmpPrototype;
}
}
if ($prototype === null) {
require_once "Zend/Soap/AutoDiscover/Exception.php";
throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function");
}
// Add the input message (parameters)
$args = array();
if ($this->_bindingStyle['style'] == 'document') {
// Document style: wrap all parameters in a sequence element
$sequence = array();
foreach ($prototype->getParameters() as $param) {
$sequenceElement = array(
'name' => $param->getName(),
'type' => $wsdl->getType($param->getType())
);
if ($param->isOptional()) {
$sequenceElement['nillable'] = 'true';
}
$sequence[] = $sequenceElement;
}
$element = array(
'name' => $function->getName(),
'sequence' => $sequence
);
// Add the wrapper element part, which must be named 'parameters'
$args['parameters'] = array('element' => $wsdl->addElement($element));
} else {
// RPC style: add each parameter as a typed part
foreach ($prototype->getParameters() as $param) {
$args[$param->getName()] = array('type' => $wsdl->getType($param->getType()));
}
}
$wsdl->addMessage($function->getName() . 'In', $args);
$isOneWayMessage = false;
if($prototype->getReturnType() == "void") {
$isOneWayMessage = true;
}
if($isOneWayMessage == false) {
// Add the output message (return value)
$args = array();
if ($this->_bindingStyle['style'] == 'document') {
// Document style: wrap the return value in a sequence element
$sequence = array();
if ($prototype->getReturnType() != "void") {
$sequence[] = array(
'name' => $function->getName() . 'Result',
'type' => $wsdl->getType($prototype->getReturnType())
);
}
$element = array(
'name' => $function->getName() . 'Response',
'sequence' => $sequence
);
// Add the wrapper element part, which must be named 'parameters'
$args['parameters'] = array('element' => $wsdl->addElement($element));
} else if ($prototype->getReturnType() != "void") {
// RPC style: add the return value as a typed part
$args['return'] = array('type' => $wsdl->getType($prototype->getReturnType()));
}
$wsdl->addMessage($function->getName() . 'Out', $args);
}
// Add the portType operation
if($isOneWayMessage == false) {
$portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', 'tns:' . $function->getName() . 'Out');
} else {
$portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', false);
}
$desc = $function->getDescription();
if (strlen($desc) > 0) {
$wsdl->addDocumentation($portOperation, $desc);
}
// When using the RPC style, make sure the operation style includes a 'namespace' attribute (WS-I Basic Profile 1.1 R2717)
if ($this->_bindingStyle['style'] == 'rpc' && !isset($this->_operationBodyStyle['namespace'])) {
$this->_operationBodyStyle['namespace'] = ''.$uri;
}
// Add the binding operation
$operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
$wsdl->addSoapOperation($operation, $uri . '#' .$function->getName());
// Add the function name to the list
$this->_functions[] = $function->getName();
}
/**
* Action to take when an error occurs
*

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage AutoDiscover
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Zend/Exception.php";
@ -27,4 +28,4 @@ require_once "Zend/Exception.php";
*/
class Zend_Soap_AutoDiscover_Exception extends Zend_Exception
{
}
}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Client.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Soap_Server */
@ -34,7 +35,7 @@ require_once 'Zend/Soap/Client/Common.php';
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Zend_Soap_Client
@ -814,6 +815,8 @@ class Zend_Soap_Client
public function setSoapFeatures($feature)
{
$this->_features = $feature;
$this->_soapClient = null;
return $this;
}
@ -1048,14 +1051,12 @@ class Zend_Soap_Client
*/
public function __call($name, $arguments)
{
if ($this->_soapClient == null) {
$this->_initSoapClientObject();
}
$soapClient = $this->getSoapClient();
$this->_lastMethod = $name;
$soapHeaders = array_merge($this->_permanentSoapInputHeaders, $this->_soapInputHeaders);
$result = $this->_soapClient->__soapCall($name,
$result = $soapClient->__soapCall($name,
$this->_preProcessArguments($arguments),
null, /* Options are already set to the SOAP client object */
(count($soapHeaders) > 0)? $soapHeaders : null,
@ -1081,11 +1082,8 @@ class Zend_Soap_Client
throw new Zend_Soap_Client_Exception('\'getFunctions\' method is available only in WSDL mode.');
}
if ($this->_soapClient == null) {
$this->_initSoapClientObject();
}
return $this->_soapClient->__getFunctions();
$soapClient = $this->getSoapClient();
return $soapClient->__getFunctions();
}
@ -1108,10 +1106,41 @@ class Zend_Soap_Client
throw new Zend_Soap_Client_Exception('\'getTypes\' method is available only in WSDL mode.');
}
$soapClient = $this->getSoapClient();
return $soapClient->__getTypes();
}
/**
* @param SoapClient $soapClient
* @return Zend_Soap_Client
*/
public function setSoapClient(SoapClient $soapClient)
{
$this->_soapClient = $soapClient;
return $this;
}
/**
* @return SoapClient
*/
public function getSoapClient()
{
if ($this->_soapClient == null) {
$this->_initSoapClientObject();
}
return $this->_soapClient;
}
return $this->_soapClient->__getTypes();
/**
* @param string $name
* @param string $value
* @return Zend_Soap_Client
*/
public function setCookie($cookieName, $cookieValue=null)
{
$soapClient = $this->getSoapClient();
$soapClient->__setCookie($cookieName, $cookieValue);
return $this;
}
}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Common.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: DotNet.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Soap_Client */

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -26,9 +26,9 @@ 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)
* @copyright Copyright (c) 2005-2009 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 16971 2009-07-22 18:05:45Z mikaelkael $
*/
class Zend_Soap_Client_Exception extends Zend_Exception
{}

View File

@ -15,8 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Client
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Local.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
/** Zend_Soap_Server */

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Soap
* @subpackage Server
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -31,9 +31,9 @@ require_once 'Zend/Server/Interface.php';
* @package Zend_Soap
* @subpackage Server
* @uses Zend_Server_Interface
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Server.php 14918 2009-04-15 16:07:53Z beberlei $
* @version $Id: Server.php 16210 2009-06-21 19:22:17Z thomas $
*/
class Zend_Soap_Server implements Zend_Server_Interface
{

View File

@ -15,7 +15,7 @@
* @category Zend
* @package Zend_Soap
* @subpackage Server
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
@ -28,9 +28,9 @@ 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)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Exception.php 14918 2009-04-15 16:07:53Z beberlei $
* @version $Id: Exception.php 16210 2009-06-21 19:22:17Z thomas $
*/
class Zend_Soap_Server_Exception extends Zend_Exception
{}

View File

@ -14,9 +14,9 @@
*
* @category Zend
* @package Zend_Soap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id: Wsdl.php 15829 2009-05-30 19:04:57Z beberlei $
* @version $Id: Wsdl.php 16210 2009-06-21 19:22:17Z thomas $
*/
require_once "Zend/Soap/Wsdl/Strategy/Interface.php";
@ -175,6 +175,8 @@ class Zend_Soap_Wsdl
* @param string $name Name for the {@link http://www.w3.org/TR/wsdl#_messages message}
* @param array $parts An array of {@link http://www.w3.org/TR/wsdl#_message parts}
* The array is constructed like: 'name of part' => 'part xml schema data type'
* or 'name of part' => array('type' => 'part xml schema type')
* or 'name of part' => array('element' => 'part xml element name')
* @return object The new message's XML_Tree_Node for use in {@link function addDocumentation}
*/
public function addMessage($name, $parts)
@ -187,7 +189,13 @@ class Zend_Soap_Wsdl
foreach ($parts as $name => $type) {
$part = $this->_dom->createElement('part');
$part->setAttribute('name', $name);
$part->setAttribute('type', $type);
if (is_array($type)) {
foreach ($type as $key => $value) {
$part->setAttribute($key, $value);
}
} else {
$part->setAttribute('type', $type);
}
$message->appendChild($part);
}
}
@ -587,4 +595,65 @@ class Zend_Soap_Wsdl
// delegates the detection of a complex type to the current strategy
return $strategy->addComplexType($type);
}
/**
* Parse an xsd:element represented as an array into a DOMElement.
*
* @param array $element an xsd:element represented as an array
* @return DOMElement parsed element
*/
private function _parseElement($element)
{
if (!is_array($element)) {
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception("The 'element' parameter needs to be an associative array.");
}
$elementXml = $this->_dom->createElement('xsd:element');
foreach ($element as $key => $value) {
if (in_array($key, array('sequence', 'all', 'choice'))) {
if (is_array($value)) {
$complexType = $this->_dom->createElement('xsd:complexType');
if (count($value) > 0) {
$container = $this->_dom->createElement('xsd:' . $key);
foreach ($value as $subelement) {
$subelementXml = $this->_parseElement($subelement);
$container->appendChild($subelementXml);
}
$complexType->appendChild($container);
}
$elementXml->appendChild($complexType);
}
} else {
$elementXml->setAttribute($key, $value);
}
}
return $elementXml;
}
/**
* Add an xsd:element represented as an array to the schema.
*
* Array keys represent attribute names and values their respective value.
* The 'sequence', 'all' and 'choice' keys must have an array of elements as their value,
* to add them to a nested complexType.
*
* Example: array( 'name' => 'MyElement',
* 'sequence' => array( array('name' => 'myString', 'type' => 'string'),
* array('name' => 'myInteger', 'type' => 'int') ) );
* Resulting XML: <xsd:element name="MyElement"><xsd:complexType><xsd:sequence>
* <xsd:element name="myString" type="string"/>
* <xsd:element name="myInteger" type="int"/>
* </xsd:sequence></xsd:complexType></xsd:element>
*
* @param array $element an xsd:element represented as an array
* @return string xsd:element for the given element array
*/
public function addElement($element)
{
$schema = $this->getSchema();
$elementXml = $this->_parseElement($element);
$schema->appendChild($elementXml);
return 'tns:' . $element['name'];
}
}

View File

@ -1,127 +0,0 @@
<?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
* @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: CodeGenerator.php 11560 2008-10-01 10:09:10Z yoshida@zend.co.jp $
*/
require_once 'Zend/Soap/Wsdl/Parser.php';
/**
* Zend_Soap_Wsdl_CodeGenerator
*
* @category Zend
* @package Zend_Soap
*/
class Zend_Soap_Wsdl_CodeGenerator {
/**
* @var string WSDL Filename/URI
*/
private static $filename = null;
/**
* @var string PHP Code for output
*/
private static $php_code;
/**
* @var object Zend_Soap_Wsdl_Parser Result
*/
private static $wsdl;
/**
* Constructor
*
* @param string $wsdl Filename, URI or XML for the WSDL
* @param string $output Output file name, default: null
*/
public static function parse($wsdl, $output = null)
{
self::$wsdl = Zend_Soap_Wsdl_Parser::parse($wsdl);
self::$php_code = self::generatePhp();
if (!is_null($output) && is_writable($output)) {
file_put_contents($output);
}
return self::$php_code;
}
/**
* Generate the output PHP
*
* @return string
*/
private function generatePhp()
{
$php_code = '<?php' . "\n";
if (isset(self::$wsdl->documentation)) {
$docs = self::$wsdl->documentation;
$docs = explode("\n", $docs);
$php_code .= "/**\n";
foreach ($docs as $line) {
$php_code .= ' * ' .trim($line). PHP_EOL;
}
$php_code .= " */\n\n";
}
if (!isset(self::$wsdl->name)) {
$classname = 'SoapService';
} else {
$classname = self::$wsdl->name;
}
$php_code .= "class {$classname} {\n";
foreach (self::$wsdl->operations as $name => $io) {
if (isset($io['documentation'])) {
$php_code .= "\n\t/**\n";
$docs = $io['documentation'];
$docs = explode("\n", $docs);
foreach ($docs as $line) {
$php_code .= "\t * " .trim($line). PHP_EOL;
}
$php_code .= "\t */\n";
}
$php_code .= "\n\tpublic function {$name} (";
if (isset($io['input'])) {
$arg_names = array();
foreach ($io['input'] as $arg) {
$arg_names[] = $arg['name'];
}
$php_code .= '$' .implode(', $', $arg_names);
}
$php_code .= ')';
$php_code .= "\n\t{";
$php_code .= "\n\t\t\n";
if (isset($io['output'])) {
$php_code .= "\t\treturn \${$io['output']['name']};\n";
}
$php_code .= "\t}\n";
}
$php_code .= "\n}";
$php_code .= PHP_EOL. "\$server = new SoapServer;" .PHP_EOL;
$php_code .= "\$server->setClass($classname);";
$php_code .= "\n?>";
return $php_code;
}
}

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: Exception.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Zend/Exception.php";

View File

@ -1,173 +0,0 @@
<?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
* @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: Parser.php 12080 2008-10-22 16:40:33Z beberlei $
*/
require_once 'Zend/Soap/Wsdl/Parser/Result.php';
/**
* Zend_Soap_Wsdl_Parser
*
* @category Zend
* @package Zend_Soap
*/
class Zend_Soap_Wsdl_Parser {
/**
* @var SimpleXML object for the WSDL document being parsed
*/
private static $xml;
/**
* Parse a WSDL document into a generic object
*
* @param string|file $wsdl The WSDL document or a filename for the WSDL document to parse
* @return Zend_Soap_Wsdl_Parser_Result The contents of the WSDL file
*/
public static function parse($wsdl)
{
if (strpos($wsdl, '<') === false) {
$wsdl_result = new Zend_Soap_Wsdl_Parser_Result($wsdl);
$wsdl = file_get_contents($wsdl);
} else {
$tmp = tempnam(ini_get('upload_tmp_dir'), 'ZF_Temp_');
file_put_contents($tmp, $wsdl);
$wsdl_result = new Zend_Soap_Wsdl_Parser_Result($tmp);
}
self::$xml = simplexml_load_string($wsdl);
/* This is done so that we have a known prefix to the WSDL elements
for XPath queries */
self::$xml['xmlns:zfwsdl'] = 'http://schemas.xmlsoap.org/wsdl/';
self::$xml = simplexml_load_string(self::$xml->asXML());
if (isset(self::$xml->documentation)) {
$wsdl_result->documentation = trim(self::$xml->documentation);
}
if (!isset(self::$xml['name'])) {
$wsdl_result->name = null;
} else {
$wsdl_result->name = (string) self::$xml['name'];
}
foreach (self::$xml->binding->operation as $operation) {
$name = (string) $operation['name'];
$wsdl_result->operations[$name] = array();
$wsdl_result->operations[$name]['input'] = self::getOperationInputs($name);
$wsdl_result->operations[$name]['output'] = self::getOperationOutput($name);
$wsdl_result->operations[$name]['documentation'] = self::getDocs($name);
}
$wsdl_result->portType = (string) self::$xml->portType['name'];
$wsdl_result->binding = (string) self::$xml->binding['name'];
$wsdl_result->service['name'] = (string) self::$xml->service['name'];
$wsdl_result->service['address'] = (string) self::$xml->service->port->children('http://schemas.xmlsoap.org/wsdl/soap/')->attributes();
$wsdl_result->targetNamespace = (string) self::$xml['targetNamespace'];
return $wsdl_result;
}
/**
* Get Function arguments
*
* @param string $operation_name Name of the <operation> element to find
* @return string
*/
private static function getOperationInputs($operation_name)
{
$operation = self::$xml->xpath('/zfwsdl:definitions[1]/zfwsdl:portType/zfwsdl:operation[@name="' .$operation_name. '"]');
if ($operation == null) {
return '';
}
if (isset($operation[0]->input)) {
$input_message_name = $operation[0]->input['message'];
$input_message_name = explode(':', $input_message_name);
$input_message_name = $input_message_name[1];
$input_message = self::$xml->xpath('/zfwsdl:definitions[1]/zfwsdl:message[@name="' .$input_message_name. '"]');
}
if ($input_message != null) {
foreach ($input_message[0]->part as $part) {
$args[] = array(
'name' => (string) $part['name'],
'type' => (string) $part['type'],
);
}
if (isset($args) && is_array($args)) {
return $args;
} else {
return null;
}
} else {
return null;
}
}
/**
* Get Function return variable
*
* @param string $operation_name Name of the <operation> element to find
* @return string|false Returns variable name if found, or false
*/
private static function getOperationOutput($operation_name)
{
$operation = self::$xml->xpath('/zfwsdl:definitions[1]/zfwsdl:portType/zfwsdl:operation[@name="' .$operation_name. '"]');
if (isset($operation[0]->output)) {
$output_message_name = $operation[0]->output['message'];
$output_message_name = explode(':', $output_message_name);
$output_message_name = $output_message_name[1];
$output_message = self::$xml->xpath('/zfwsdl:definitions[1]/zfwsdl:message[@name="' .$output_message_name. '"]');
}
if ($output_message != null) {
return array(
'name' => (string) $output_message[0]->part['name'],
'type' => (string) $output_message[0]->part['type']
);
} else {
return null;
}
}
/**
* Get Function Documentation
*
* @param string $operation_name Name of the <operation> element to find
* @return string
*/
private static function getDocs($operation_name)
{
$portType = self::$xml->xpath('//zfwsdl:operation[@name="' .$operation_name. '"]/zfwsdl:documentation');
if (isset($portType) && is_array($portType) && (sizeof($portType) >= 1)) {
return trim((string) $portType[0]);
} else {
return null;
}
}
}

View File

@ -1,52 +0,0 @@
<?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
* @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: Result.php 11560 2008-10-01 10:09:10Z yoshida@zend.co.jp $
*/
/**
* Zend_Soap_Wsdl_Parser_Result
*
* @category Zend
* @package Zend_Soap
*/
class Zend_Soap_Wsdl_Parser_Result {
public $wsdl_file = '';
public $name;
public $documentation;
public $operations;
public $portType;
public $binding;
public $service;
public $targetNamespace;
public function __construct($wsdl)
{
$this->wsdl_file = $wsdl;
}
}

View File

@ -15,12 +15,12 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Interface.php";
require_once "Zend/Soap/Wsdl/Strategy/Interface.php";
/**
* Abstract class for Zend_Soap_Wsdl_Strategy.
@ -28,7 +28,7 @@ require_once "Interface.php";
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 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

View File

@ -15,12 +15,12 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: AnyType.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Interface.php";
require_once "Zend/Soap/Wsdl/Strategy/Interface.php";
class Zend_Soap_Wsdl_Strategy_AnyType implements Zend_Soap_Wsdl_Strategy_Interface
{

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: ArrayOfTypeComplex.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php";

View File

@ -14,14 +14,14 @@
*
* @category Zend
* @package Zend_Soap
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: ArrayOfTypeSequence.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Abstract.php";
require_once "Zend/Soap/Wsdl/Strategy/DefaultComplexType.php";
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_Abstract
class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strategy_DefaultComplexType
{
/**
* Add an unbounded ArrayOfType based on the xsd:sequence syntax if type[] is detected in return value doc comment.
@ -37,7 +37,7 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
$singularType = $this->_getSingularType($type);
for($i = 1; $i <= $nestedCounter; $i++) {
$complexTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i);
$complexTypeName = substr($this->_getTypeNameBasedOnNestingLevel($singularType, $i), 4);
$childTypeName = $this->_getTypeNameBasedOnNestingLevel($singularType, $i-1);
$this->_addElementFromWsdlAndChildTypes($complexTypeName, $childTypeName);
@ -46,11 +46,12 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
$this->getContext()->addType($complexTypeName);
return "tns:$complexTypeName";
} else if (!in_array($type, $this->getContext()->getTypes())) {
// New singular complex type
return parent::addComplexType($type);
} else {
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception(sprintf(
'ArrayOfTypeSequence Strategy does not allow for complex types that are not in @return type[] syntax. "%s" type was specified.', $type
));
// Existing complex type
return $this->getContext()->getType($type);
}
}
@ -70,7 +71,7 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
$prefix = str_repeat("ArrayOf", $level);
$xsdType = $this->_getStrippedXsdType($singularType);
$arrayType = $prefix.$xsdType;
return $arrayType;
return "tns:$arrayType";
}
}
@ -95,14 +96,6 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
protected function _getSingularType($type)
{
$singulartype = $this->getContext()->getType(str_replace("[]", "", $type));
if(substr($singulartype, 0, 4) != "xsd:") {
require_once "Zend/Soap/Wsdl/Exception.php";
throw new Zend_Soap_Wsdl_Exception(sprintf(
'ArrayOfTypeSequence Strategy works only with arrays of simple types like int, string, boolean, not with "%s".'.
'You may use Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex for more complex types.', $type
));
}
return $singulartype;
}
@ -147,4 +140,4 @@ class Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence extends Zend_Soap_Wsdl_Strateg
$this->getContext()->addType($arrayType);
}
}
}
}

View File

@ -15,11 +15,13 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: Composite.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Zend/Soap/Wsdl/Strategy/Interface.php";
class Zend_Soap_Wsdl_Strategy_Composite implements Zend_Soap_Wsdl_Strategy_Interface
{
/**

View File

@ -15,12 +15,12 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: DefaultComplexType.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/
require_once "Abstract.php";
require_once "Zend/Soap/Wsdl/Strategy/Abstract.php";
class Zend_Soap_Wsdl_Strategy_DefaultComplexType extends Zend_Soap_Wsdl_Strategy_Abstract
{

View File

@ -15,9 +15,9 @@
* @category Zend
* @package Zend_Soap
* @subpackage Wsdl
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
* @version $Id: Interface.php 16971 2009-07-22 18:05:45Z mikaelkael $
*/