使用php SoapServer的分段错误(核心转储)错误

时间:2019-02-27 15:00:42

标签: php apache soap

我使用php7和apache 2制作soap API,并且我有一个像这样的处理程序:

$app->any('/xmlrpc', function (\Slim\Http\Request $request, \Slim\Http\Response $response) use ($app) {
    $soap = \System\Core\Soap::getInstance();
    $soapHandler = new \Application\Controllers\Soap($app->getContainer());
    $soap->setObject($soapHandler);
    $soap->handle($request->getBody()->getContents());
});

我的\ System \ Core \ Soap类只是单调包装器:

class Soap
{
    /**
     * @var self
     */
    private static $oInstance;
    /**
     * @var \SoapServer
     */
    private $soap;

    /**
     * Soap constructor.
     */
    protected function __construct()
    {
        $this->soap = new \SoapServer(env('SOAP_WSDL_PATH'), ['cache_wsdl' => 1]);
    }

    /**
     * Return instance
     *
     * @return Soap
     */
    public static function getInstance(): self
    {
        if (null === self::$oInstance) {
            self::$oInstance = new self();
        }
        return self::$oInstance;
    }

    /**
     * @param string $class
     */
    public function setClass(string $class, $args): void
    {
        $this->soap->setClass($class, $args);
    }

    /**
     * @param $object
     */
    public function setObject($object): void
    {
        $this->soap->setObject($object);
    }

    /**
     * @param string $request
     */
    public function handle(string $request): void
    {
        $this->soap->handle($request);
    }

    /**
     * @param string $code
     * @param string $string
     * @param string|null $actor
     * @param string|null $details
     */
    public function fault(string $code, string $string, ?string $actor = null, ?string $details = null): void
    {
        $this->soap->fault($code, $string, $actor, $details);
    }
}

我有一个处理程序类\ Application \ Controllers \ Soap 当处理程序方法返回数组时,出现类似以下错误:[core:notice] [pid 1] AH00051: child pid 7 exit signal Segmentation fault (11), possible coredump in /etc/apache2 但是,如果我不返回数组,就没有错误,只是空的响应。

1 个答案:

答案 0 :(得分:0)

我不知道为什么,但是如果我返回关联数组,一切正常。

return ['ResultCode' => $ret[0], 'Data' => $ret[1]];