phphttpsoapsoapheadersoapserver

Adding HTTP Headers on SoapServer Response


Is there a way to add an HTTP Header in a response of a SoapServer.

For example: I want the response of my SoapServer to add "Location", "http://localhost"

HTTP/1.1 307 Temporary Redirect

Location: http://localhost

Content-Type: text/xml; charset="utf-8"

Content-Length: 100


Solution

  • In your SoapServer, just add:

    header('Location: http://localhost');
    

    this will automatically add the 'Location' header as well as change the response code.