44
55namespace SimpleSAML \WSDL \XML \soap12 ;
66
7- use DOMElement ;
7+ use Dom ;
88use SimpleSAML \Assert \Assert ;
9- use SimpleSAML \WSDL \Constants as C ;
9+ use SimpleSAML \WSDL \Constants as C_WSDL ;
1010use SimpleSAML \WSDL \Type \RequiredValue ;
1111use SimpleSAML \WSDL \Type \UseChoiceValue ;
1212use SimpleSAML \WSDL \XML \wsdl \AbstractExtensibilityElement ;
13+ use SimpleSAML \XML \Attribute as XMLAttribute ;
14+ use SimpleSAML \XML \Constants as C ;
1315use SimpleSAML \XMLSchema \Exception \InvalidDOMElementException ;
1416use SimpleSAML \XMLSchema \Exception \SchemaViolationException ;
1517use SimpleSAML \XMLSchema \Type \AnyURIValue ;
@@ -26,7 +28,7 @@ abstract class AbstractHeader extends AbstractExtensibilityElement
2628 use BodyAttributesTrait;
2729
2830
29- public const string NS = C ::NS_WSDL_SOAP_12 ;
31+ public const string NS = C_WSDL ::NS_WSDL_SOAP_12 ;
3032
3133 public const string NS_PREFIX = 'soap12 ' ;
3234
@@ -102,19 +104,19 @@ public function getParts(): ?NMTokensValue
102104 /**
103105 * Initialize a Header element.
104106 *
105- * @param \DOMElement $xml The XML element we should load.
107+ * @param \Dom\Element $xml The XML element we should load.
106108 *
107109 * @throws \SimpleSAML\XMLSchema\Exception\InvalidDOMElementException
108110 * if the qualified name of the supplied element is wrong
109111 */
110- public static function fromXML (DOMElement $ xml ): static
112+ public static function fromXML (Dom \ Element $ xml ): static
111113 {
112114 Assert::same ($ xml ->localName , static ::getLocalName (), InvalidDOMElementException::class);
113115 Assert::same ($ xml ->namespaceURI , static ::NS , InvalidDOMElementException::class);
114116
115117 $ required = null ;
116- if ($ xml ->hasAttributeNS (C ::NS_WSDL , 'required ' )) {
117- $ required = RequiredValue::fromString ($ xml ->getAttributeNS (C ::NS_WSDL , 'required ' ));
118+ if ($ xml ->hasAttributeNS (C_WSDL ::NS_WSDL , 'required ' )) {
119+ $ required = RequiredValue::fromString ($ xml ->getAttributeNS (C_WSDL ::NS_WSDL , 'required ' ));
118120 }
119121
120122 return new static (
@@ -132,13 +134,23 @@ public static function fromXML(DOMElement $xml): static
132134 /**
133135 * Convert this tHeader to XML.
134136 *
135- * @param \DOMElement |null $parent The element we are converting to XML.
136- * @return \DOMElement The XML element after adding the data corresponding to this tHeader
137+ * @param \Dom\Element |null $parent The element we are converting to XML.
138+ * @return \Dom\Element The XML element after adding the data corresponding to this tHeader
137139 */
138- public function toXML (?DOMElement $ parent = null ): DOMElement
140+ public function toXML (?Dom \ Element $ parent = null ): Dom \ Element
139141 {
140142 $ e = parent ::toXML ($ parent );
141143
144+ if (!$ e ->lookupPrefix ($ this ->getMessage ()->getNamespacePrefix ()->getValue ())) {
145+ $ namespace = new XMLAttribute (
146+ C::NS_XMLNS ,
147+ 'xmlns ' ,
148+ $ this ->getMessage ()->getNamespacePrefix ()->getValue (),
149+ $ this ->getMessage ()->getNamespaceURI (),
150+ );
151+ $ namespace ->toXML ($ e );
152+ }
153+
142154 $ e ->setAttribute ('message ' , $ this ->getMessage ()->getValue ());
143155 $ e ->setAttribute ('parts ' , $ this ->getParts ()->getValue ());
144156 $ e ->setAttribute ('use ' , $ this ->getUse ()->getValue ());
0 commit comments