1212use Soap \WsdlReader \Model \Definitions \SoapVersion ;
1313use Soap \Xml \Xmlns ;
1414use VeeWee \Xml \Exception \RuntimeException as XmlRuntimeException ;
15- use VeeWee \Xml \Writer \Writer ;
1615use XMLWriter ;
1716use function Psl \Vec \filter_nulls ;
1817use function VeeWee \Xml \Writer \Builder \children ;
1918use function VeeWee \Xml \Writer \Builder \namespace_attribute ;
2019use function VeeWee \Xml \Writer \Builder \namespaced_attribute ;
2120use function VeeWee \Xml \Writer \Builder \namespaced_element ;
22- use function VeeWee \Xml \Writer \Mapper \memory_output ;
2321
2422final class SoapEnvelopeWriter
2523{
@@ -45,45 +43,43 @@ public function __invoke(): string
4543 };
4644
4745 try {
48- return Writer ::inMemory ()
49- ->write (
46+ return (new InMemoryXmlWriter ())(
47+ namespaced_element (
48+ $ envelopeNamespace ,
49+ 'SOAP-ENV ' ,
50+ 'Envelope ' ,
5051 namespaced_element (
5152 $ envelopeNamespace ,
5253 'SOAP-ENV ' ,
53- 'Envelope ' ,
54- namespaced_element (
55- $ envelopeNamespace ,
56- 'SOAP-ENV ' ,
57- 'Body ' ,
58- children (
59- filter_nulls ([
60- // In SOAP 1.2 the position of the encoding attributes is limited:
61- // See: https://www.w3.org/TR/soap12-part1/#soapencattr
62- // For SOAP 1.1 it can be everywhere:
63- // See: https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383495
64- $ this ->encodingStyle
65- ->filter (fn (): bool => $ this ->bindingUse === BindingUse::ENCODED )
66- ->map (
67- static fn (EncodingStyle $ encodingStyle ) => children ([
68- namespace_attribute (
69- $ encodingStyle ->value ,
70- 'SOAP-ENC '
71- ),
72- namespaced_attribute (
73- $ envelopeNamespace ,
74- 'SOAP-ENV ' ,
75- 'encodingStyle ' ,
76- $ encodingStyle ->value
77- )
78- ])
79- )->unwrapOr (null ),
80- $ this ->children
81- ])
82- )
54+ 'Body ' ,
55+ children (
56+ filter_nulls ([
57+ // In SOAP 1.2 the position of the encoding attributes is limited:
58+ // See: https://www.w3.org/TR/soap12-part1/#soapencattr
59+ // For SOAP 1.1 it can be everywhere:
60+ // See: https://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383495
61+ $ this ->encodingStyle
62+ ->filter (fn (): bool => $ this ->bindingUse === BindingUse::ENCODED )
63+ ->map (
64+ static fn (EncodingStyle $ encodingStyle ) => children ([
65+ namespace_attribute (
66+ $ encodingStyle ->value ,
67+ 'SOAP-ENC '
68+ ),
69+ namespaced_attribute (
70+ $ envelopeNamespace ,
71+ 'SOAP-ENV ' ,
72+ 'encodingStyle ' ,
73+ $ encodingStyle ->value
74+ )
75+ ])
76+ )->unwrapOr (null ),
77+ $ this ->children
78+ ])
8379 )
8480 )
8581 )
86- -> map ( memory_output () );
82+ );
8783 } catch (XmlRuntimeException $ e ) {
8884 throw ($ e ->getPrevious () instanceof EncodingExceptionInterface) ? $ e ->getPrevious () : $ e ;
8985 }
0 commit comments