Added headers in request

You can add @Soap\Header("foobar", phpType="string") in a method definition
This commit is contained in:
Francis Besset
2011-08-14 18:00:28 +02:00
parent a6f8ccbfd2
commit c5902122bb
14 changed files with 256 additions and 112 deletions

View File

@ -43,6 +43,11 @@ class SoapWebServiceController extends ContainerAware
*/
protected $serviceBinder;
/**
* @var array
*/
private $headers = array();
/**
* @return \BeSimple\SoapBundle\Soap\SoapResponse
*/
@ -96,12 +101,14 @@ class SoapWebServiceController extends ContainerAware
*/
public function __call($method, $arguments)
{
if ($this->serviceBinder->isServiceHeader($method)) {
// collect request soap headers
$this->soapRequest->getSoapHeaders()->add(
$this->serviceBinder->processServiceHeader($method, $arguments[0])
);
} elseif ($this->serviceBinder->isServiceMethod($method)) {
if ($this->serviceBinder->isServiceMethod($method)) {
foreach ($this->headers as $name => $value) {
if ($this->serviceBinder->isServiceHeader($method, $name)) {
$this->soapRequest->getSoapHeaders()->add($this->serviceBinder->processServiceHeader($method, $name, $value));
}
}
$this->headers = null;
$this->soapRequest->attributes->add(
$this->serviceBinder->processServiceMethodArguments($method, $arguments)
);
@ -127,9 +134,28 @@ class SoapWebServiceController extends ContainerAware
$method,
$this->soapResponse->getReturnValue()
);
} else {
// collect request soap headers
$this->headers[$method] = $arguments[0];
}
}
/**
* @return \BeSimple\SoapBundle\Soap\SoapRequest
*/
public function getRequest()
{
return $this->soapRequest;
}
/**
* @return \BeSimple\SoapBundle\Soap\SoapResponse
*/
public function getResponse()
{
return $this->soapResponse;
}
/**
* Checks that the given Response is a SoapResponse.
*
@ -148,28 +174,12 @@ class SoapWebServiceController extends ContainerAware
return $response;
}
/**
* @return \BeSimple\SoapBundle\Soap\SoapRequest
*/
public function getRequest()
{
return $this->soapRequest;
}
/**
* @return \BeSimple\SoapBundle\Soap\SoapResponse
*/
public function getResponse()
{
return $this->soapResponse;
}
private function getWebServiceContext($webservice)
{
if(!$this->container->has('besimple.soap.context.'.$webservice))
{
if (!$this->container->has('besimple.soap.context.'.$webservice)) {
throw new NotFoundHttpException(sprintf('No webservice with name "%s" found.', $webservice));
}
return $this->container->get('besimple.soap.context.'.$webservice);
}
}