CodeIgniter Forums
Not able to return a soap XML response back to the caller - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Not able to return a soap XML response back to the caller (/thread-58290.html)



Not able to return a soap XML response back to the caller - El Forum - 05-30-2013

[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:
&lt;html&gt;
&lt;body&gt;
  [removed][removed]='zzzzzzz=d7be80d2zzzzzzz_d7be80d2; path=/';[removed].href=[removed].href;[removed]
&lt;/body&gt;
&lt;/html&gt;
I return a string with
Code:
$this->output->set_output('Dude! This is not cool!');
then header comes perfectly fine.


Not able to return a soap XML response back to the caller - El Forum - 05-30-2013

[eluser]TheFuzzy0ne[/eluser]
Dude! This is not cool!

I'm not sure why that's not working, or where the response you're receiving actually came from. I would suggest you try turning off the output buffer and just echoing your output before die()ing.
Code:
ob_end_clean();
echo $responsexml;
die();

This isn't a solution, but a possible workaround.


Not able to return a soap XML response back to the caller - El Forum - 05-30-2013

[eluser]himanshuy[/eluser]
No it didn't work me. Strangely I am getting xml response back in
Quote:localhost
.


Not able to return a soap XML response back to the caller - El Forum - 05-30-2013

[eluser]TheFuzzy0ne[/eluser]
Do you have error reporting enabled? Maybe there's an error somewhere that's halting script execution prematurely? I'm also wondering if this may have something to do with PHP's output buffering. It might be worth disabling it and seeing if that makes any difference.


Not able to return a soap XML response back to the caller - El Forum - 05-31-2013

[eluser]himanshuy[/eluser]
I am new to Codeigniter. By error reporting do you mean enabling the logs? And how would I disable PHP's output buffering?
Does header information gives any idea about this kind response?
Code:
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



Not able to return a soap XML response back to the caller - El Forum - 05-31-2013

[eluser]TheFuzzy0ne[/eluser]
I've just checked my php.ini file, and output buffering is disabled by default, so I don't think that's the problem.

The server response you posted is what confuses me. It's not even close to what you specified. I'd be interest to know where it's coming from. Could it be a problem with your application flow? Are you sure that your code is even being executed?


Not able to return a soap XML response back to the caller - El Forum - 05-31-2013

[eluser]himanshuy[/eluser]
Here some new update.
Everything works fine if I just
Code:
echo  $responsexml
. It gives me weird javascript response if set it to the output.