Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions | Protected Attributes
Zend_Soap_AutoDiscover Class Reference
Inheritance diagram for Zend_Soap_AutoDiscover:
Zend_Server_Interface

Public Member Functions

 __construct ($strategy=true, $uri=null, $wsdlClass=null)
 
 setUri ($uri)
 
 getUri ()
 
 setWsdlClass ($wsdlClass)
 
 getWsdlClass ()
 
 setOperationBodyStyle (array $operationStyle=array())
 
 setBindingStyle (array $bindingStyle=array())
 
 setComplexTypeStrategy ($strategy)
 
 setClass ($class, $namespace='', $argv=null)
 
 addFunction ($function, $namespace='')
 
 fault ($fault=null, $code=null)
 
 handle ($request=false)
 
 dump ($filename)
 
 toXml ()
 
 getFunctions ()
 
 loadFunctions ($definition)
 
 setPersistence ($mode)
 
 getType ($type)
 

Protected Member Functions

 getSchema ()
 
 getHostName ()
 
 getRequestUriWithoutParameters ()
 
 _addFunctionToWsdl ($function, $wsdl, $port, $binding)
 

Protected Attributes

 $_wsdl = null
 
 $_reflection = null
 
 $_functions = array()
 
 $_strategy
 
 $_uri
 
 $_operationBodyStyle = array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
 
 $_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http')
 
 $_wsdlClass = 'Zend_Soap_Wsdl'
 

Detailed Description

Definition at line 51 of file AutoDiscover.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $strategy = true,
  $uri = null,
  $wsdlClass = null 
)

Constructor

Parameters
boolean | string | Zend_Soap_Wsdl_Strategy_Interface$strategy
string | Zend_Uri$uri
string$wsdlClass

Definition at line 108 of file AutoDiscover.php.

109  {
110  $this->_reflection = new Zend_Server_Reflection();
111  $this->setComplexTypeStrategy($strategy);
112 
113  if($uri !== null) {
114  $this->setUri($uri);
115  }
116 
117  if($wsdlClass !== null) {
118  $this->setWsdlClass($wsdlClass);
119  }
120  }
setComplexTypeStrategy($strategy)

Member Function Documentation

◆ _addFunctionToWsdl()

_addFunctionToWsdl (   $function,
  $wsdl,
  $port,
  $binding 
)
protected

Add a function to the WSDL document.

Parameters
Zend_Server_Reflection_Function_Abstract$functionfunction to add
Zend_Soap_Wsdl$wsdlWSDL document
object$portwsdl:portType
object$bindingwsdl:binding
Returns
void

Definition at line 389 of file AutoDiscover.php.

390  {
391  $uri = $this->getUri();
392 
393  // We only support one prototype: the one with the maximum number of arguments
394  $prototype = null;
395  $maxNumArgumentsOfPrototype = -1;
396  foreach ($function->getPrototypes() as $tmpPrototype) {
397  $numParams = count($tmpPrototype->getParameters());
398  if ($numParams > $maxNumArgumentsOfPrototype) {
399  $maxNumArgumentsOfPrototype = $numParams;
400  $prototype = $tmpPrototype;
401  }
402  }
403  if ($prototype === null) {
404  #require_once "Zend/Soap/AutoDiscover/Exception.php";
405  throw new Zend_Soap_AutoDiscover_Exception("No prototypes could be found for the '" . $function->getName() . "' function");
406  }
407 
408  // Add the input message (parameters)
409  $args = array();
410  if ($this->_bindingStyle['style'] == 'document') {
411  // Document style: wrap all parameters in a sequence element
412  $sequence = array();
413  foreach ($prototype->getParameters() as $param) {
414  $sequenceElement = array(
415  'name' => $param->getName(),
416  'type' => $wsdl->getType($param->getType())
417  );
418  if ($param->isOptional()) {
419  $sequenceElement['nillable'] = 'true';
420  }
421  $sequence[] = $sequenceElement;
422  }
423  $element = array(
424  'name' => $function->getName(),
425  'sequence' => $sequence
426  );
427  // Add the wrapper element part, which must be named 'parameters'
428  $args['parameters'] = array('element' => $wsdl->addElement($element));
429  } else {
430  // RPC style: add each parameter as a typed part
431  foreach ($prototype->getParameters() as $param) {
432  $args[$param->getName()] = array('type' => $wsdl->getType($param->getType()));
433  }
434  }
435  $wsdl->addMessage($function->getName() . 'In', $args);
436 
437  $isOneWayMessage = false;
438  if($prototype->getReturnType() == "void") {
439  $isOneWayMessage = true;
440  }
441 
442  if($isOneWayMessage == false) {
443  // Add the output message (return value)
444  $args = array();
445  if ($this->_bindingStyle['style'] == 'document') {
446  // Document style: wrap the return value in a sequence element
447  $sequence = array();
448  if ($prototype->getReturnType() != "void") {
449  $sequence[] = array(
450  'name' => $function->getName() . 'Result',
451  'type' => $wsdl->getType($prototype->getReturnType())
452  );
453  }
454  $element = array(
455  'name' => $function->getName() . 'Response',
456  'sequence' => $sequence
457  );
458  // Add the wrapper element part, which must be named 'parameters'
459  $args['parameters'] = array('element' => $wsdl->addElement($element));
460  } else if ($prototype->getReturnType() != "void") {
461  // RPC style: add the return value as a typed part
462  $args['return'] = array('type' => $wsdl->getType($prototype->getReturnType()));
463  }
464  $wsdl->addMessage($function->getName() . 'Out', $args);
465  }
466 
467  // Add the portType operation
468  if($isOneWayMessage == false) {
469  $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', 'tns:' . $function->getName() . 'Out');
470  } else {
471  $portOperation = $wsdl->addPortOperation($port, $function->getName(), 'tns:' . $function->getName() . 'In', false);
472  }
473  $desc = $function->getDescription();
474  if (strlen($desc) > 0) {
475  $wsdl->addDocumentation($portOperation, $desc);
476  }
477 
478  // When using the RPC style, make sure the operation style includes a 'namespace' attribute (WS-I Basic Profile 1.1 R2717)
479  if ($this->_bindingStyle['style'] == 'rpc' && !isset($this->_operationBodyStyle['namespace'])) {
480  $this->_operationBodyStyle['namespace'] = ''.$uri;
481  }
482 
483  // Add the binding operation
484  if($isOneWayMessage == false) {
485  $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle, $this->_operationBodyStyle);
486  } else {
487  $operation = $wsdl->addBindingOperation($binding, $function->getName(), $this->_operationBodyStyle);
488  }
489  $wsdl->addSoapOperation($operation, $uri . '#' .$function->getName());
490 
491  // Add the function name to the list
492  $this->_functions[] = $function->getName();
493  }
$element
Definition: element.phtml:12

◆ addFunction()

addFunction (   $function,
  $namespace = '' 
)

Add a Single or Multiple Functions to the WSDL

Parameters
string$functionFunction Name
string$namespaceFunction namespace - Not Used
Returns
Zend_Soap_AutoDiscover

Implements Zend_Server_Interface.

Definition at line 342 of file AutoDiscover.php.

343  {
344  static $port;
345  static $operation;
346  static $binding;
347 
348  if (!is_array($function)) {
349  $function = (array) $function;
350  }
351 
352  $uri = $this->getUri();
353 
354  if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) {
355  $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
356  $name = $parts[0];
357  $wsdl = new Zend_Soap_Wsdl($name, $uri, $this->_strategy);
358 
359  // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
360  $wsdl->addSchemaTypeSection();
361 
362  $port = $wsdl->addPortType($name . 'Port');
363  $binding = $wsdl->addBinding($name . 'Binding', 'tns:' .$name. 'Port');
364 
365  $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
366  $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
367  } else {
368  $wsdl = $this->_wsdl;
369  }
370 
371  foreach ($function as $func) {
372  $method = $this->_reflection->reflectFunction($func);
373  $this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
374  }
375  $this->_wsdl = $wsdl;
376 
377  return $this;
378  }
_addFunctionToWsdl($function, $wsdl, $port, $binding)
$method
Definition: info.phtml:13
if(!isset($_GET['name'])) $name
Definition: log.php:14

◆ dump()

dump (   $filename)

Proxy to WSDL dump function

Parameters
string$filename
Returns
boolean
Exceptions
Zend_Soap_AutoDiscover_Exception
See also
Zend_Soap_AutoDiscover_Exception

Definition at line 528 of file AutoDiscover.php.

529  {
530  if($this->_wsdl !== null) {
531  return $this->_wsdl->dump($filename);
532  } else {
536  #require_once "Zend/Soap/AutoDiscover/Exception.php";
537  throw new Zend_Soap_AutoDiscover_Exception("Cannot dump autodiscovered contents, WSDL file has not been generated yet.");
538  }
539  }

◆ fault()

fault (   $fault = null,
  $code = null 
)

Action to take when an error occurs

Parameters
string$fault
string | int$code
Exceptions
Zend_Soap_AutoDiscover_Exception

Implements Zend_Server_Interface.

Definition at line 502 of file AutoDiscover.php.

503  {
504  #require_once "Zend/Soap/AutoDiscover/Exception.php";
505  throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover.");
506  }

◆ getFunctions()

getFunctions ( )

Return an array of functions in the WSDL

Returns
array

Implements Zend_Server_Interface.

Definition at line 565 of file AutoDiscover.php.

566  {
567  return $this->_functions;
568  }

◆ getHostName()

getHostName ( )
protected

Detect and return the current hostname

Returns
string

Definition at line 254 of file AutoDiscover.php.

255  {
256  if(isset($_SERVER['HTTP_HOST'])) {
257  $host = $_SERVER['HTTP_HOST'];
258  } else {
259  $host = $_SERVER['SERVER_NAME'];
260  }
261  return $host;
262  }

◆ getRequestUriWithoutParameters()

getRequestUriWithoutParameters ( )
protected

Detect and return the current script name without parameters

Returns
string

Definition at line 269 of file AutoDiscover.php.

270  {
271  if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { // IIS with Microsoft Rewrite Module
272  $requestUri = $_SERVER['HTTP_X_ORIGINAL_URL'];
273  } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
274  $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
275  } elseif (isset($_SERVER['REQUEST_URI'])) {
276  $requestUri = $_SERVER['REQUEST_URI'];
277  } elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
278  $requestUri = $_SERVER['ORIG_PATH_INFO'];
279  } else {
280  $requestUri = $_SERVER['SCRIPT_NAME'];
281  }
282  if( ($pos = strpos($requestUri, "?")) !== false) {
283  $requestUri = substr($requestUri, 0, $pos);
284  }
285 
286  return $requestUri;
287  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$pos
Definition: list.phtml:42

◆ getSchema()

getSchema ( )
protected

Detect and returns the current HTTP/HTTPS Schema

Returns
string

Definition at line 240 of file AutoDiscover.php.

241  {
242  $schema = "http";
243  if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
244  $schema = 'https';
245  }
246  return $schema;
247  }

◆ getType()

getType (   $type)

Returns an XSD Type for the given PHP type

Parameters
string$typePHP Type to get the XSD type for
Returns
string
Todo:
Exception throwing may be more correct

Definition at line 600 of file AutoDiscover.php.

601  {
602  if (!($this->_wsdl instanceof Zend_Soap_Wsdl)) {
605  // WSDL is not defined yet, so we can't recognize type in context of current service
606  return '';
607  } else {
608  return $this->_wsdl->getType($type);
609  }
610  }
$type
Definition: item.phtml:13

◆ getUri()

getUri ( )

Return the current Uri that the SOAP WSDL Service will be located at.

Returns
Zend_Uri

Definition at line 151 of file AutoDiscover.php.

152  {
153  if($this->_uri !== null) {
154  $uri = $this->_uri;
155  } else {
156  $schema = $this->getSchema();
157  $host = $this->getHostName();
158  $scriptName = $this->getRequestUriWithoutParameters();
159  $uri = Zend_Uri::factory($schema . '://' . $host . $scriptName);
160  $this->setUri($uri);
161  }
162  return $uri;
163  }
static factory($uri='http', $className=null)
Definition: Uri.php:96

◆ getWsdlClass()

getWsdlClass ( )

Return the name of the WSDL handling class.

Returns
string

Definition at line 190 of file AutoDiscover.php.

191  {
192  return $this->_wsdlClass;
193  }

◆ handle()

handle (   $request = false)

Handle the Request

Parameters
string$requestA non-standard request - Not Used

Implements Zend_Server_Interface.

Definition at line 513 of file AutoDiscover.php.

514  {
515  if (!headers_sent()) {
516  header('Content-Type: text/xml');
517  }
518  $this->_wsdl->dump();
519  }

◆ loadFunctions()

loadFunctions (   $definition)

Load Functions

Parameters
unknown_type$definition
Exceptions
Zend_Soap_AutoDiscover_Exception

Implements Zend_Server_Interface.

Definition at line 576 of file AutoDiscover.php.

577  {
578  #require_once "Zend/Soap/AutoDiscover/Exception.php";
579  throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover.");
580  }

◆ setBindingStyle()

setBindingStyle ( array  $bindingStyle = array())

Set Binding soap:binding style.

By default 'style' is 'rpc' and 'transport' is 'http://schemas.xmlsoap.org/soap/http'.

Parameters
array$bindingStyle
Returns
Zend_Soap_AutoDiscover

Definition at line 224 of file AutoDiscover.php.

225  {
226  if(isset($bindingStyle['style'])) {
227  $this->_bindingStyle['style'] = $bindingStyle['style'];
228  }
229  if(isset($bindingStyle['transport'])) {
230  $this->_bindingStyle['transport'] = $bindingStyle['transport'];
231  }
232  return $this;
233  }

◆ setClass()

setClass (   $class,
  $namespace = '',
  $argv = null 
)

Set the Class the SOAP server will use

Parameters
string$classClass Name
string$namespaceClass Namspace - Not Used
array$argvArguments to instantiate the class - Not Used
Returns
Zend_Soap_AutoDiscover

Implements Zend_Server_Interface.

Definition at line 313 of file AutoDiscover.php.

314  {
315  $uri = $this->getUri();
316 
317  $wsdl = new $this->_wsdlClass($class, $uri, $this->_strategy);
318 
319  // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
320  $wsdl->addSchemaTypeSection();
321 
322  $port = $wsdl->addPortType($class . 'Port');
323  $binding = $wsdl->addBinding($class . 'Binding', 'tns:' .$class. 'Port');
324 
325  $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
326  $wsdl->addService($class . 'Service', $class . 'Port', 'tns:' . $class . 'Binding', $uri);
327  foreach ($this->_reflection->reflectClass($class)->getMethods() as $method) {
328  $this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
329  }
330  $this->_wsdl = $wsdl;
331 
332  return $this;
333  }
_addFunctionToWsdl($function, $wsdl, $port, $binding)
$_option $_optionId $class
Definition: date.phtml:13
$method
Definition: info.phtml:13

◆ setComplexTypeStrategy()

setComplexTypeStrategy (   $strategy)

Set the strategy that handles functions and classes that are added AFTER this call.

Parameters
boolean | string | Zend_Soap_Wsdl_Strategy_Interface$strategy
Returns
Zend_Soap_AutoDiscover

Definition at line 295 of file AutoDiscover.php.

296  {
297  $this->_strategy = $strategy;
298  if($this->_wsdl instanceof Zend_Soap_Wsdl) {
299  $this->_wsdl->setComplexTypeStrategy($strategy);
300  }
301 
302  return $this;
303  }

◆ setOperationBodyStyle()

setOperationBodyStyle ( array  $operationStyle = array())

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 also
Zend_Soap_AutoDiscover_Exception
Parameters
array$operationStyle
Returns
Zend_Soap_AutoDiscover
Exceptions
Zend_Soap_AutoDiscover_Exception

Definition at line 206 of file AutoDiscover.php.

207  {
208  if(!isset($operationStyle['use'])) {
209  #require_once "Zend/Soap/AutoDiscover/Exception.php";
210  throw new Zend_Soap_AutoDiscover_Exception("Key 'use' is required in Operation soap:body style.");
211  }
212  $this->_operationBodyStyle = $operationStyle;
213  return $this;
214  }

◆ setPersistence()

setPersistence (   $mode)

Set Persistance

Parameters
int$mode
Exceptions
Zend_Soap_AutoDiscover_Exception

Implements Zend_Server_Interface.

Definition at line 588 of file AutoDiscover.php.

589  {
590  #require_once "Zend/Soap/AutoDiscover/Exception.php";
591  throw new Zend_Soap_AutoDiscover_Exception("Function has no use in AutoDiscover.");
592  }

◆ setUri()

setUri (   $uri)

Set the location at which the WSDL file will be availabe.

See also
Zend_Soap_Exception
Parameters
Zend_Uri | string$uri
Returns
Zend_Soap_AutoDiscover
Exceptions
Zend_Soap_AutoDiscover_Exception

Definition at line 130 of file AutoDiscover.php.

131  {
132  if (!is_string($uri) && !($uri instanceof Zend_Uri)) {
133  #require_once "Zend/Soap/AutoDiscover/Exception.php";
134  throw new Zend_Soap_AutoDiscover_Exception("No uri given to Zend_Soap_AutoDiscover::setUri as string or Zend_Uri instance.");
135  }
136  $this->_uri = $uri;
137 
138  // change uri in WSDL file also if existant
139  if ($this->_wsdl instanceof Zend_Soap_Wsdl) {
140  $this->_wsdl->setUri($uri);
141  }
142 
143  return $this;
144  }

◆ setWsdlClass()

setWsdlClass (   $wsdlClass)

Set the name of the WSDL handling class.

See also
Zend_Soap_Exception
Zend_Soap_Exception
Parameters
string$wsdlClass
Returns
Zend_Soap_AutoDiscover
Exceptions
Zend_Soap_AutoDiscover_Exception

Definition at line 174 of file AutoDiscover.php.

175  {
176  if (!is_string($wsdlClass) && !is_subclass_of($wsdlClass, 'Zend_Soap_Wsdl')) {
177  #require_once "Zend/Soap/AutoDiscover/Exception.php";
178  throw new Zend_Soap_AutoDiscover_Exception("No Zend_Soap_Wsdl subclass given to Zend_Soap_AutoDiscover::setWsdlClass as string.");
179  }
180  $this->_wsdlClass = $wsdlClass;
181 
182  return $this;
183  }
is_subclass_of($obj, $className)

◆ toXml()

toXml ( )

Proxy to WSDL toXml() function

Returns
string
Exceptions
Zend_Soap_AutoDiscover_Exception
See also
Zend_Soap_AutoDiscover_Exception

Definition at line 547 of file AutoDiscover.php.

548  {
549  if($this->_wsdl !== null) {
550  return $this->_wsdl->toXml();
551  } else {
555  #require_once "Zend/Soap/AutoDiscover/Exception.php";
556  throw new Zend_Soap_AutoDiscover_Exception("Cannot return autodiscovered contents, WSDL file has not been generated yet.");
557  }
558  }

Field Documentation

◆ $_bindingStyle

$_bindingStyle = array('style' => 'rpc', 'transport' => 'http://schemas.xmlsoap.org/soap/http')
protected

Definition at line 92 of file AutoDiscover.php.

◆ $_functions

$_functions = array()
protected

Definition at line 66 of file AutoDiscover.php.

◆ $_operationBodyStyle

$_operationBodyStyle = array('use' => 'encoded', 'encodingStyle' => "http://schemas.xmlsoap.org/soap/encoding/")
protected

Definition at line 85 of file AutoDiscover.php.

◆ $_reflection

$_reflection = null
protected

Definition at line 61 of file AutoDiscover.php.

◆ $_strategy

$_strategy
protected

Definition at line 71 of file AutoDiscover.php.

◆ $_uri

$_uri
protected

Definition at line 78 of file AutoDiscover.php.

◆ $_wsdl

$_wsdl = null
protected

Definition at line 56 of file AutoDiscover.php.

◆ $_wsdlClass

$_wsdlClass = 'Zend_Soap_Wsdl'
protected

Definition at line 99 of file AutoDiscover.php.


The documentation for this class was generated from the following file: