| @@ -22,9 +22,9 @@ | ||
| 22 | 22 | * @param bool $honorResultWrapper Set to false to disable the peeling |
| 23 | 23 | * back of result wrappers from the |
| 24 | 24 | * output structure. |
| 25 | 25 | */ |
| 26 | - public function __construct(Service $api, XmlParser $xmlParser = null, $honorResultWrapper = \true) | |
| 26 | + public function __construct(Service $api, ?XmlParser $xmlParser = null, $honorResultWrapper = \true) | |
| 27 | 27 | { |
| 28 | 28 | parent::__construct($api); |
| 29 | 29 | $this->parser = $xmlParser ?: new XmlParser(); |
| 30 | 30 | $this->honorResultWrapper = $honorResultWrapper; |
| @@ -31,9 +31,14 @@ | ||
| 31 | 31 | } |
| 32 | 32 | public function __invoke(CommandInterface $command, ResponseInterface $response) |
| 33 | 33 | { |
| 34 | 34 | $output = $this->api->getOperation($command->getName())->getOutput(); |
| 35 | - $xml = $this->parseXml($response->getBody(), $response); | |
| 35 | + $body = $response->getBody(); | |
| 36 | + $xml = !$body->isSeekable() || $body->getSize() ? $this->parseXml($body, $response) : null; | |
| 37 | + // Empty request bodies should not be deserialized. | |
| 38 | + if (\is_null($xml)) { | |
| 39 | + return new Result(); | |
| 40 | + } | |
| 36 | 41 | if ($this->honorResultWrapper && $output['resultWrapper']) { |
| 37 | 42 | $xml = $xml->{$output['resultWrapper']}; |
| 38 | 43 | } |
| 39 | 44 | return new Result($this->parser->parse($output, $xml)); |