# SOAP request formed correctly the first time, extra env:Header/ tag added on subsequent invocations

**URL:** <https://www.ruby-forum.com/t/soap-request-formed-correctly-the-first-time-extra-env-header-tag-added-on-subsequent-invocations/142811>\
**Category:** Rails\
**Created:** [July 11, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/soap-request-formed-correctly-the-first-time-extra-env-header-tag-added-on-subsequent-invocations/142811 "2008-07-11T19:01:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/bb73d2/32.png) [@ian](https://www.ruby-forum.com/u/ian)\
**Post date:** [July 11, 2008, 7:01pm UTC](https://www.ruby-forum.com/t/soap-request-formed-correctly-the-first-time-extra-env-header-tag-added-on-subsequent-invocations/142811/1 "2008-07-11T19:01:01Z")

</div>

I have the following code in a controller. New to Rails, so please  
tell me if I’m doing something here that should be in a different part  
of the application. The weird thing is that this code works fine ONCE,  
the first pageload after starting up the application. Every subsequent  
pageload produces a “org.xml.sax.SAXException: Only one Header element  
allowed!” error from the remote webservice. Looking at the XML  
wiredumps, the SOAP request sent the first time is correct, but on  
subsequent executions the SOAP request has an extra env:Header/ (with  
the / at the END of the tag) tag right before the env:Body tag.

class GethelpnowController \< ApplicationController  
def index  
require ‘wss4r/rpc/wssdriver’  
require ‘customsimpleheader’

```
obj = MCWSGateway.new()
obj.wiredump_dev = STDERR
obj.headerhandler << CustomSimpleHeader.new

usernametoken = UsernameToken.new("username","password",:type =>

```

‘PLAIN’)  
obj.security.add\_security\_token(usernametoken)

```
aq = AuthorRetrieve.new("",00000,"")
puts obj.retrieveAuthor(aq)

```

end  
end

Thanks,  
Ian
