| 
        php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
  [2013-06-10 12:42 UTC] kjarli at gmail dot com
 Description:
------------
Case: I'm using a framework with MVC, symfony2. I'm using SOAP for 1 part of the 
system to receive notifications by an external party. Using SoapServer::handle() 
requires me to hack/cheat on the MVC pattern. 
Say I want to use the normal route in any framework, thus assign my 
SoapServer::handle() to a variable in the output, that's impossible because it's 
send to the browser straight away. This breaks several things:
- The framework using Output Buffering 
- PHPUnit using Output Buffering.
Soap feels like php 4.0 and it's time to update it. My feature request: Have 
SoapServer::handle() return the string instead or make a new method that does 
this.
Test script:
---------------
$classmap = array(...);
$server = new \SoapServer(
    __DIR__ . '/../Resources/config/Notification.wsdl',
    array('classmap' => $this->classmap)
);
$server->setObject($this->get('mysoap.methods'));
$response = new Response();
$response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
// Sadly handle() prints the output rather than returning it -.-
ob_start();
$server->handle();
$content = ob_get_length() > 0
    ? ob_get_clean()
    : '<?xml version="1.0" encoding="UTF-8"?><root><error>No soap response generated</error></root>';
$response->setContent($content);
Expected result:
----------------
.
Actual result:
--------------
Would be so much easier if I could just do:
[...]
$response = new Response();
$response->headers->set('Content-Type', 'text/xml; charset=ISO-8859-1');
$response->setContent($server->handle());
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             
             | 
    |||||||||||||||||||||||||||||||||||||
            
                 
                Copyright © 2001-2025 The PHP GroupAll rights reserved.  | 
        Last updated: Tue Nov 04 03:00:01 2025 UTC | 
You can do it this way <?php class \SoapServer2 extends \SoapServer{ public function handle($soap_request = null){ ob_start(); parent::handle($soap_request); $output = ob_get_contents(); ob_end_clean(); return $output; } } $server = new \SoapServer2( __DIR__ . '/../Resources/config/Notification.wsdl', array('classmap' => $this->classmap)); // ...