diff --git a/src/Middleware/WsseMiddleware.php b/src/Middleware/WsseMiddleware.php index cc67c21..20f4bec 100644 --- a/src/Middleware/WsseMiddleware.php +++ b/src/Middleware/WsseMiddleware.php @@ -62,6 +62,11 @@ class WsseMiddleware extends Middleware */ private $encrypt = false; + /** + * @var bool + */ + private $mustUnderstand = true; + /** * @var bool */ @@ -127,7 +132,7 @@ public function withServerCertificateHasSubjectKeyIdentifier(bool $hasSubjectKey public function beforeRequest(callable $handler, RequestInterface $request): Promise { $xml = SoapXml::fromStream($request->getBody()); - $wsse = new WSSESoap($xml->getXmlDocument()); + $wsse = new WSSESoap($xml->getXmlDocument(), $this->mustUnderstand); // Prepare the WSSE soap class: $wsse->signAllHeaders = $this->signAllHeaders; diff --git a/tests/Unit/SoapClientTest.php b/tests/Unit/SoapClientTest.php index b2be530..c6c4290 100644 --- a/tests/Unit/SoapClientTest.php +++ b/tests/Unit/SoapClientTest.php @@ -40,6 +40,21 @@ public function testMagicCallByConfig() self::assertTrue($response->ok()); } + public function testWsseWithWsaCall() + { + Soap::fake(); + $client = Soap::baseWsdl('https://laravel-soap.wsdl')->withWsse([ + 'userTokenName' => 'Test', + 'userTokenPassword' => 'passwordTest', + 'mustUnderstand' => false, + ])->withWsa(); + $response = $client->Get_User(); + $lastRequestInfo = $client->getEngine()->collectLastRequestInfo(); + self::assertStringNotContainsString('mustUnderstand', $lastRequestInfo->getLastRequest()); +// dd($client->debugLastSoapRequest()); + self::assertTrue($response->ok()); + } + public function testArrayAccessResponse() { Soap::fakeSequence()->push('test');