title: zend soap server response set custom ns1 namespace
body: <p>I am using Zend_Soap_Server (WSDL mode) for outputting an xml response to the client calls.
  However, i want to set a custom name for the <strong>ns1</strong> namespace in the response.</p>
  
  <p>I noticed that the namespace in the response is set by default like: '<strong>ns1:getDoubleResponse</strong>' where '<strong>getDouble</strong>' is the server method being called.</p>
  
  <p>Here is my controller and SOAP server setup:</p>
  
  <pre><code>class TestController extends Zend_Controller_Action {
  
      public function testAction() {
  
          // diable laoyouts and renderers
          $this-&gt;getHelper ( 'viewRenderer' )-&gt;setNoRender ( true );
          $server = new Zend_Soap_Server ('http://example.com/public/test/testwsdl'); 
          $server-&gt;setClass ( 'Application_Model_test');
  
          // register exceptions that generate SOAP faults
          $server-&gt;registerFaultException('Application_Model_soapException');
  
          // handle request
          $server-&gt;handle ();
      }
  
      public function testwsdlAction() {
          // diable laoyouts and renderers
          $this-&gt;getHelper ( 'viewRenderer' )-&gt;setNoRender ( true );      
          $wsdl = new Zend_Soap_AutoDiscover ();
  
          $wsdl-&gt;setClass ( 'Application_Model_test');    
          $wsdl-&gt;setUri ('http://example.com/public/test/test');
  
          // handle request
          $wsdl-&gt;handle ();
      }
  }
  </code></pre>
  
  <p>This is my model code:</p>
  
  <pre><code>class Application_Model_test
  {
      /**
       * Returns the double of an integer value
       * @param integer $int
       * @return string
       */
      public function getDouble($int)
      {
          $doc = new DOMDocument ( '1.0', 'utf-8' );
  
          $response = $doc-&gt;createElement("IntegerResult");
          $val = $doc-&gt;createElement("Value");
          $val-&gt;appendChild ($doc-&gt;createTextNode($int * 2));     
          $response-&gt;appendChild($val);           
  
          $doc-&gt;appendChild ($response);      
          $result = $doc-&gt;saveXML();
          return $result;
      }   
  }
  </code></pre>
  
  <p>This is the request i see, as per SOAP UI:</p>
  
  <pre><code>    &lt;soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://example.com/public/test/test"&gt;
     &lt;soapenv:Header/&gt;
     &lt;soapenv:Body&gt;
        &lt;test:getDouble soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
           &lt;int xsi:type="xsd:int" xs:type="type:int" xmlns:xs="http://www.w3.org/2000/XMLSchema-instance"&gt;3&lt;/int&gt;
        &lt;/test:getDouble&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>And this is the associated response, as per SOAP UI:</p>
  
  <pre><code>    &lt;SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://example.com/public/test/test" 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/"&gt;
     &lt;SOAP-ENV:Body&gt;
        &lt;ns1:getDoubleResponse&gt;
           &lt;return xsi:type="xsd:string"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&gt;
  &amp;lt;IntegerResult&gt;&amp;lt;Value&gt;6&amp;lt;/Value&gt;&amp;lt;/IntegerResult&gt;&lt;/return&gt;
        &lt;/ns1:getDoubleResponse&gt;
     &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p>I just want to change the <code>&lt;ns1:getDoubleResponse&gt;</code> in SOAP response to something like <code>&lt;ns1:TestResult&gt;</code></p>
  
  <p>How can i fix namespace? I don't mind throwing the response through DOM or Xpath.
  I am also interested in extending the Zend_Soap_Server for customizing the response.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have extended the Zend_Soap_Server with a class, and now tried to send a custom response through the handle() method.</p>
  
  <pre><code>// TestController.php
  //$server = new Zend_Soap_Server ('http://example.com/public/test/testwsdl');
  $server = new TestSoapServer ('http://example.com/public/test/testwsdl');
  </code></pre>
  
  <p>And this is the class that extends Zend_Soap_Server, and handles the response:</p>
  
  <pre><code>// TestController.php
  class TestSoapServer extends Zend_Soap_Server 
  {
      public function __construct($wsdl, $options = null)
      {
          return parent::__construct($wsdl, $options);
      }
  
      public function handle($request = null)
      {
        $result = parent::handle($request);
        $result = str_replace("getDoubleResponse", "TestResult", $result);
        return $result;       
      }
  }
  </code></pre>
  
  <p>But now, when i run the request in SOAP UI, i see an empty response. Don't know what i am doing wrong.</p>