From 0126cd422193185f8000e7a8b7c9e61147e01388 Mon Sep 17 00:00:00 2001 From: Christian Kerl Date: Sun, 17 Jul 2011 15:01:42 +0200 Subject: [PATCH] some cleanup Conflicts: Controller/SoapWebServiceController.php ServiceBinding/ServiceBinder.php --- Controller/SoapWebServiceController.php | 18 ++++++++++++++---- ServiceBinding/ServiceBinder.php | 10 ++-------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index 0970a18..be8c747 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -15,6 +15,7 @@ use Bundle\WebServiceBundle\Soap\SoapResponse; use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; /** @@ -47,7 +48,7 @@ class SoapWebServiceController extends ContainerAware */ public function callAction($webservice) { - $webServiceContext = $this->container->get('webservice.context.'.$webservice); + $webServiceContext = $this->getWebServiceContext($webservice); $this->serviceBinder = $webServiceContext->getServiceBinder(); $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); @@ -66,7 +67,7 @@ class SoapWebServiceController extends ContainerAware */ public function definitionAction($webservice) { - $webServiceContext = $this->container->get('webservice.context.'.$webservice); + $webServiceContext = $this->getWebServiceContext($webservice); $request = $this->container->get('request'); if ($request->query->has('wsdl') || $request->query->has('WSDL')) { @@ -75,7 +76,7 @@ class SoapWebServiceController extends ContainerAware $response = new Response($webServiceContext->getWsdlFileContent($endpoint)); $response->headers->set('Content-Type', 'application/wsdl+xml'); } else { - // TODO: replace with better represantation + // TODO: replace with better representation $response = new Response($webServiceContext->getWsdlFileContent()); $response->headers->set('Content-Type', 'text/xml'); } @@ -159,4 +160,13 @@ class SoapWebServiceController extends ContainerAware { return $this->soapResponse; } -} \ No newline at end of file + + private function getWebServiceContext($webservice) + { + if(!$this->container->has('webservice.context.'.$webservice)) + { + throw new NotFoundHttpException(sprintf('No webservice with name "%s" found.', $webservice)); + } + return $this->container->get('webservice.context.'.$webservice); + } +} diff --git a/ServiceBinding/ServiceBinder.php b/ServiceBinding/ServiceBinder.php index c2f860b..88c5377 100644 --- a/ServiceBinding/ServiceBinder.php +++ b/ServiceBinding/ServiceBinder.php @@ -32,14 +32,8 @@ class ServiceBinder */ private $responseMessageBinder; - public function __construct( - ServiceDefinition $definition, - MessageBinderInterface $requestMessageBinder, - MessageBinderInterface $responseMessageBinder - ) - { - $this->definition = $definition; - + public function __construct(ServiceDefinition $definition, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) { + $this->definition = $definition; $this->requestMessageBinder = $requestMessageBinder; $this->responseMessageBinder = $responseMessageBinder; }