LastRequest 为空,POST 为空。如何从 Zend Soap Server 获取 XML 请求?

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

我用下面的代码实现了一个 zend soap 服务器。出于我的目的,我需要能够访问完整的 XML 消息或至少它的 headers。但是,SoapServer returns 上的 getLastRequest 方法是空的,所有超级全局变量,如 $_GET、$_POST 等等,也是空的。有人有什么想法吗?

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();
    }

显然,Zend Soap Server 在句柄之后填充 $request 属性(在 getLastRequest 中返回),所以我无法在我的方法中访问它。

不过,我可以通过调用以下命令访问 XML:

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