24 private $errorProcessor;
36 $this->xmlSecurity = $xmlSecurity;
37 $this->errorProcessor = $errorProcessor;
48 public function validate($xmlResponse, $isShippingLabel =
false)
50 if (strlen(trim($xmlResponse)) > 0 && strpos(trim($xmlResponse),
'<?xml') === 0) {
51 if (!$this->xmlSecurity->scan($xmlResponse)) {
54 $xml = simplexml_load_string($xmlResponse, \
Magento\Shipping\Model\Simplexml\Element::class);
56 if (in_array($xml->getName(), [
'ErrorResponse',
'ShipmentValidateErrorResponse'])
57 || isset($xml->GetQuoteResponse->Note->Condition)
60 $exceptionPhrase = $this->errorProcessor->process($xml, $isShippingLabel);
64 throw new DocumentValidationException(
__(
'The response is in the wrong format'));
__construct(\Magento\Framework\Xml\Security $xmlSecurity, ResponseErrorProcessor $errorProcessor)