[eluser]himanshuy[/eluser]
Return XML response with Codeigniter:
I am trying to return a xml response from controller:
Code:
if($_SERVER['REQUEST_METHOD'] === 'POST')
{
$responsexml = '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://schemas.microsoft.com/windows/management/2012/01/enrollment/IDiscoveryService/DiscoverResponse</a:Action><ActivityId>d9eb2fdd-e38a-46ee-bd93-aea9dc86a3b8</ActivityId><a:RelatesTo>urn:uuid: 748132ec-a575-4329-b01b-6171a9cf8478</a:RelatesTo></s:Header><s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"></s:Body></s:Envelope>';
$this->output->set_header("HTTP/1.1 200 OK");
$this->output->set_header("Cache-Control: no-cache");
$this->output->set_header("Pragma: no-cache");
$this->output->set_header("Content-Type: application/soap+xml;charset=utf-8");
//$this->output->set_output('Dude! This is not cool!');
$this->output->set_output($responsexml);
}
Response I get while returning the xml is:
Header:
Expires: Sat, 6 May 1995 12:00:00 GMT
P3P: CP=NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Content-Length: 144
Connection: Close
Response:
Code:
<html>
<body>
[removed][removed]='zzzzzzz=d7be80d2zzzzzzz_d7be80d2; path=/';[removed].href=[removed].href;[removed]
</body>
</html>
I return a string with
Code:
$this->output->set_output('Dude! This is not cool!');
then header comes perfectly fine.