33
44namespace Soap \Encoding ;
55
6- use Soap \Encoding \Encoder \Context ;
7- use Soap \Encoding \Xml \Writer \OperationBuilder ;
8- use Soap \Encoding \Xml \Writer \ParameterBuilder ;
9- use Soap \Encoding \Xml \Writer \SoapEnvelopeWriter ;
6+ use Soap \Encoding \Encoder \Method \MethodContext ;
7+ use Soap \Encoding \Encoder \Method \RequestEncoder ;
108use Soap \Engine \Encoder as SoapEncoder ;
119use Soap \Engine \HttpBinding \SoapRequest ;
1210use Soap \Engine \Metadata \Metadata ;
13- use Soap \WsdlReader \Model \Definitions \BindingUse ;
14- use Soap \WsdlReader \Model \Definitions \EncodingStyle ;
1511use Soap \WsdlReader \Model \Definitions \Namespaces ;
1612use Soap \WsdlReader \Model \Definitions \SoapVersion ;
17- use function VeeWee \ Reflecta \ Lens \ index ;
13+ use function Psl \ Type \ mixed_vec ;
1814
1915final class Encoder implements SoapEncoder
2016{
@@ -29,26 +25,12 @@ public function encode(string $method, array $arguments): SoapRequest
2925 {
3026 $ methodInfo = $ this ->metadata ->getMethods ()->fetchByName ($ method );
3127 $ meta = $ methodInfo ->getMeta ();
32-
28+ $ methodContext = new MethodContext ( $ methodInfo , $ this -> metadata , $ this -> registry , $ this -> namespaces );
3329 $ soapVersion = $ meta ->soapVersion ()->map (SoapVersion::from (...))->unwrapOr (SoapVersion::SOAP_12 );
34- $ bindingUse = $ meta ->inputBindingUsage ()->map (BindingUse::from (...))->unwrapOr (BindingUse::LITERAL );
35- $ encodingStyle = $ meta ->inputEncodingStyle ()->map (EncodingStyle::from (...));
36-
37- $ requestParams = [];
38- foreach ($ methodInfo ->getParameters () as $ index => $ parameter ) {
39- $ type = $ parameter ->getType ();
40- $ context = new Context ($ type , $ this ->metadata , $ this ->registry , $ this ->namespaces , $ bindingUse );
41- /** @var mixed $value */
42- $ value = index ($ index )->get ($ arguments );
43-
44- $ requestParams [] = (new ParameterBuilder ($ meta , $ context , $ value ))(...);
45- }
46-
47- $ operation = new OperationBuilder ($ meta , $ this ->namespaces , $ requestParams );
48- $ writeEnvelope = new SoapEnvelopeWriter ($ soapVersion , $ bindingUse , $ encodingStyle , $ operation (...));
30+ $ iso = (new RequestEncoder ())->iso ($ methodContext );
4931
5032 return new SoapRequest (
51- $ writeEnvelope () . PHP_EOL ,
33+ $ iso -> to ( mixed_vec ()-> assert ( $ arguments )) ,
5234 $ meta ->location ()->unwrap (),
5335 $ meta ->action ()->unwrap (),
5436 match ($ soapVersion ) {
0 commit comments