title: php set encoding type for soap server response
body: <p>I have created a soap server in php using the native soap server class in php. The encoding I need is <code>ISO-8859-1</code>.
  I have tried to do it while creating the soap server like this:</p>
  
  <p><code>$server = new SoapServer('./AdviseAndPay.wsdl',array('encoding'=&gt;'ISO-8859-1'));</code></p>
  
  <p>However the encoding for the http header  and the soap response is still utf-8.</p>
  
  <p>I am returning a native php <code>SoapVar</code> object for the soap response. I have tried setting the header Content type to <code>ISO-8859-1</code> with this code:</p>
  
  <p><code>header('Content-Type: text/xml;charset=iso-8859-1')</code>
   just before returning the <code>SoapVar</code>. 
  However I still get the encoding as utf-8 in both the http header and the soap response.</p>
  
  <p>I have tried answers in stackoverflow and in the answer the encdoding type has been set while defining the soap server but this has not worked for me.</p>
  
  <p>Could you please help me.
  Thanks in advance.</p>
  
  <p><code>Edit</code>:
  This is the raw http response for the soap server response.</p>
  
  <pre><code>HTTP/1.1 200 OK
  Date: Wed, 15 Jan 2014 04:47:16 GMT
  Server: Apache/2.2.22 (Ubuntu)
  X-Powered-By: PHP/5.4.9-4ubuntu2.4
  Cache-Control: no-store, no-cache, must-revalidate, private, max-age=0
  Pragma: no-cache
  Expires: Wed, 11 Jan 1984 05:00:00 GMT
  Vary: Accept-Encoding
  Content-Encoding: gzip
  Content-Length: 225
  Keep-Alive: timeout=5, max=100
  Connection: Keep-Alive
  Content-Type: text/xml; charset=utf-8
  
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;SOAP-ENV:Body&gt;&lt;ns2:responseType xmlns:ns2="http://tempuri.org/response"&gt;
  &lt;code&gt;00&lt;/code&gt;
  &lt;message&gt;incorrect username/password&lt;/message&gt;
  &lt;responseBody&gt;
  &lt;responseStr&gt;5&lt;/responseStr&gt;
  &lt;/responseBody&gt;
  &lt;/ns2:responseType&gt;
  &lt;/SOAP-ENV:Body&gt;
  &lt;/SOAP-ENV:Envelope&gt;
  </code></pre>
  
  <p><code>Edit</code>:</p>
  
  <p>I found that there was a php bug report regarding the encoding type of the soap server response. The latest comment on that saying there was a bug was in 2008.
  Here is the link: <a href="https://bugs.php.net/bug.php?id=34748" rel="nofollow">php bug</a></p>
  
  <p>Could anyone verify if they have a similar problem with soap server encoding?</p>