-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrited Definition of WebService and WSDL dumper
- Loading branch information
1 parent
e9a8384
commit d60eb19
Showing
9 changed files
with
627 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BeSimpleSoap. | ||
* | ||
* (c) Christian Kerl <[email protected]> | ||
* (c) Francis Besset <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace BeSimple\SoapCommon\Definition; | ||
|
||
use BeSimple\SoapCommon\Definition\Type\TypeRepository; | ||
|
||
/** | ||
* @author Francis Besset <[email protected]> | ||
*/ | ||
class Definition | ||
{ | ||
protected $name; | ||
protected $namespace; | ||
|
||
protected $typeRepository; | ||
|
||
protected $options; | ||
protected $methods; | ||
|
||
public function __construct($name, $namespace, TypeRepository $typeRepository, array $options = array()) | ||
{ | ||
$this->name = $name; | ||
$this->namespace = $namespace; | ||
$this->methods = array(); | ||
|
||
$this->typeRepository = $typeRepository; | ||
|
||
$this->setOptions($options); | ||
} | ||
|
||
public function setOptions(array $options) | ||
{ | ||
$this->options = array( | ||
'version' => \SOAP_1_1, | ||
'style' => \SOAP_RPC, | ||
'use' => \SOAP_LITERAL, | ||
'location' => null, | ||
); | ||
|
||
$invalid = array(); | ||
foreach ($options as $key => $value) { | ||
if (array_key_exists($key, $this->options)) { | ||
$this->options[$key] = $value; | ||
} else { | ||
$invalid[] = $key; | ||
} | ||
} | ||
|
||
if ($invalid) { | ||
throw new \InvalidArgumentException(sprintf('The Definition does not support the following options: "%s"', implode('", "', $invalid))); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
public function setOption($key, $value) | ||
{ | ||
if (!array_key_exists($key, $this->options)) { | ||
throw new \InvalidArgumentException(sprintf('The Definition does not support the "%s" option.', $key)); | ||
} | ||
|
||
$this->options[$key] = $value; | ||
|
||
return $this; | ||
} | ||
|
||
public function getOption($key) | ||
{ | ||
if (!array_key_exists($key, $this->options)) { | ||
throw new \InvalidArgumentException(sprintf('The Definition does not support the "%s" option.', $key)); | ||
} | ||
|
||
return $this->options[$key]; | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getNamespace() | ||
{ | ||
return $this->namespace; | ||
} | ||
|
||
public function getType($phpType) | ||
{ | ||
return $this->types[$phpType]; | ||
} | ||
|
||
public function addType($phpType, $xmlType) | ||
{ | ||
if (isset($$this->types[$phpType])) { | ||
throw new \Exception(); | ||
} | ||
|
||
$this->types[$phpType] = $xmlType; | ||
} | ||
|
||
public function getMessages() | ||
{ | ||
$messages = array(); | ||
foreach ($this->methods as $method) { | ||
$messages[] = $method->getHeaders(); | ||
$messages[] = $method->getInput(); | ||
$messages[] = $method->getOutput(); | ||
} | ||
|
||
return $messages; | ||
} | ||
|
||
public function getMethod($name, $default = null) | ||
{ | ||
return isset($this->methods[$name]) ? $this->methods[$name] : $default; | ||
} | ||
|
||
public function getMethods() | ||
{ | ||
return $this->methods; | ||
} | ||
|
||
public function addMethod(Method $method) | ||
{ | ||
$name = $method->getName(); | ||
if (isset($this->methods[$name])) { | ||
throw new \Exception(sprintf('The method "%s" already exists', $name)); | ||
} | ||
|
||
$this->methods[$name] = $method; | ||
|
||
return $method; | ||
} | ||
|
||
public function getTypeRepository() | ||
{ | ||
return $this->typeRepository; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BeSimpleSoap. | ||
* | ||
* (c) Christian Kerl <[email protected]> | ||
* (c) Francis Besset <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace BeSimple\SoapCommon\Definition; | ||
|
||
use BeSimple\SoapCommon\Definition\Type\TypeInterface; | ||
|
||
/** | ||
* @author Francis Besset <[email protected]> | ||
*/ | ||
class Message | ||
{ | ||
protected $name; | ||
protected $parts; | ||
|
||
public function __construct($name) | ||
{ | ||
$this->name = $name; | ||
$this->parts = array(); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function all() | ||
{ | ||
return $this->parts; | ||
} | ||
|
||
public function get($name, $default = null) | ||
{ | ||
return isset($this->parts[$name]) ? $this->parts[$name] : $default; | ||
} | ||
|
||
public function isEmpty() | ||
{ | ||
return 0 === count($this->parts) ? true : false; | ||
} | ||
|
||
public function add($name, $phpType, $nillable = false) | ||
{ | ||
if ($phpType instanceof TypeInterface) { | ||
$phpType = $phpType->getPhpType(); | ||
} | ||
|
||
$this->parts[$name] = new Part($name, $phpType, $nillable); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BeSimpleSoap. | ||
* | ||
* (c) Christian Kerl <[email protected]> | ||
* (c) Francis Besset <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace BeSimple\SoapCommon\Definition; | ||
|
||
use BeSimple\SoapCommon\Definition\Type\TypeRepository; | ||
|
||
/** | ||
* @author Francis Besset <[email protected]> | ||
*/ | ||
class Method | ||
{ | ||
private $name; | ||
|
||
private $headers; | ||
private $input; | ||
private $output; | ||
private $fault; | ||
|
||
public function __construct($name, TypeRepository $typeRepository) | ||
{ | ||
$this->name = $name; | ||
|
||
$this->headers = new Message($name.'Header', $typeRepository); | ||
$this->input = new Message($name.'Request', $typeRepository); | ||
$this->output = new Message($name.'Response', $typeRepository); | ||
$this->fault = new Message($name.'Fault', $typeRepository); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getDefinition() | ||
{ | ||
return $this->definition; | ||
} | ||
|
||
public function getVersions() | ||
{ | ||
return array(\SOAP_1_1, \SOAP_1_2); | ||
} | ||
|
||
public function getUse() | ||
{ | ||
return \SOAP_LITERAL; | ||
} | ||
|
||
public function addHeader($name, $type) | ||
{ | ||
$this->headers->add($name, $type); | ||
} | ||
|
||
public function addInput($name, $type) | ||
{ | ||
$this->input->add($name, $type); | ||
} | ||
|
||
public function setOutput($type) | ||
{ | ||
$this->output->add('return', $type); | ||
} | ||
|
||
public function getHeaders() | ||
{ | ||
return $this->headers; | ||
} | ||
|
||
public function getHeader($name, $default = null) | ||
{ | ||
return $this->headers->get($name, $default); | ||
} | ||
|
||
public function getInput() | ||
{ | ||
return $this->input; | ||
} | ||
|
||
public function getOutput() | ||
{ | ||
return $this->output; | ||
} | ||
|
||
public function getFault() | ||
{ | ||
return $this->fault; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BeSimpleSoap. | ||
* | ||
* (c) Christian Kerl <[email protected]> | ||
* (c) Francis Besset <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace BeSimple\SoapCommon\Definition; | ||
|
||
/** | ||
* @author Francis Besset <[email protected]> | ||
*/ | ||
class Part | ||
{ | ||
protected $name; | ||
protected $type; | ||
protected $nillable; | ||
|
||
public function __construct($name, $type, $nillable = false) | ||
{ | ||
$this->name = $name; | ||
$this->type = $type; | ||
$this->setNillable($nillable); | ||
} | ||
|
||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function getType() | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function setType($type) | ||
{ | ||
$this->type = $type; | ||
} | ||
|
||
public function isNillable() | ||
{ | ||
return $this->nillable; | ||
} | ||
|
||
public function setNillable($nillable) | ||
{ | ||
$this->nillable = (boolean) $nillable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the BeSimpleSoap. | ||
* | ||
* (c) Christian Kerl <[email protected]> | ||
* (c) Francis Besset <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace BeSimple\SoapCommon\Definition\Type; | ||
|
||
/** | ||
* @author Francis Besset <[email protected]> | ||
*/ | ||
class ArrayOfType extends ComplexType | ||
{ | ||
public function __construct($phpType, $arrayOf, $xmlTypeOf) | ||
{ | ||
if ($arrayOf instanceof TypeInterface) { | ||
$arrayOf = $arrayOf->getPhpType(); | ||
} | ||
|
||
parent::__construct($phpType, 'ArrayOf'.ucfirst($xmlTypeOf ?: $arrayOf)); | ||
|
||
$this->add('item', $arrayOf); | ||
} | ||
} |
Oops, something went wrong.