Soap4r header without a namespace

Hello all. I’m trying to create a header using soap4r and the web
service I’m calling requires a Username and Password to be sent as
individual elements of the header. I’ve overridden
SOAP::Header::SimpleHandler as follows:

class CelltrustAuthHeader < SOAP::Header::SimpleHandler
attr_accessor :username, :password

def initialize(username, password)
super(XSD::QName::EMPTY)
@username, @password = username, password
end

def on_simple_outbound
{“Username” => @username, “Password” => @password}
end
end

However this is giving me an error when I call the web services method
stating SOAP::Generator::FormatEncodeError: Element name not defined:
#SOAP::SOAPElement:0x122c968.

If I pass in dummy values to the call to super, then it executes the
request but the response gives me an error (“Security Violation” which
means that it’s not getting my username/password) since the request XML
looks like this:

env:Header
<n1:dummy env:mustUnderstand=“0”
xmlns:n1=“dummy”>
n1:Usernamemyusername</n1:Username>
n1:Passwordtopsecret</n1:Password>
</n1:dummy>
</env:Header>

When the web service is expecting it to look like this:

env:Header
n1:Usernamemyusername</n1:Username>
n1:Passwordtopsecret</n1:Password>
</env:Header>

I don’t need or want the <n1:text env:mustUnderstand=“0”
xmlns:n1=“text”> portion; how can I get rid of it?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs