title: soap web service with symfony
body: <p>I write a web service with symfony2 that is in this <a href="http://symfony.com/doc/current/cookbook/web_services/php_soap_extension.html" rel="nofollow">tutorial</a>.</p>
  
  <p>my rout is :</p>
  
  <pre><code>_soap:
  path:      /soap
  defaults:  { _controller: AcmeSoapBundle:Default:index}
  </code></pre>
  
  <p>my config :</p>
  
  <pre><code>services:
  hello_service:
      class: Acme\SoapBundle\Services\HelloService
      arguments: ["@mailer"]
  </code></pre>
  
  <p>my service :</p>
  
  <pre><code>namespace Acme\SoapBundle\Services;
  
  class HelloService
  {
      private $mailer;
  
      public function __construct(\Swift_Mailer $mailer)
      {
          $this-&gt;mailer = $mailer;
      }
  
      public function hello($name)
      {
  
          $message = \Swift_Message::newInstance()
              -&gt;setTo('me@example.com')
              -&gt;setSubject('Hello Service')
              -&gt;setBody($name . ' says hi!');
  
          $this-&gt;mailer-&gt;send($message);
  
          return 'Hello, '.$name;
      }
  }
  </code></pre>
  
  <p>my controller :</p>
  
  <pre><code>namespace Acme\SoapBundle\Controller;
  
  use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  use Symfony\Component\HttpFoundation\Response;
  
  class DefaultController extends Controller
  {
      public function indexAction()
      {
          $server = new \SoapServer('hello.wsdl');
          $server-&gt;setObject($this-&gt;get('hello_service'));
  
          $response = new Response();
          $response-&gt;headers-&gt;set('Content-Type', 'text/xml; charset=ISO-8859-1');
  
          ob_start();
          $server-&gt;handle();
          $response-&gt;setContent(ob_get_clean());
  
          return $response;
      }
  }
  </code></pre>
  
  <p>hello.wsdl ( web/hello.wsdl )</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &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:arnleadservicewsdl"
      xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns="http://schemas.xmlsoap.org/wsdl/"
      targetNamespace="urn:helloservicewsdl"&gt;
  
      &lt;types&gt;
          &lt;xsd:schema targetNamespace="urn:hellowsdl"&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;
      &lt;/types&gt;
  
      &lt;message name="helloRequest"&gt;
          &lt;part name="name" type="xsd:string" /&gt;
      &lt;/message&gt;
  
      &lt;message name="helloResponse"&gt;
          &lt;part name="return" type="xsd:string" /&gt;
      &lt;/message&gt;
  
      &lt;portType name="hellowsdlPortType"&gt;
          &lt;operation name="hello"&gt;
              &lt;documentation&gt;Hello World&lt;/documentation&gt;
              &lt;input message="tns:helloRequest"/&gt;
              &lt;output message="tns:helloResponse"/&gt;
          &lt;/operation&gt;
      &lt;/portType&gt;
  
      &lt;binding name="hellowsdlBinding" type="tns:hellowsdlPortType"&gt;
          &lt;soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/&gt;
          &lt;operation name="hello"&gt;
              &lt;soap:operation soapAction="urn:arnleadservicewsdl#hello" style="rpc"/&gt;
  
              &lt;input&gt;
                  &lt;soap:body use="encoded" namespace="urn:hellowsdl"
                      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
              &lt;/input&gt;
  
              &lt;output&gt;
                  &lt;soap:body use="encoded" namespace="urn:hellowsdl"
                      encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/&gt;
              &lt;/output&gt;
          &lt;/operation&gt;
      &lt;/binding&gt;
  
      &lt;service name="hellowsdl"&gt;
          &lt;port name="hellowsdlPort" binding="tns:hellowsdlBinding"&gt;
              &lt;soap:address location="http://example.com/app.php/soap" /&gt;
          &lt;/port&gt;
      &lt;/service&gt;
  &lt;/definitions&gt;
  </code></pre>
  
  <p><strong>but I see bellow error:</strong></p>
  
  <pre><code>XML Parsing Error: no element found
  Location: http://xxx.xxxx.xxx/unproject/web/app_dev.php/soap
  Line Number 1, Column 1:
  </code></pre>
  
  <p>How can I fix this problem ?
  Thanks for your help</p>