# SOAP / EncodingStyle

**URL:** <https://www.ruby-forum.com/t/soap-encodingstyle/48826>\
**Category:** Ruby\
**Created:** [November 25, 2005, 11:55am UTC](https://www.ruby-forum.com/t/soap-encodingstyle/48826 "2005-11-25T11:55:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabienpenso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/838e76/32.png) [@fabienpenso](https://www.ruby-forum.com/u/fabienpenso)\
**Post date:** [November 25, 2005, 11:55am UTC](https://www.ruby-forum.com/t/soap-encodingstyle/48826/1 "2005-11-25T11:55:38Z")

</div>

Hi.

I’ve been trying to do something with SOAP for hours with no luck. I  
need to get a request that looks like :

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

\<SOAP-ENV:Envelope  
xmlns:SOAP-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)”  
xmlns:xsd=“[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)”\>  
SOAP-ENV:Body  
\<ns1:getEligibilite xmlns:ns1=“urn:eligibilite”\>  
foobar  
  
101  
…

and I get :

\<?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  
\<n1:getEligibilite xmlns:n1=“urn:eligibilite”  
env:encodingStyle=“[http://schemas.xmlsoap.org/soap/encoding/](http://schemas.xmlsoap.org/soap/encoding/)”\>  
foobar  
  
101  
…

Note the encodingStyle specified in the n1 part of the XML, and not in  
the nd part. The server gives me an error, and I beleive because of it.  
The code currently looks like :

```
106 map = SOAP::Mapping::Registry.new
107 map.set(IntArray, SOAP::SOAPArray,
108 SOAP::Mapping::Registry::TypedArrayFactory,
109 { :type => XSD::QName.new('urn:eligibilite',

```

‘int’) })  
110  
111 # On met le mapper  
112 soap.mapping\_registry = map  
113 soap.default\_encodingstyle =  
SOAP::EncodingStyle::SOAPHandler::Namespace  
114  
115 #soapObj = SOAP::Marshal.marshal( IntArray[ 101, 102, 103  
], map )  
116  
117 soap.getEligibilite(“foobar”, IntArray[ 101, 102, 103  
],“”,“something”)

I’ve already spent hours on that soap part just to find documentation  
to be able to send an Array of int[] … Anyone has a  
hint/documentation how I could fix my request and move on ? 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![fabienpenso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/838e76/32.png) [@fabienpenso](https://www.ruby-forum.com/u/fabienpenso)\
**Post date:** [November 26, 2005, 2:33pm UTC](https://www.ruby-forum.com/t/soap-encodingstyle/48826/2 "2005-11-26T14:33:14Z")

</div>

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

Hi,

Fabien P. wrote:

> Note the encodingStyle specified in the n1 part of the XML, and not in  
> the nd part. The server gives me an error, and I beleive because of it.  
> The code currently looks like :

I think the cause of the problem is that you are sending  
arrayType=“{urn:eligibilite}int[]”, not  
arrayType=“{[http://www.w3.org/2001/XMLSchema](http://www.w3.org/2001/XMLSchema)}:int[]”.

> ```
> 106 map = SOAP::Mapping::Registry.new
> 107 map.set(IntArray, SOAP::SOAPArray,
> 108 SOAP::Mapping::Registry::TypedArrayFactory,
> 109 { :type => XSD::QName.new('urn:eligibilite',
> 
> ```
> 
> ‘int’) })

It should be { :type =\> XSD::XSDInt::Type } here.

0% cat intarray.rb  
require ‘soap/marshal’  
include SOAP::Mapping

class IntArray \< Array; end

map = Registry.new  
map.set(IntArray, SOAP::SOAPArray, Registry::TypedArrayFactory,  
{ :type =\> XSD::QName.new(‘urn:eligibilite’, ‘int’) })  
puts SOAP::Marshal.marshal(IntArray[1, 2, 3], map)

puts

map2 = Registry.new  
map2.set(IntArray, SOAP::SOAPArray, Registry::TypedArrayFactory,  
{ :type =\> XSD::XSDInt::Type })  
puts SOAP::Marshal.marshal(IntArray[1, 2, 3], map2)

0% ruby intarray.rb

\<?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  
  
1  
2  
3  
  
\</env:Body\>  
\</env:Envelope\>

\<?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  
  
1  
2  
3  
  
\</env:Body\>  
\</env:Envelope\>

Please tell me if it won’t work.

Regards,  
// NaHi  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.1 (Cygwin)

iD8DBQFDiGLnf6b33ts2dPkRAp+gAKCQ/Kz7f/t8jVOEqLW7qWKD+z9AUACffmtZ  
DlLKHg5mGYWFRj85g+dpp48=  
=G0EH  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![fabienpenso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/838e76/32.png) [@fabienpenso](https://www.ruby-forum.com/u/fabienpenso)\
**Post date:** [November 28, 2005, 3:45pm UTC](https://www.ruby-forum.com/t/soap-encodingstyle/48826/3 "2005-11-28T15:45:29Z")

</div>

Hi.

Works like a charm. Thanks !
