parent
cc83e1e6db
commit
aa0b750f47
|
@ -19,7 +19,6 @@ use BeSimple\SoapBundle\WebServiceContext;
|
||||||
use BeSimple\SoapServer\SoapServerBuilder;
|
use BeSimple\SoapServer\SoapServerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Debug\Exception\FlattenException;
|
use Symfony\Component\Debug\Exception\FlattenException;
|
||||||
|
@ -59,7 +58,7 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $headers = array();
|
private $headers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \BeSimple\SoapBundle\Soap\SoapResponse
|
* @return \BeSimple\SoapBundle\Soap\SoapResponse
|
||||||
|
@ -67,12 +66,12 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
public function callAction($webservice)
|
public function callAction($webservice)
|
||||||
{
|
{
|
||||||
/** @var WebServiceContext $webServiceContext */
|
/** @var WebServiceContext $webServiceContext */
|
||||||
$webServiceContext = $this->getWebServiceContext($webservice);
|
$webServiceContext = $this->getWebServiceContext($webservice);
|
||||||
|
|
||||||
$this->serviceBinder = $webServiceContext->getServiceBinder();
|
$this->serviceBinder = $webServiceContext->getServiceBinder();
|
||||||
|
|
||||||
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest());
|
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest());
|
||||||
$this->soapServer = $webServiceContext
|
$this->soapServer = $webServiceContext
|
||||||
->getServerBuilder()
|
->getServerBuilder()
|
||||||
->withSoapVersion11()
|
->withSoapVersion11()
|
||||||
->withHandler($this)
|
->withHandler($this)
|
||||||
|
@ -96,14 +95,14 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
$routeName = $webservice . '_webservice_call';
|
$routeName = $webservice . '_webservice_call';
|
||||||
$result = $this->container->get('router')->getRouteCollection()->get($routeName);
|
$result = $this->container->get('router')->getRouteCollection()->get($routeName);
|
||||||
if ($result === null) {
|
if (null === $result) {
|
||||||
$routeName = '_webservice_call';
|
$routeName = '_webservice_call';
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
|
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
|
||||||
$this->container->get('router')->generate(
|
$this->container->get('router')->generate(
|
||||||
$routeName,
|
$routeName,
|
||||||
array('webservice' => $webservice),
|
['webservice' => $webservice],
|
||||||
UrlGeneratorInterface::ABSOLUTE_URL
|
UrlGeneratorInterface::ABSOLUTE_URL
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
@ -135,14 +134,14 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e);
|
throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
|
$view = '@Twig/Exception/' . ($this->container->get('kernel')->isDebug() ? 'exception' : 'error') . '.txt.twig';
|
||||||
$code = $exception->getStatusCode();
|
$code = $exception->getStatusCode();
|
||||||
$details = $this->container->get('twig')->render($view, array(
|
$details = $this->container->get('twig')->render($view, [
|
||||||
'status_code' => $code,
|
'status_code' => $code,
|
||||||
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||||
'exception' => $exception,
|
'exception' => $exception,
|
||||||
'logger' => $logger,
|
'logger' => $logger,
|
||||||
));
|
]);
|
||||||
|
|
||||||
$handler = new ExceptionHandler($exception, $details);
|
$handler = new ExceptionHandler($exception, $details);
|
||||||
if ($soapFault = $request->query->get('_besimple_soap_fault')) {
|
if ($soapFault = $request->query->get('_besimple_soap_fault')) {
|
||||||
|
@ -153,7 +152,7 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$server = SoapServerBuilder::createWithDefaults()
|
$server = SoapServerBuilder::createWithDefaults()
|
||||||
->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl')
|
->withWsdl(__DIR__ . '/../Handler/wsdl/exception.wsdl')
|
||||||
->withWsdlCacheNone()
|
->withWsdlCacheNone()
|
||||||
->withHandler($handler)
|
->withHandler($handler)
|
||||||
->build()
|
->build()
|
||||||
|
@ -161,11 +160,11 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
$server->handle(
|
$server->handle(
|
||||||
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://besim.pl/soap/exception/1.0/">'.
|
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://besim.pl/soap/exception/1.0/">' .
|
||||||
'<soapenv:Header/>'.
|
'<soapenv:Header/>' .
|
||||||
'<soapenv:Body>'.
|
'<soapenv:Body>' .
|
||||||
'<ns:exception />'.
|
'<ns:exception />' .
|
||||||
'</soapenv:Body>'.
|
'</soapenv:Body>' .
|
||||||
'</soapenv:Envelope>'
|
'</soapenv:Envelope>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -176,8 +175,8 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
* This method gets called once for every SOAP header the \SoapServer received
|
* This method gets called once for every SOAP header the \SoapServer received
|
||||||
* and afterwards once for the called SOAP operation.
|
* and afterwards once for the called SOAP operation.
|
||||||
*
|
*
|
||||||
* @param string $method The SOAP header or SOAP operation name
|
* @param string $method The SOAP header or SOAP operation name
|
||||||
* @param array $arguments
|
* @param array $arguments
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -234,7 +233,7 @@ class SoapWebServiceController implements ContainerAwareInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the SoapResponse
|
* Set the SoapResponse.
|
||||||
*
|
*
|
||||||
* @param Response $response A response to check and set
|
* @param Response $response A response to check and set
|
||||||
*
|
*
|
||||||
|
|
|
@ -55,8 +55,7 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
$isArray = true;
|
$isArray = true;
|
||||||
$array = array();
|
$array = array();
|
||||||
|
|
||||||
$phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2);
|
$type = $this->typeRepository->getType($type->get('item')->getType());
|
||||||
$type = $this->typeRepository->getType($phpType);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// @TODO Fix array reference
|
// @TODO Fix array reference
|
||||||
|
@ -79,21 +78,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
$array = $assocArray;
|
$array = $assocArray;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_array($message)) {
|
|
||||||
foreach ($message as $complexType) {
|
|
||||||
$array[] = $this->checkComplexType($phpType, $complexType);
|
|
||||||
}
|
|
||||||
|
|
||||||
// See https://github.com/BeSimple/BeSimpleSoapBundle/issues/29
|
|
||||||
if (in_array('BeSimple\SoapCommon\Type\AbstractKeyValue', class_parents($phpType))) {
|
|
||||||
$assocArray = array();
|
|
||||||
foreach ($array as $keyValue) {
|
|
||||||
$assocArray[$keyValue->getKey()] = $keyValue->getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
$array = $assocArray;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$message = $array;
|
$message = $array;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,7 +18,6 @@ class ComplexType extends Configuration
|
||||||
private $name;
|
private $name;
|
||||||
private $value;
|
private $value;
|
||||||
private $isNillable = false;
|
private $isNillable = false;
|
||||||
private $isAttribute = false;
|
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
|
@ -60,26 +59,6 @@ class ComplexType extends Configuration
|
||||||
$this->isNillable = (bool) $isNillable;
|
$this->isNillable = (bool) $isNillable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAttribute()
|
|
||||||
{
|
|
||||||
return $this->isAttribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $isAttribute
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setIsAttribute($isAttribute)
|
|
||||||
{
|
|
||||||
$this->isAttribute = $isAttribute;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAliasName()
|
public function getAliasName()
|
||||||
{
|
{
|
||||||
return 'complextype';
|
return 'complextype';
|
||||||
|
|
|
@ -20,7 +20,6 @@ class ComplexType
|
||||||
private $name;
|
private $name;
|
||||||
private $value;
|
private $value;
|
||||||
private $isNillable = false;
|
private $isNillable = false;
|
||||||
private $isAttribute = false;
|
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
|
@ -47,26 +46,6 @@ class ComplexType
|
||||||
$this->value = $value;
|
$this->value = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAttribute()
|
|
||||||
{
|
|
||||||
return $this->isAttribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $isAttribute
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setIsAttribute($isAttribute)
|
|
||||||
{
|
|
||||||
$this->isAttribute = $isAttribute;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setNillable($isNillable)
|
public function setNillable($isNillable)
|
||||||
{
|
{
|
||||||
$this->isNillable = (bool) $isNillable;
|
$this->isNillable = (bool) $isNillable;
|
||||||
|
|
|
@ -160,7 +160,7 @@ class AnnotationClassLoader extends Loader
|
||||||
$loaded = $complexTypeResolver->load($phpType);
|
$loaded = $complexTypeResolver->load($phpType);
|
||||||
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
|
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
|
||||||
foreach ($loaded['properties'] as $name => $property) {
|
foreach ($loaded['properties'] as $name => $property) {
|
||||||
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->isAttribute());
|
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->typeRepository->addComplexType($complexType);
|
$this->typeRepository->addComplexType($complexType);
|
||||||
|
|
|
@ -58,7 +58,6 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
||||||
$propertyComplexType = new ComplexType();
|
$propertyComplexType = new ComplexType();
|
||||||
$propertyComplexType->setValue($complexType->getValue());
|
$propertyComplexType->setValue($complexType->getValue());
|
||||||
$propertyComplexType->setNillable($complexType->isNillable());
|
$propertyComplexType->setNillable($complexType->isNillable());
|
||||||
$propertyComplexType->setIsAttribute($complexType->isAttribute());
|
|
||||||
$propertyComplexType->setName($property->getName());
|
$propertyComplexType->setName($property->getName());
|
||||||
$annotations['properties']->add($propertyComplexType);
|
$annotations['properties']->add($propertyComplexType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,10 +79,7 @@ class WebServiceContext
|
||||||
}
|
}
|
||||||
|
|
||||||
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
|
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
|
||||||
|
$cache->write($dumper->dump());
|
||||||
$wsdl = $dumper->dump();
|
|
||||||
|
|
||||||
$cache->write($wsdl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $cache->getPath();
|
return $cache->getPath();
|
||||||
|
|
|
@ -48,13 +48,13 @@ class Message
|
||||||
return 0 === count($this->parts) ? true : false;
|
return 0 === count($this->parts) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($name, $phpType, $nillable = false, $attribute = false)
|
public function add($name, $phpType, $nillable = false)
|
||||||
{
|
{
|
||||||
if ($phpType instanceof TypeInterface) {
|
if ($phpType instanceof TypeInterface) {
|
||||||
$phpType = $phpType->getPhpType();
|
$phpType = $phpType->getPhpType();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parts[$name] = new Part($name, $phpType, $nillable, $attribute);
|
$this->parts[$name] = new Part($name, $phpType, $nillable);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,12 @@ class Part
|
||||||
protected $name;
|
protected $name;
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $nillable;
|
protected $nillable;
|
||||||
protected $attribute;
|
|
||||||
|
|
||||||
public function __construct($name, $type, $nillable = false, $attribute = false)
|
public function __construct($name, $type, $nillable = false)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->setNillable($nillable);
|
$this->setNillable($nillable);
|
||||||
$this->setAttribute($attribute);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
|
@ -35,26 +33,6 @@ class Part
|
||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function isAttribute()
|
|
||||||
{
|
|
||||||
return $this->attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param bool $attribute
|
|
||||||
*
|
|
||||||
* @return $this
|
|
||||||
*/
|
|
||||||
public function setAttribute($attribute)
|
|
||||||
{
|
|
||||||
$this->attribute = $attribute;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getType()
|
public function getType()
|
||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
|
|
|
@ -217,13 +217,11 @@ class Dumper
|
||||||
|
|
||||||
protected function addComplexTypes()
|
protected function addComplexTypes()
|
||||||
{
|
{
|
||||||
$types = $this->document->createElement(static::WSDL_NS . ':types');
|
$types = $this->document->createElement('types');
|
||||||
$this->domDefinitions->appendChild($types);
|
$this->domDefinitions->appendChild($types);
|
||||||
|
|
||||||
$this->domSchema = $this->document->createElement(static::XSD_NS.':schema');
|
$this->domSchema = $this->document->createElement(static::XSD_NS.':schema');
|
||||||
$this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace());
|
$this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace());
|
||||||
$this->domSchema->setAttribute('elementFormDefault', 'unqualified');
|
|
||||||
$this->domSchema->setAttribute(static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI);
|
|
||||||
$types->appendChild($this->domSchema);
|
$types->appendChild($this->domSchema);
|
||||||
|
|
||||||
foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) {
|
foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) {
|
||||||
|
@ -238,18 +236,13 @@ class Dumper
|
||||||
$complexType = $this->document->createElement(static::XSD_NS.':complexType');
|
$complexType = $this->document->createElement(static::XSD_NS.':complexType');
|
||||||
$complexType->setAttribute('name', $type->getXmlType());
|
$complexType->setAttribute('name', $type->getXmlType());
|
||||||
|
|
||||||
$all = $this->document->createElement(static::XSD_NS.':'.'sequence');
|
$all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all'));
|
||||||
$complexType->appendChild($all);
|
$complexType->appendChild($all);
|
||||||
|
|
||||||
foreach ($type->all() as $child) {
|
foreach ($type->all() as $child) {
|
||||||
$isArray = false;
|
|
||||||
$childType = $this->definition->getTypeRepository()->getType($child->getType());
|
$childType = $this->definition->getTypeRepository()->getType($child->getType());
|
||||||
|
|
||||||
if ($child->isAttribute()) {
|
$element = $this->document->createElement(static::XSD_NS.':element');
|
||||||
$element = $this->document->createElement(static::XSD_NS.':attribute');
|
|
||||||
} else {
|
|
||||||
$element = $this->document->createElement(static::XSD_NS.':element');
|
|
||||||
}
|
|
||||||
$element->setAttribute('name', $child->getName());
|
$element->setAttribute('name', $child->getName());
|
||||||
|
|
||||||
if ($childType instanceof ComplexType) {
|
if ($childType instanceof ComplexType) {
|
||||||
|
@ -269,18 +262,14 @@ class Dumper
|
||||||
$element->setAttribute('minOccurs', 1);
|
$element->setAttribute('minOccurs', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type instanceof ArrayOfType || $isArray) {
|
if ($type instanceof ArrayOfType) {
|
||||||
$element->setAttribute('minOccurs', 0);
|
$element->setAttribute('minOccurs', 0);
|
||||||
$element->setAttribute('maxOccurs', 'unbounded');
|
$element->setAttribute('maxOccurs', 'unbounded');
|
||||||
} else {
|
} else {
|
||||||
$element->setAttribute('maxOccurs', 1);
|
$element->setAttribute('maxOccurs', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($child->isAttribute()) {
|
$all->appendChild($element);
|
||||||
$complexType->appendChild($element);
|
|
||||||
} else {
|
|
||||||
$all->appendChild($element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->domSchema->appendChild($complexType);
|
$this->domSchema->appendChild($complexType);
|
||||||
|
|
Loading…
Reference in New Issue