Skip to content

Commit bc4d3ca

Browse files
CodeDreddGregor Becker
and
Gregor Becker
authored
fix(laravel-soap-126): 400 Bad Request, XML not as expected (#138)
* fix(laravel-soap-126): 400 Bad Request, XML not as expected Added mustUnderstand option for Wsse Header * Apply fixes from StyleCI (#139) Co-authored-by: Gregor Becker <[email protected]> Co-authored-by: Gregor Becker <[email protected]> Co-authored-by: Gregor Becker <[email protected]>
1 parent 22d162d commit bc4d3ca

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

src/Middleware/WsseMiddleware.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ class WsseMiddleware extends Middleware
6262
*/
6363
private $encrypt = false;
6464

65+
/**
66+
* @var bool
67+
*/
68+
private $mustUnderstand = true;
69+
6570
/**
6671
* @var bool
6772
*/
@@ -127,7 +132,7 @@ public function withServerCertificateHasSubjectKeyIdentifier(bool $hasSubjectKey
127132
public function beforeRequest(callable $handler, RequestInterface $request): Promise
128133
{
129134
$xml = SoapXml::fromStream($request->getBody());
130-
$wsse = new WSSESoap($xml->getXmlDocument());
135+
$wsse = new WSSESoap($xml->getXmlDocument(), $this->mustUnderstand);
131136

132137
// Prepare the WSSE soap class:
133138
$wsse->signAllHeaders = $this->signAllHeaders;

tests/Unit/SoapClientTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@ public function testMagicCallByConfig()
4040
self::assertTrue($response->ok());
4141
}
4242

43+
public function testWsseWithWsaCall()
44+
{
45+
Soap::fake();
46+
$client = Soap::baseWsdl('https://laravel-soap.wsdl')->withWsse([
47+
'userTokenName' => 'Test',
48+
'userTokenPassword' => 'passwordTest',
49+
'mustUnderstand' => false,
50+
])->withWsa();
51+
$response = $client->Get_User();
52+
$lastRequestInfo = $client->getEngine()->collectLastRequestInfo();
53+
self::assertStringNotContainsString('mustUnderstand', $lastRequestInfo->getLastRequest());
54+
// dd($client->debugLastSoapRequest());
55+
self::assertTrue($response->ok());
56+
}
57+
4358
public function testArrayAccessResponse()
4459
{
4560
Soap::fakeSequence()->push('test');

0 commit comments

Comments
 (0)