I was able to get the namespace abbreviations right by returning a hash
from on_simple_outbound instead of a string, letting the API handle the
conversion to XML.
A handler to add authentication parameters to the SOAP header.
class AutheticationHeaderHandler < SOAP::Header::SimpleHandler
@@HEADER_NAME = ‘WSAuthHeader’
def initialize(namespace, username, password)
super(XSD::QName.new(namespace, @@HEADER_NAME))
@user_element = XSD::QName.new(namespace, ‘User’)
@password_element = XSD::QName.new(namespace, ‘Password’)
@username, @password = username, password
end
def on_simple_outbound
# Seems to result in the creation of elements with the proper
namespace
# abbreviation, e.g. ‘ns1:UserJohnDoe</ns1:User>’
{@user_element => @username, @password_element => @password}
end
end
… As before …
ws.headerhandler << AutheticationHeaderHandler.new(namespace, user,
password)
Of course, this could be generalized to handle an arbitrary set of child
data, as in your example below.
Thanks again!
Brian H.