Skip to content

Commit 01e9b93

Browse files
Add suporte a interpretação de XML literal pelo método doRequest
1 parent 76fe08e commit 01e9b93

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/Soap.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ public function doRequest($servico, $argumentos)
7070
}
7171

7272
if(is_string($argumentos)) {
73+
/* @see http://php.net/manual/pt_BR/function.libxml-use-internal-errors.php */
74+
libxml_use_internal_errors(true);
75+
$xml = simplexml_load_string($argumentos);
76+
77+
if ($xml === false) {
78+
foreach (libxml_get_errors() as $error) {
79+
throw new Exception('Ocorreu um erro ao processar o XML de envio: ' . $error->message);
80+
}
81+
}
82+
83+
if ($xml = $xml->children('soapenv', true)) {
84+
$argumentos = $xml->Body->children()->asXML();
85+
}
86+
7387
$argumentos = [new SoapVar($argumentos, XSD_ANYXML)];
7488
}
7589

@@ -147,7 +161,7 @@ public function formatXML($soap)
147161
if(!$soap) {
148162
return null;
149163
}
150-
164+
151165
$dom = new DOMDocument;
152166
$dom->preserveWhiteSpace = false;
153167
$dom->formatOutput = true;

0 commit comments

Comments
 (0)