Skip to content

Commit 4804b45

Browse files
committed
feat: adding option to decied if arguments should be wrapped
Related to #237, #233
1 parent 476377e commit 4804b45

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

config/soap.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,28 @@
1818

1919
/*
2020
|--------------------------------------------------------------------------
21-
| SOAP Code Generation directory
21+
| SOAP Ray Configuration
2222
|--------------------------------------------------------------------------
2323
|
24-
| Define the destination for the code generator under the app directory
24+
| Define if all requests should go to ray
2525
*/
2626

2727
'ray' => [
2828
'send_soap_client_requests' => false,
2929
],
3030

31+
/*
32+
|--------------------------------------------------------------------------
33+
| SOAP Call behaviour
34+
|--------------------------------------------------------------------------
35+
|
36+
| Define if all requests should go to ray
37+
*/
38+
39+
'call' => [
40+
'wrap_arguments_in_array' => true,
41+
],
42+
3143
/*
3244
|--------------------------------------------------------------------------
3345
| SOAP Client Configuration

src/Client/Request.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,14 @@ public function xmlContent(): string
160160
public function arguments(): array
161161
{
162162
$doc = Document::fromXmlString($this->body());
163+
$wrappedArguments = config()->get('soap.call.wrap_arguments_in_array', true);
163164
$method = $doc->locate(new SoapBodyLocator());
164165

165-
return Arr::wrap(Arr::get(element_decode($method, traverse(new RemoveNamespaces())), 'Body', []));
166+
if ($wrappedArguments) {
167+
$method = $method?->firstElementChild;
168+
}
169+
170+
return Arr::wrap(Arr::get(element_decode($method, traverse(new RemoveNamespaces())), $wrappedArguments ? 'node' : 'Body', []));
166171
}
167172

168173
/**

src/SoapClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function call(string $method, Validator|array $arguments = []): Response
354354
}
355355
$arguments = $arguments->validated();
356356
}
357-
$arguments = [$arguments];
357+
$arguments = config()->get('soap.call.wrap_arguments_in_array', true) ? [$arguments] : $arguments;
358358
$result = $this->engine->request($method, $arguments);
359359
if ($result instanceof ResultProviderInterface) {
360360
return $this->buildResponse(Response::fromSoapResponse($result->getResult()));

0 commit comments

Comments
 (0)