Class: WSDL::Security::XmlBuilderHelper
- Inherits:
-
Object
- Object
- WSDL::Security::XmlBuilderHelper
- Defined in:
- lib/wsdl/security/xml_builder_helper.rb
Overview
Helper for building XML with or without explicit namespace prefixes.
Some SOAP servers have strict XML parsers that only accept elements
with explicit namespace prefixes (e.g., ds:Signature instead of
Signature xmlns="..."). This helper provides a unified interface
for building XML that works in both modes.
Constant Summary collapse
- SecurityNS =
Local aliases for namespace constants
Constants::NS::Security
- SignatureNS =
Alias for XML Signature namespace constants.
Constants::NS::Signature
- NAMESPACE_URIS =
Namespace prefix to URI mapping
{ ds: SignatureNS::DS, wsse: SecurityNS::WSSE, wsu: SecurityNS::WSU, ec: SignatureNS::EC }.freeze
Instance Attribute Summary collapse
-
#explicit_prefixes ⇒ Boolean
readonly
Returns whether explicit namespace prefixes are enabled.
Instance Method Summary collapse
-
#build_child(xml, ns_prefix, element_name, content_or_attributes = nil, attributes = {}) { ... } ⇒ Object
Builds a child element (inherits namespace from parent).
-
#build_child_with_ns(xml, ns_prefix, element_name, attributes = {}) { ... } ⇒ Object
Builds a child element with explicit namespace declaration.
-
#build_element(xml, ns_prefix, element_name, attributes = {}) { ... } ⇒ Object
Builds a root element with namespace declaration.
-
#initialize(explicit_prefixes: false) ⇒ XmlBuilderHelper
constructor
Creates a new XmlBuilderHelper instance.
Constructor Details
#initialize(explicit_prefixes: false) ⇒ XmlBuilderHelper
Creates a new XmlBuilderHelper instance.
57 58 59 |
# File 'lib/wsdl/security/xml_builder_helper.rb', line 57 def initialize(explicit_prefixes: false) @explicit_prefixes = explicit_prefixes end |
Instance Attribute Details
#explicit_prefixes ⇒ Boolean (readonly)
Returns whether explicit namespace prefixes are enabled.
51 52 53 |
# File 'lib/wsdl/security/xml_builder_helper.rb', line 51 def explicit_prefixes @explicit_prefixes end |
Instance Method Details
#build_child(xml, ns_prefix, element_name, content_or_attributes = nil, attributes = {}) { ... } ⇒ Object
Builds a child element (inherits namespace from parent).
82 83 84 85 |
# File 'lib/wsdl/security/xml_builder_helper.rb', line 82 def build_child(xml, ns_prefix, element_name, content_or_attributes = nil, attributes = {}, &) content, attrs = resolve_arguments(content_or_attributes, attributes) invoke(xml, ns_prefix, element_name, attrs, content, &) end |
#build_child_with_ns(xml, ns_prefix, element_name, attributes = {}) { ... } ⇒ Object
Builds a child element with explicit namespace declaration.
95 96 97 |
# File 'lib/wsdl/security/xml_builder_helper.rb', line 95 def build_child_with_ns(xml, ns_prefix, element_name, attributes = {}, &) invoke(xml, ns_prefix, element_name, ns_attributes(ns_prefix).merge(attributes), &) end |
#build_element(xml, ns_prefix, element_name, attributes = {}) { ... } ⇒ Object
Builds a root element with namespace declaration.
69 70 71 |
# File 'lib/wsdl/security/xml_builder_helper.rb', line 69 def build_element(xml, ns_prefix, element_name, attributes = {}, &) invoke(xml, ns_prefix, element_name, ns_attributes(ns_prefix).merge(attributes), &) end |