2010-10-08 14:24:42 +02:00
|
|
|
<?php
|
2010-10-08 17:01:27 +02:00
|
|
|
/*
|
2011-07-18 22:43:12 +02:00
|
|
|
* This file is part of the BeSimpleSoapBundle.
|
2010-10-08 17:01:27 +02:00
|
|
|
*
|
|
|
|
* (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.
|
|
|
|
*/
|
2010-10-08 14:24:42 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
namespace BeSimple\SoapBundle\ServiceBinding;
|
2010-10-08 14:24:42 +02:00
|
|
|
|
2011-07-18 22:43:12 +02:00
|
|
|
use BeSimple\SoapBundle\ServiceDefinition\Header;
|
|
|
|
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
|
|
|
|
use BeSimple\SoapBundle\Soap\SoapHeader;
|
|
|
|
use BeSimple\SoapBundle\Util\QName;
|
2010-10-08 14:24:42 +02:00
|
|
|
|
2011-07-24 11:31:15 +02:00
|
|
|
/**
|
|
|
|
* @author Christian Kerl <christian-kerl@web.de>
|
|
|
|
*/
|
2010-10-08 14:24:42 +02:00
|
|
|
class ServiceBinder
|
|
|
|
{
|
|
|
|
/**
|
2011-07-18 22:43:12 +02:00
|
|
|
* @var \BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition
|
2010-10-08 14:24:42 +02:00
|
|
|
*/
|
|
|
|
private $definition;
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
/**
|
|
|
|
* @var \BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface
|
|
|
|
*/
|
|
|
|
private $requestHeaderMessageBinder;
|
|
|
|
|
2010-10-08 14:24:42 +02:00
|
|
|
/**
|
2011-07-18 22:43:12 +02:00
|
|
|
* @var \BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface
|
2010-10-08 14:24:42 +02:00
|
|
|
*/
|
|
|
|
private $requestMessageBinder;
|
|
|
|
|
|
|
|
/**
|
2011-07-18 22:43:12 +02:00
|
|
|
* @var \BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface
|
2010-10-08 14:24:42 +02:00
|
|
|
*/
|
|
|
|
private $responseMessageBinder;
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function __construct(ServiceDefinition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) {
|
|
|
|
$this->definition = $definition;
|
|
|
|
|
|
|
|
$this->requestHeaderMessageBinder = $requestHeaderMessageBinder;
|
|
|
|
$this->requestMessageBinder = $requestMessageBinder;
|
|
|
|
|
2010-10-08 14:24:42 +02:00
|
|
|
$this->responseMessageBinder = $responseMessageBinder;
|
|
|
|
}
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function isServiceHeader($method, $header)
|
2010-10-08 14:24:42 +02:00
|
|
|
{
|
2011-08-14 18:00:28 +02:00
|
|
|
return $this->definition->getMethods()->get($method)->getHeaders()->has($header);
|
2010-10-08 14:24:42 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function isServiceMethod($method)
|
2010-10-08 14:24:42 +02:00
|
|
|
{
|
2011-08-14 18:00:28 +02:00
|
|
|
return $this->definition->getMethods()->has($method);
|
2010-10-08 14:24:42 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function processServiceHeader($method, $header, $data)
|
2010-10-08 14:24:42 +02:00
|
|
|
{
|
2011-08-14 18:00:28 +02:00
|
|
|
$methodDefinition = $this->definition->getMethods()->get($method);
|
|
|
|
$headerDefinition = $methodDefinition->getHeaders()->get($header);
|
|
|
|
|
|
|
|
$this->requestHeaderMessageBinder->setHeader($header);
|
|
|
|
$data = $this->requestHeaderMessageBinder->processMessage($methodDefinition, $data, $this->definition->getDefinitionComplexTypes());
|
2010-10-08 14:24:42 +02:00
|
|
|
|
2011-09-01 19:40:44 +02:00
|
|
|
return new SoapHeader($this->definition->getNamespace(), $headerDefinition->getName(), $data);
|
2010-10-08 14:24:42 +02:00
|
|
|
}
|
|
|
|
|
2011-08-14 18:00:28 +02:00
|
|
|
public function processServiceMethodArguments($method, $arguments)
|
2010-10-08 14:24:42 +02:00
|
|
|
{
|
2011-08-14 18:00:28 +02:00
|
|
|
$methodDefinition = $this->definition->getMethods()->get($method);
|
2010-10-08 14:24:42 +02:00
|
|
|
|
2011-08-11 23:55:46 +02:00
|
|
|
return array_merge(
|
|
|
|
array('_controller' => $methodDefinition->getController()),
|
|
|
|
$this->requestMessageBinder->processMessage($methodDefinition, $arguments, $this->definition->getDefinitionComplexTypes())
|
|
|
|
);
|
2010-10-08 14:24:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function processServiceMethodReturnValue($name, $return)
|
|
|
|
{
|
|
|
|
$methodDefinition = $this->definition->getMethods()->get($name);
|
|
|
|
|
2011-07-23 20:06:42 +02:00
|
|
|
return $this->responseMessageBinder->processMessage($methodDefinition, $return, $this->definition->getDefinitionComplexTypes());
|
2010-10-08 14:24:42 +02:00
|
|
|
}
|
|
|
|
}
|