title: Web Service call does not work in prod environment in Symfony2
body: <p>I have developed a WebService in Symfony2 framework. It works perfectly in DEV environment in either my local PC and in my hosting server (both have PHP version 5.3.8), but in PROD environment only works in my local PC, not in my hosting.</p>
  
  <p>This is the WebService controller:</p>
  
  <pre><code>&lt;?php
  
  namespace Desytec\ServiciosBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  use Symfony\Component\HttpFoundation\Response;
  use Desytec\ServiciosBundle\Services\SoapDiscovery;
  
  class FeriadosController extends Controller {
  
      /**
       * @Route("/feriados")
       */
      public function indexAction() {
          $response = new Response();
          $response-&gt;headers-&gt;set('Content-Type', 'text/xml; charset=UTF-8');
  
          $request = $this-&gt;getRequest();
          if (strcasecmp($request-&gt;getQueryString(), 'wsdl') == 0) {
              // Crea el servidor de descubrimiento
              $disco = new SoapDiscovery($request, 'Desytec\ServiciosBundle\Services\FeriadosService', 'Desytec_Feriados');
              $response-&gt;setContent($disco-&gt;getWSDL());
          } else {
              $server = new \SoapServer('http://' . $request-&gt;getHttpHost() . $request-&gt;getScriptName() . $request-&gt;getPathInfo() . '?wsdl');
              $server-&gt;setObject($this-&gt;get('feriados_service'));
              ob_start();
              $server-&gt;handle();
              if (ob_get_length() &gt; 0) {
                  $response-&gt;setContent(ob_get_clean());
              }
          }
          return $response;
      }
  
      /**
       * @Route("/testing")
       * @Template()
       */
      public function testingAction() {
  
          //date_default_timezone_set('America/Santiago');
          //$fecha = new \DateTime();
          //echo sha1(sha1('761463993'.$fecha-&gt;format('YmdHisu'))).'&lt;br /&gt;';
  
          $client = new \SoapClient('http://' . $this-&gt;getRequest()-&gt;getHttpHost() . '/feriados?wsdl');
  
          var_dump($client-&gt;__getFunctions());        $client = new \SoapClient('http://' . $this-&gt;getRequest()-&gt;getHttpHost() . $this-&gt;getRequest()-&gt;getScriptName() . '/feriados?wsdl');
  
          $result = $client-&gt;IsHoliday('8cd4c502f69b5606a8bef291deaac1ba83bb7727', 'cl', 2013, 6, 29);
  
          if ($result)
              echo 'Es feriado';
          else
              echo 'No es feriado';
  
          $feriados = $client-&gt;GetHolidays('8cd4c502f69b5606a8bef291deaac1ba83bb7727', 'cl', 2013, 6);
          var_dump($feriados);
  
          $numero_dias = $client-&gt;GetDateDifference('8cd4c502f69b5606a8bef291deaac1ba83bb7727', 'cl', '2013-08-01', '2013-08-31');
          echo $numero_dias;
  
          $diferencias = $client-&gt;GetDatesDifference('8cd4c502f69b5606a8bef291deaac1ba83bb7727', 'cl', '2013-08-01;2013-09-01', '2013-08-31;2013-09-30');
          var_dump($diferencias);
  
          return array();
      }
  
  }
  </code></pre>
  
  <p>indexAction is the WebService. The testingAction is an action to make some calls to it.</p>
  
  <p>The class that discovers the WSDL is:</p>
  
  <pre><code>&lt;?php
  
  /**
   * Copyright (c) 2005, Braulio José Solano Rojas
   * All rights reserved.
   *
   * Redistribution and use in source and binary forms, with or without modification, are
   * permitted provided that the following conditions are met:
   *
   *  Redistributions of source code must retain the above copyright notice, this list of
   *  conditions and the following disclaimer.
   *  Redistributions in binary form must reproduce the above copyright notice, this list of
   *  conditions and the following disclaimer in the documentation and/or other materials
   *  provided with the distribution.
   *  Neither the name of the Solsoft de Costa Rica S.A. nor the names of its contributors may
   *  be used to endorse or promote products derived from this software without specific
   *  prior written permission.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
   * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
   * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   *
   * @version $Id$
   * @copyright 2005
   */
  
  namespace Desytec\ServiciosBundle\Services;
  
  /**
   * SoapDiscovery Class that provides Web Service Definition Language (WSDL).
   *
   * @package SoapDiscovery
   * @author Braulio Jos� Solano Rojas
   * @copyright Copyright (c) 2005 Braulio José Solano Rojas
   * @version $Id$
   * @access public
   * */
  class SoapDiscovery {
  
      private $class_name = '';
      private $service_name = '';
      private $request;
  
      /**
       * SoapDiscovery::__construct() SoapDiscovery class Constructor.
       *
       * @param string $class_name
       * @param string $service_name
       * */
      public function __construct($request, $class_name = '', $service_name = '') {
          $this-&gt;request = $request;
          $this-&gt;class_name = $class_name;
          $this-&gt;service_name = $service_name;
      }
  
      /**
       * SoapDiscovery::getWSDL() Returns the WSDL of a class if the class is instantiable.
       *
       * @return string
       * */
      public function getWSDL() {
          if (empty($this-&gt;service_name)) {
              throw new Exception('No service name.');
          }
          $headerWSDL = "&lt;?xml version=\"1.0\" ?&gt;\n";
          $headerWSDL .= "&lt;definitions xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"
                          xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
                          xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
                          xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\"
                          xmlns:tns=\"urn:$this-&gt;service_name\"
                          xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"
                          xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\"
                          xmlns=\"http://schemas.xmlsoap.org/wsdl/\"
                          targetNamespace=\"urn:$this-&gt;service_name\"&gt;";
          //$headerWSDL.= "&lt;definitions name=\"$this-&gt;service_name\" targetNamespace=\"urn:$this-&gt;service_name\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:tns=\"urn:$this-&gt;service_name\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\"&gt;\n";
          $headerWSDL.= "&lt;types&gt;
                             &lt;xsd:schema targetNamespace=\"urn:$this-&gt;service_name\"&gt;
                                 &lt;xsd:import namespace=\"http://schemas.xmlsoap.org/soap/encoding/\" /&gt;
                                 &lt;xsd:import namespace=\"http://schemas.xmlsoap.org/wsdl/\" /&gt;
                             &lt;/xsd:schema&gt;
                             {{complexTypes}}
                         &lt;/types&gt;\n";
  
          if (empty($this-&gt;class_name)) {
              throw new Exception('No class name.');
          }
  
          $class = new \ReflectionClass($this-&gt;class_name);
  
          if (!$class-&gt;isInstantiable()) {
              throw new Exception('Class is not instantiable.');
          }
  
          $methods = $class-&gt;getMethods();
          $portTypeWSDL = "\n&lt;!-- Ports --&gt;\n" . '&lt;portType name="' . $this-&gt;service_name . 'Port"&gt;';
          $bindingWSDL = "\n&lt;!-- SOAP Bindings --&gt;\n" . '&lt;binding name="' . $this-&gt;service_name . 'Binding" type="tns:' . $this-&gt;service_name . "Port\"&gt;\n&lt;soap:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\" /&gt;\n";
          $serviceWSDL = "\n&lt;!-- Service (location) --&gt;\n" . '&lt;service name="' . $this-&gt;service_name . "\"&gt;\n&lt;documentation /&gt;\n&lt;port name=\"" . $this-&gt;service_name . 'Port" binding="tns:' . $this-&gt;service_name . "Binding\"&gt;&lt;soap:address location=\"http://" . $this-&gt;request-&gt;getHttpHost() . $this-&gt;request-&gt;getScriptName() . $this-&gt;request-&gt;getPathInfo() . "\" /&gt;\n&lt;/port&gt;\n&lt;/service&gt;\n";
          $messageWSDL = "\n&lt;!-- Messages --&gt;\n";
          $complexType = '';
          foreach ($methods as $method) {
              if ($method-&gt;isPublic() &amp;&amp; !$method-&gt;isConstructor()) {
                  $portTypeWSDL.= '&lt;operation name="' . $method-&gt;getName() . "\"&gt;\n" . '&lt;input message="tns:' . $method-&gt;getName() . "Request\" /&gt;\n&lt;output message=\"tns:" . $method-&gt;getName() . "Response\" /&gt;\n&lt;/operation&gt;\n";
                  $bindingWSDL.= '&lt;operation name="' . $method-&gt;getName() . "\"&gt;\n" . '&lt;soap:operation soapAction="urn:' . $this-&gt;service_name . '#' . $this-&gt;class_name . '#' . $method-&gt;getName() . "\" /&gt;\n&lt;input&gt;&lt;soap:body use=\"encoded\" namespace=\"urn:$this-&gt;service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" /&gt;\n&lt;/input&gt;\n&lt;output&gt;\n&lt;soap:body use=\"encoded\" namespace=\"urn:$this-&gt;service_name\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\" /&gt;\n&lt;/output&gt;\n&lt;/operation&gt;\n";
                  $messageWSDL.= "&lt;!-- Input parameters for method {$method-&gt;getName()} --&gt;\n" . '&lt;message name="' . $method-&gt;getName() . "Request\"&gt;\n";
                  $parameters = $method-&gt;getParameters();
                  foreach ($parameters as $parameter) {
                      if ($method-&gt;getDocComment()) {
                          $pattern = '/@param\s+(string|boolean|int|integer|float|double)/i';
                          preg_match($pattern, $method-&gt;getDocComment(), $matches);
                          $type = $matches[1];
                      } else {
                          $type = 'string';
                      }
                      $messageWSDL.= '&lt;part name="' . $parameter-&gt;getName() . "\" type=\"xsd:{$type}\" /&gt;\n";
                  }
                  $messageWSDL.= "&lt;/message&gt;\n";
                  $typePrefix = 'xsd';
                  if ($method-&gt;getDocComment()) {
                      $pattern = '/@return\s+(string|boolean|int|integer|float|double)/i';
                      preg_match($pattern, $method-&gt;getDocComment(), $matches);
                      if (count($matches) &gt; 0)
                          $return = $matches[1];
                      else {
                          $typePrefix = 'tns';
                          $pattern = '/@return\s+\w+(\[.*])?/i';
                          preg_match($pattern, $method-&gt;getDocComment(), $matches);
                          $matches = explode(' ', $matches[0]);
                          $return = trim($matches[1]);
                          $is_array = substr($return, 0, 6) == 'array[';
  
                          if ($is_array) {
                              $return = substr($return, 6, strlen($return) - 7);
                          }
  
                          if (strstr($complexType, 'name="' . $return . '"') === FALSE) {
                              $pattern = '/(string|boolean|int|integer|float|double)/i';
                              preg_match($pattern, $return, $matches);
                              if (count($matches) == 0) {
                                  if ($return[0] == '\\')
                                      $refClass = $return;
                                  else
                                      $refClass = $class-&gt;getNamespaceName() . '\\' . $return;
                                  $type = new \ReflectionClass($refClass);
                                  $properties = $type-&gt;getProperties();
                                  $complexType .= '&lt;xsd:complexType name="' . $return . '"&gt;' . "\n" . '&lt;xsd:sequence&gt;' . "\n";
                                  foreach ($properties as $property)
                                      $complexType .= '&lt;xsd:element minOccurs="0" maxOccurs="1" name="' . $property-&gt;getName() . '" type="xsd:string"/&gt;' . "\n";
                                  $complexType .= "&lt;/xsd:sequence&gt;\n&lt;/xsd:complexType&gt;\n";
                              }
                          }
                          if ($is_array) {
                              $complexType .= '&lt;xsd:complexType name="ArrayOf' . ucfirst($return) . '"&gt;' . "\n" . '&lt;xsd:sequence&gt;' . "\n";
                              $complexType .= '&lt;xsd:element minOccurs="0" maxOccurs="unbounded" name="' . $return . '" nillable="true" type="tns:' . $return . '" /&gt;' . "\n";
                              $complexType .= "&lt;/xsd:sequence&gt;\n&lt;/xsd:complexType&gt;\n";
                              $return = 'ArrayOf' . ucfirst($return);
                          }
                      }
                  } else {
                      $return = 'string';
                  }
                  $messageWSDL.= "&lt;!-- Output for method {$method-&gt;getName()} --&gt;\n" . '&lt;message name="' . $method-&gt;getName() . "Response\"&gt;\n";
                  $messageWSDL.= '&lt;part name="' . $method-&gt;getName() . "\" type=\"{$typePrefix}:{$return}\" /&gt;\n";
                  $messageWSDL.= "&lt;/message&gt;\n";
              }
          }
          $headerWSDL = str_replace('{{complexTypes}}', $complexType, $headerWSDL);
          $portTypeWSDL.= "&lt;/portType&gt;\n";
          $bindingWSDL.= "&lt;/binding&gt;\n";
          return sprintf('%s%s%s%s%s%s', $headerWSDL, $messageWSDL, $portTypeWSDL, $bindingWSDL, $serviceWSDL, '&lt;/definitions&gt;');
      }
  
      /**
       * SoapDiscovery::getDiscovery() Returns discovery of WSDL.
       *
       * @return string
       * */
      public function getDiscovery() {
          return "&lt;?xml version=\"1.0\" ?&gt;\n&lt;disco:discovery xmlns:disco=\"http://schemas.xmlsoap.org/disco/\" xmlns:scl=\"http://schemas.xmlsoap.org/disco/scl/\"&gt;\n&lt;scl:contractRef ref=\"http://" . $this-&gt;request-&gt;getHttpHost() . $this-&gt;request-&gt;getScriptName() . $this-&gt;request-&gt;getPathInfo() . "?wsdl\" /&gt;\n&lt;/disco:discovery&gt;";
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>These are the addional files that maybe are relevant:</p>
  
  <p>config.yml:</p>
  
  <pre><code>imports:
      - { resource: parameters.yml }
      - { resource: security.yml }
  
  framework:
      #esi:             ~
      #translator:      { fallback: %locale% }
      secret:          %secret%
      router:
          resource: "%kernel.root_dir%/config/routing.yml"
          strict_requirements: ~
      form:            ~
      csrf_protection: ~
      validation:      { enable_annotations: true }
      templating:
          engines: ['twig']
          #assets_version: SomeVersionScheme
      default_locale:  "%locale%"
      trusted_proxies: ~
      session:         ~
      fragments:       ~
      http_method_override: true
  
  # Twig Configuration
  twig:
      debug:            %kernel.debug%
      strict_variables: %kernel.debug%
  
  # Assetic Configuration
  assetic:
      debug:          %kernel.debug%
      use_controller: false
      bundles:        [ ]
      #java: /usr/bin/java
      filters:
          cssrewrite: ~
          #closure:
          #    jar: %kernel.root_dir%/Resources/java/compiler.jar
          #yui_css:
          #    jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
  
  # Doctrine Configuration
  doctrine:
      dbal:
          driver:   %database_driver%
          host:     %database_host%
          port:     %database_port%
          dbname:   %database_name%
          user:     %database_user%
          password: %database_password%
          charset:  UTF8
          # if using pdo_sqlite as your database driver, add the path in parameters.yml
          # e.g. database_path: %kernel.root_dir%/data/data.db3
          # path:     %database_path%
  
      orm:
          auto_generate_proxy_classes: %kernel.debug%
          auto_mapping: true
  
  # Swiftmailer Configuration
  swiftmailer:
      transport: %mailer_transport%
      host:      %mailer_host%
      username:  %mailer_user%
      password:  %mailer_password%
      spool:     { type: memory }
  
  services:
      feriados_service:
          class: Desytec\ServiciosBundle\Services\FeriadosService
          arguments: ["@database_connection"]
  </code></pre>
  
  <p>config_dev.yml</p>
  
  <pre><code>imports:
      - { resource: config.yml }
  
  framework:
      router:
          resource: "%kernel.root_dir%/config/routing_dev.yml"
          strict_requirements: true
      profiler: { only_exceptions: false }
  
  web_profiler:
      toolbar: true
      intercept_redirects: false
  
  monolog:
      handlers:
          main:
              type:  stream
              path:  %kernel.logs_dir%/%kernel.environment%.log
              level: debug
          firephp:
              type:  firephp
              level: info
          chromephp:
              type:  chromephp
              level: info
  
  assetic:
      use_controller: true
  
  #swiftmailer:
  #    delivery_address: me@example.com
  </code></pre>
  
  <p>config_prod.yml</p>
  
  <pre><code>imports:
      - { resource: config.yml }
  
  #framework:
  #    validation:
  #        cache: apc
  
  #doctrine:
  #    orm:
  #        metadata_cache_driver: apc
  #        result_cache_driver: apc
  #        query_cache_driver: apc
  
  monolog:
      handlers:
          main:
              type:         fingers_crossed
              action_level: error
              handler:      nested
          nested:
              type:  stream
              path:  %kernel.logs_dir%/%kernel.environment%.log
              level: debug
  </code></pre>
  
  <p>routing.yml</p>
  
  <pre><code>_desytec:
      resource: "@DesytecServiciosBundle/Resources/config/routing.yml"
  </code></pre>
  
  <p>routing_dev.yml</p>
  
  <pre><code>_wdt:
      resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
      prefix:   /_wdt
  
  _profiler:
      resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
      prefix:   /_profiler
  
  _configurator:
      resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml"
      prefix:   /_configurator
  
  _main:
      resource: routing.yml
  </code></pre>
  
  <p>@DesytecServiciosBundle/Resources/config/routing.yml</p>
  
  <pre><code>desytec_servicios:
      resource: "@DesytecServiciosBundle/Controller/"
      type:     annotation
      prefix:   /
  </code></pre>
  
  <p>.htaccess</p>
  
  <pre><code># Use the front controller as index file. It serves as a fallback solution when
  # every other rewrite/redirect fails (e.g. in an aliased environment without
  # mod_rewrite). Additionally, this reduces the matching process for the
  # start page (path "/") because otherwise Apache will apply the rewriting rules
  # to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
  DirectoryIndex app.php
  
  &lt;IfModule mod_rewrite.c&gt;
      RewriteEngine On
  
      # Determine the RewriteBase automatically and set it as environment variable.
      # If you are using Apache aliases to do mass virtual hosting or installed the
      # project in a subdirectory, the base path will be prepended to allow proper
      # resolution of the app.php file and to redirect to the correct URI. It will
      # work in environments without path prefix as well, providing a safe, one-size
      # fits all solution. But as you do not need it in this case, you can comment
      # the following 2 lines to eliminate the overhead.
      RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
      RewriteRule ^(.*) - [E=BASE:%1]
  
      # Redirect to URI without front controller to prevent duplicate content
      # (with and without `/app.php`). Only do this redirect on the initial
      # rewrite by Apache and not on subsequent cycles. Otherwise we would get an
      # endless redirect loop (request -&gt; rewrite to front controller -&gt;
      # redirect -&gt; request -&gt; ...).
      # So in case you get a "too many redirects" error or you always get redirected
      # to the start page because your Apache does not expose the REDIRECT_STATUS
      # environment variable, you have 2 choices:
      # - disable this feature by commenting the following 2 lines or
      # - use Apache &gt;= 2.3.9 and replace all L flags by END flags and remove the
      #   following RewriteCond (best solution)
      RewriteCond %{ENV:REDIRECT_STATUS} ^$
      RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
  
      # If the requested filename exists, simply serve it.
      # We only want to let Apache serve files and not directories.
      RewriteCond %{REQUEST_FILENAME} -f
      RewriteRule .? - [L]
  
      # Rewrite all other queries to the front controller.
      RewriteRule .? %{ENV:BASE}/app.php [L]
  &lt;/IfModule&gt;
  
  &lt;IfModule !mod_rewrite.c&gt;
      &lt;IfModule mod_alias.c&gt;
          # When mod_rewrite is not available, we instruct a temporary redirect of
          # the start page to the front controller explicitly so that the website
          # and the generated links can still be used.
          RedirectMatch 302 ^/$ /app.php/
          # RedirectTemp cannot be used instead
      &lt;/IfModule&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>Any help will be greatly appreciated</p>
  
  <p>Thanks
  Jaime</p>