# Soap4r header without a namespace

**URL:** <https://www.ruby-forum.com/t/soap4r-header-without-a-namespace/177157>\
**Category:** Ruby\
**Created:** [October 12, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/soap4r-header-without-a-namespace/177157 "2009-10-12T16:56:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wemagor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/8edcca/32.png) [@wemagor](https://www.ruby-forum.com/u/wemagor)\
**Post date:** [October 12, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/soap4r-header-without-a-namespace/177157/1 "2009-10-12T16:56:43Z")

</div>

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?
