-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
300 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/Metadata/Converter/Methods/Configurator/Binding/BindingConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Converter\Methods\Configurator\Binding; | ||
|
||
use Soap\Engine\Metadata\Model\Method; | ||
use Soap\WsdlReader\Model\Definitions\Binding; | ||
use function Psl\Fun\pipe; | ||
|
||
final class BindingConfigurator | ||
{ | ||
public function __invoke(Method $method, Binding $binding): Method | ||
{ | ||
return pipe( | ||
static fn (Method $method) => (new HttpBindingConfigurator())($method, $binding), | ||
static fn (Method $method) => (new SoapBindingConfigurator())($method, $binding), | ||
)($method); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Metadata/Converter/Methods/Configurator/Binding/HttpBindingConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Converter\Methods\Configurator\Binding; | ||
|
||
use Soap\Engine\Metadata\Model\Method; | ||
use Soap\Engine\Metadata\Model\MethodMeta; | ||
use Soap\WsdlReader\Model\Definitions\Binding; | ||
use Soap\WsdlReader\Model\Definitions\Implementation\Binding\HttpBinding; | ||
|
||
final class HttpBindingConfigurator | ||
{ | ||
public function __invoke(Method $method, Binding $binding): Method | ||
{ | ||
$implementation = $binding->implementation; | ||
if (!$implementation instanceof HttpBinding) { | ||
return $method; | ||
} | ||
|
||
return $method->withMeta( | ||
static fn (MethodMeta $meta): MethodMeta => $meta | ||
->withTransport($implementation->transport->value) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/Metadata/Converter/Methods/Configurator/Operation/HttpBindingOperationConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Converter\Methods\Configurator\Operation; | ||
|
||
use Soap\Engine\Metadata\Model\Method; | ||
use Soap\Engine\Metadata\Model\MethodMeta; | ||
use Soap\WsdlReader\Model\Definitions\BindingOperation; | ||
use Soap\WsdlReader\Model\Definitions\BindingStyle; | ||
use Soap\WsdlReader\Model\Definitions\BindingUse; | ||
use Soap\WsdlReader\Model\Definitions\EncodingStyle; | ||
use Soap\WsdlReader\Model\Definitions\Implementation\Message\HttpMessage; | ||
use Soap\WsdlReader\Model\Definitions\Implementation\Operation\HttpOperation; | ||
use Soap\WsdlReader\Model\Definitions\SoapVersion; | ||
|
||
final class HttpBindingOperationConfigurator | ||
{ | ||
public function __invoke(Method $method, BindingOperation $operation): Method | ||
{ | ||
$implementation = $operation->implementation; | ||
if (!$implementation instanceof HttpOperation) { | ||
return $method; | ||
} | ||
|
||
if (!$this->messageIsConsideredSoap($operation)) { | ||
return $method; | ||
} | ||
|
||
$guessedSoapVersion = $implementation->transport->guessSoapVersion(); | ||
$guessedBindingUse = $this->guessBindingUse($guessedSoapVersion); | ||
$guessedEncodingStyle = $this->guessEncodingStyle($guessedSoapVersion); | ||
|
||
return $method->withMeta( | ||
static fn (MethodMeta $meta): MethodMeta => $meta | ||
->withSoapVersion($guessedSoapVersion?->value) | ||
->withAction('') // Soap Action is considered empty for HTTP binding. | ||
->withOperationName($operation->name) | ||
->withBindingStyle(BindingStyle::RPC->value) | ||
->withInputBindingUsage($guessedBindingUse?->value) | ||
->withInputEncodingStyle($guessedEncodingStyle?->value) | ||
->withOutputBindingUsage($guessedBindingUse?->value) | ||
->withOutputEncodingStyle($guessedEncodingStyle?->value) | ||
); | ||
} | ||
|
||
private function messageIsConsideredSoap(BindingOperation $operation): bool | ||
{ | ||
$input = $operation->input?->implementation; | ||
if (!$input instanceof HttpMessage) { | ||
return false; | ||
} | ||
|
||
return $input->isConsideredSoapContentType(); | ||
} | ||
|
||
private function guessEncodingStyle(?SoapVersion $soapVersion): ?EncodingStyle | ||
{ | ||
return match ($soapVersion) { | ||
SoapVersion::SOAP_11 => EncodingStyle::SOAP_11, | ||
SoapVersion::SOAP_12 => EncodingStyle::SOAP_12_2003_05, | ||
default => null, | ||
}; | ||
} | ||
|
||
private function guessBindingUse(?SoapVersion $soapVersion): ?BindingUse | ||
{ | ||
return match ($soapVersion) { | ||
SoapVersion::SOAP_11 => BindingUse::ENCODED, | ||
SoapVersion::SOAP_12 => BindingUse::LITERAL, | ||
default => null, | ||
}; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/Metadata/Converter/Methods/Configurator/Operation/OperationConfigurator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Soap\WsdlReader\Metadata\Converter\Methods\Configurator\Operation; | ||
|
||
use Soap\Engine\Metadata\Model\Method; | ||
use Soap\WsdlReader\Model\Definitions\BindingOperation; | ||
use function Psl\Fun\pipe; | ||
|
||
final readonly class OperationConfigurator | ||
{ | ||
public function __invoke(Method $method, BindingOperation $operation): Method | ||
{ | ||
return pipe( | ||
static fn (Method $method) => (new HttpBindingOperationConfigurator())($method, $operation), | ||
static fn (Method $method) => (new SoapBindingOperationConfigurator())($method, $operation), | ||
)($method); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.