# Problems with SOAP: duplicate XML declarations

**URL:** <https://www.ruby-forum.com/t/problems-with-soap-duplicate-xml-declarations/161169>\
**Category:** Ruby\
**Created:** [June 18, 2007, 1:03am UTC](https://www.ruby-forum.com/t/problems-with-soap-duplicate-xml-declarations/161169 "2007-06-18T01:03:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2007, 1:03am UTC](https://www.ruby-forum.com/t/problems-with-soap-duplicate-xml-declarations/161169/1 "2007-06-18T01:03:30Z")

</div>

Hi,

I’m trying to implement a SOAP client using the native Ruby SOAP  
client library. Here’s the relevant bit of code:

```
 XSD::Charset.encoding = 'UTF8' # Set

```

encoding  
wsdlfile = “[http://ws.interfax.net/dfs.asmx?wsdl](http://ws.interfax.net/dfs.asmx?wsdl)” # WSDL  
location  
driver =  
SOAP::WSDLDriverFactory.new(wsdlfile).create\_rpc\_driver # Create  
driver

# and set up

# methods

```
 driver.wiredump_dev = STDERR # output SOAP transactions to STDERR
 @result = driver.SendCharFax({:Username => username, :Password =>

```

password, :FaxNumber =\> destinationfaxnumber, :Data =\>  
‘hello’, :FileType =\> ‘’})

For some reason, this is sending XML with two XML declarations! Here  
is what it is sending:

\<?xml version="1.0" encoding="utf-8" ?\>

\<env:Envelope xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”  
xmlns:env=“[http://schemas.xmlsoap.org/soap/envelope/](http://schemas.xmlsoap.org/soap/envelope/)”  
xmlns:xsi=“[http://www.w3.org/2001/XMLSchema-instance](http://www.w3.org/2001/XMLSchema-instance)”\>  
env:Body

\<?xml version="1.0" encoding="UTF-8"?\> pass123 001801751234 hello faxuser 

I’ve tried to figure out what’s going, tried searching Google and also  
asked another Ruby developer, but neither of us have a clue why it’s  
doing this.

Can anybody point me in the right direction?

Cheers,

Jon  
PS: This is the first application I’ve written in Ruby… so don’t  
discount obvious solutions 😉

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 18, 2007, 3:35pm UTC](https://www.ruby-forum.com/t/problems-with-soap-duplicate-xml-declarations/161169/2 "2007-06-18T15:35:08Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

removed\_email\_address@domain.invalid wrote:

> I’m trying to implement a SOAP client using the native Ruby SOAP  
> client library. Here’s the relevant bit of code:

> For some reason, this is sending XML with two XML declarations! Here  
> is what it is sending:

What version of soap4r are you using? The versions from  
soap4r-1.5.5.20070519 to soap4r-1.5.5.20070605 try to call ‘to\_xml’  
method of parameters. Later versions try to call ‘to\_xmlpart’ instead  
of ‘to\_xml’. Just updating soap4r should solve the problem.

Regards,  
// NaHi

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.2.1 (Cygwin)

iQEVAwUBRnaJuh9L2jg5EEGlAQIQVAf/TsfXyi1xyjjkr+4E+j3FVBW46nRNbbxu  
HktnHj3OQMIotpv9FAGv0jGJq+C87ca9fCQSg+4xV8fauSVWEkZXJHotRkZ+gTQS  
3lOtU8+IAvSuxzlMGIWjUgwFXkSTSeN/SvWrbt0cdk/pINIumxl5ATaRQ/WK6gUD  
kqf9WMpbwUfvRuiNqnmmMWk5rPpBoLnoLWB3/wnFS+ksodZOcUGFDTRdGs0Ivo9h  
mlz+b31JhQoIFaxsWcucMuM0itpuzgfTEe2eYFe7sBbEY1p7W4fF3Lc+238ydu6q  
xqfTBUz0+ajIzmMIboLN6otGob5OcnwR7aUNMa97HYLnq81ryWHmNg==  
=4hGI  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [June 19, 2007, 3:15am UTC](https://www.ruby-forum.com/t/problems-with-soap-duplicate-xml-declarations/161169/3 "2007-06-19T03:15:16Z")

</div>

Yay! I updated all my gems (“gem update”) including soap4r, restarted  
the server and voila! Correct XML and it’s all working again 🙂

Thanks for your help!

Cheers,

Jon
