Skip to content

Commit adcc61b

Browse files
authored
feat(#225): WSA 2005 Support
* Extra commit * Added docs change
1 parent ca4182b commit adcc61b

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

docs/client/authentication.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Like Wss/Wsse it uses the same package:
4242
->withWsa()
4343
->call(...)
4444

45+
You can also use the 2005 version of Wsa with
46+
47+
$response = Soap::baseWsdl(...)
48+
->withWsa2005()
49+
->call(...)
50+
4551
### DHL Cis Authentication
4652

4753
DHL uses his own authentication header

src/SoapClient.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use Soap\Psr18Transport\Psr18Transport;
3939
use Soap\Psr18Transport\Wsdl\Psr18Loader;
4040
use Soap\Psr18WsseMiddleware\WsaMiddleware;
41+
use Soap\Psr18WsseMiddleware\WsaMiddleware2005;
4142
use Soap\Wsdl\Loader\FlatteningLoader;
4243
use Soap\Wsdl\Loader\StreamWrapperLoader;
4344

@@ -248,6 +249,18 @@ public function withWsa()
248249
return $this;
249250
}
250251

252+
/**
253+
* @return $this
254+
*/
255+
public function withWsa2005()
256+
{
257+
$this->middlewares = array_merge_recursive($this->middlewares, [
258+
new WsaMiddleware2005(),
259+
]);
260+
261+
return $this;
262+
}
263+
251264
public function withWsse(array $options): static
252265
{
253266
$this->middlewares = array_merge_recursive($this->middlewares, [

tests/Unit/SoapClientTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@ public function testWsseWithWsaCall()
7070
self::assertTrue($response->ok());
7171
}
7272

73+
public function testWsseWithWsa2005Call()
74+
{
75+
Soap::fake();
76+
ray()->showSoapClientRequests();
77+
$client = Soap::baseWsdl(dirname(__DIR__, 1).'/Fixtures/Wsdl/weather.wsdl')->withWsse([
78+
'userTokenName' => 'Test',
79+
'userTokenPassword' => 'passwordTest',
80+
'mustUnderstand' => false,
81+
])->withWsa2005();
82+
$response = $client->GetWeatherInformation();
83+
Soap::assertSent(function (Request $request) {
84+
return ! Str::contains($request->xmlContent(), 'mustUnderstand');
85+
});
86+
self::assertTrue($response->ok());
87+
}
88+
7389
public function testArrayAccessResponse()
7490
{
7591
Soap::fakeSequence()->push('test');

0 commit comments

Comments
 (0)