2011-08-14 18:00:28 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
|
|
|
*
|
|
|
|
* (c) Christian Kerl <christian-kerl@web.de>
|
|
|
|
*
|
|
|
|
* This source file is subject to the MIT license that is bundled
|
|
|
|
* with this source code in the file LICENSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
|
|
|
|
|
2011-08-26 23:39:43 +02:00
|
|
|
use BeSimple\SoapBundle\Converter\TypeRepository;
|
|
|
|
use BeSimple\SoapBundle\ServiceDefinition\Type;
|
2011-08-14 18:00:28 +02:00
|
|
|
use Zend\Soap\Wsdl as BaseWsdl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Francis Besset <francis.besset@gmail.com>
|
|
|
|
*/
|
|
|
|
class Wsdl extends BaseWsdl
|
|
|
|
{
|
2011-08-26 23:39:43 +02:00
|
|
|
private $typeRepository;
|
|
|
|
|
|
|
|
public function __construct(TypeRepository $typeRepository, $name, $uri, $strategy = true)
|
|
|
|
{
|
|
|
|
$this->typeRepository = $typeRepository;
|
|
|
|
|
|
|
|
parent::__construct($name, $uri, $strategy);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType($type)
|
|
|
|
{
|
|
|
|
if ($type instanceof Type) {
|
|
|
|
$xmlType = $type->getXmlType();
|
|
|
|
} else {
|
|
|
|
$xmlType = $this->typeRepository->getXmlTypeMapping($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $xmlType ?: $this->addComplexType($type);
|
|
|
|
}
|
|
|
|
|
2013-02-27 17:04:44 +01:00
|
|
|
/**
|
|
|
|
* Translate PHP type into WSDL QName
|
|
|
|
*
|
|
|
|
* @param string $type
|
|
|
|
* @return string QName
|
|
|
|
*/
|
|
|
|
public function translateType($type)
|
|
|
|
{
|
|
|
|
if (isset($this->classMap[$type])) {
|
|
|
|
return $this->classMap[$type];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($type[0] == '\\') {
|
|
|
|
$type = substr($type, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return str_replace('\\', '.', $type);
|
|
|
|
}
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function addBindingOperationHeader(\DOMElement $bindingOperation, array $headers, array $baseBinding)
|
|
|
|
{
|
|
|
|
foreach ($headers as $header) {
|
|
|
|
$inputNode = $bindingOperation->getElementsByTagName('input')->item(0);
|
|
|
|
|
|
|
|
$headerNode = $this->toDomDocument()->createElement('soap:header');
|
|
|
|
$headerNode->setAttribute('part', $header);
|
|
|
|
|
|
|
|
foreach ($baseBinding as $name => $value) {
|
|
|
|
$headerNode->setAttribute($name, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
$inputNode->appendChild($headerNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $bindingOperation;
|
|
|
|
}
|
|
|
|
}
|