Skip to content

Commit 7d6f697

Browse files
authored
Merge pull request #623 from CommonGateway/feature/owo/detect-soap
Force Envelope when detecting SOAP
2 parents 8aa5323 + 0fc8d9f commit 7d6f697

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/Service/RequestService.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ public function serializeData(array $data, &$contentType, ?string $xmlRootNode =
226226
$endpoint = $this->data['endpoint'];
227227
}
228228

229+
if ($xmlRootNode === null && in_array('http://schemas.xmlsoap.org/soap/envelope/', $data) === true) {
230+
$nsRef = array_search(needle: 'http://schemas.xmlsoap.org/soap/envelope/', haystack: $data);
231+
[
232+
$xmlns,
233+
$ns,
234+
] = explode(separator: ':', string: $nsRef, limit: 2);
235+
236+
$xmlRootNode = "$ns:Envelope";
237+
}
238+
229239
$encoderSettings = ['xml_encoding' => 'utf-8'];
230240
if ($xmlRootNode) {
231241
$encoderSettings['xml_root_node_name'] = $xmlRootNode;
@@ -807,6 +817,10 @@ public function proxyHandler(array $data, array $configuration, ?Source $proxy =
807817
unset($headers['Content-Length']);
808818
}
809819

820+
if ($data['accept'] !== $headers['content-type'][0]) {
821+
$headers['content-type'] = $data['accept'];
822+
}
823+
810824
// Let create a response from the guzzle call.
811825
$response = new Response(
812826
$this->serializeData($resultContent, $contentType, $xmlRootNode),

0 commit comments

Comments
 (0)