Skip to content

Commit 6ffa53b

Browse files
committed
Add SOAP request as body for better logging
1 parent 443015b commit 6ffa53b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/Engine/AsyncEngine.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ public function __construct(
2222
) {
2323
}
2424

25-
public function request(string $method, array $arguments, array $headers = []): ResponseInterface
25+
/**
26+
* @return array{0: SoapRequest, 1: SoapResponse} An array containing the prepared SoapRequest object and the resulting SoapResponse.
27+
*/
28+
public function request(string $method, array $arguments, array $headers = []): array
2629
{
2730
$request = $this->driver->encode($method, [$arguments]);
2831

@@ -47,7 +50,10 @@ public function request(string $method, array $arguments, array $headers = []):
4750

4851
$psr7Request = $this->converter->convertSoapRequest($request);
4952

50-
return new SoapResponse($this->makeRequest($psr7Request), $this->driver, $method);
53+
return [
54+
$request,
55+
new SoapResponse($this->makeRequest($psr7Request), $this->driver, $method),
56+
];
5157
}
5258

5359
private function makeRequest(RequestInterface $request): ResponseInterface
@@ -99,4 +105,4 @@ private function makeRequest(RequestInterface $request): ResponseInterface
99105

100106
return $this->client->request($request->getMethod(), (string)$request->getUri(), $options);
101107
}
102-
}
108+
}

src/Handler/SoapAsyncRequestHandler.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ protected function performRequest(WSRequest $request): ResponseInterface
3232
$requestOptions = $request->getOptions();
3333
$client = AsyncEngineFactory::createFromWSDL($requestOptions['base_uri'], $this->client);
3434

35-
return $client->request($request->action, $request->getRequestParams(), $requestOptions['headers'] ?? []);
35+
[$req, $res] = $client->request(
36+
$request->action, $request->getRequestParams(), $requestOptions['headers'] ?? []
37+
);
38+
$request->setBody(['body' => $req->getRequest()]);
39+
40+
return $res;
3641
}
37-
}
42+
}

0 commit comments

Comments
 (0)