W
Wayne Molina
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, assword
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:Username>myusername</n1:Username>
<n1assword>topsecret</n1assword>
</n1:dummy>
</env:Header>
When the web service is expecting it to look like this:
<env:Header>
<n1:Username>myusername</n1:Username>
<n1assword>topsecret</n1assword>
</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?
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, assword
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:Username>myusername</n1:Username>
<n1assword>topsecret</n1assword>
</n1:dummy>
</env:Header>
When the web service is expecting it to look like this:
<env:Header>
<n1:Username>myusername</n1:Username>
<n1assword>topsecret</n1assword>
</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?