简体   繁体   中英

LastRequest is empty, POST is empty. How to get the XML request from Zend Soap Server?

I've implemented a zend soap server with the code below. For my purposes i need to be able to access the full XML message or at the very least its headers. However, the getLastRequest method on SoapServer returns empty, and all the super globals, such as $_GET, $_POST and whatnot, are also empty. Anyone has any ideas?

class SoapTest
{

    protected $server;

    public function __construct(\Zend\Soap\Server $server)
    {
        $this->server = $server;    
    }

    /***
     * @param string $requestIn
     * @return string
     */
    public function test($requestIn)
    {
       // access XML here
    }
}
$serverUrl = "http://localhost/SoapTest.php";
    $options = [
        'uri' => $serverUrl,
    ];
    $server = new Zend\Soap\Server(null, $options);

    if (isset($_GET['wsdl'])) {
        $soapAutoDiscover = new \Zend\Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
        $soapAutoDiscover->setBindingStyle(array('style' => 'document'));
        $soapAutoDiscover->setOperationBodyStyle(array('use' => 'literal'));
        $soapAutoDiscover->setClass(SoapTest::class);
        $soapAutoDiscover->setUri($serverUrl);

        header("Content-Type: text/xml");
        echo $soapAutoDiscover->generate()->toXml();
    } else {
        $soap = new \Zend\Soap\Server($serverUrl . '?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));
        $soap->setObject(new \Zend\Soap\Server\DocumentLiteralWrapper(new SoapTest($soap)));
        $soap->handle();
    }

Apparently, Zend Soap Server fills the $request property (which is returned in getLastRequest) AFTER the handle, so i cant access it in my method.

I can however access the XML by calling the following:

$request = file_get_contents('php://input');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM