# Wrong soap4r interpretation of a WSDL

**URL:** <https://www.ruby-forum.com/t/wrong-soap4r-interpretation-of-a-wsdl/175585>\
**Category:** Rails\
**Created:** [September 16, 2009, 1:49am UTC](https://www.ruby-forum.com/t/wrong-soap4r-interpretation-of-a-wsdl/175585 "2009-09-16T01:49:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [September 16, 2009, 1:49am UTC](https://www.ruby-forum.com/t/wrong-soap4r-interpretation-of-a-wsdl/175585/1 "2009-09-16T01:49:34Z")

</div>

Hi guys,

I had a piece of code that was working perfectly fine. I went on to  
work on something else in my app, updated a few gems in the process…  
Now the first bit of code doesn’t work anymore, and I am lost. It  
seems soap4r has decided to do things wrong - but I don’t know which  
gem is impacting it.

The wsdl element is:

\<xs:element name=“GetUserDetailRequest”\>  
xs:complexType  
xs:complexContent  
\<xs:extension base=“tns:RequestBase”\>  
xs:choice  
\<xs:element name=“Id” type=“xs:long”\>  
\</xs:element\>  
\<xs:element name=“SecondId” type=“xs:string”\>  
\</xs:element\>  
\</xs:choice\>  
\</xs:extension\>  
\</xs:complexContent\>  
\</xs:complexType\>  
\</xs:element\>

with RequestBase:

\<xs:complexType name=“RequestBase”\>  
xs:sequence  
\<xs:element name=“LocalStuff” type=“xs:string”\>  
\</xs:element\>  
\<xs:element name=“CodeP” type=“xs:string”\>  
\</xs:element\>  
\</xs:sequence\>  
\</xs:complexType\>

When I call:

result = driver.getUserDetail(:CodeP =\> xxx, :LocalStuff =\> xxx, :Id  
=\> xxx)

the SOAP message generated is:

\<?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:GetUserDetailRequest xmlns:n1=“[http://mywsdl](http://mywsdl)”\>  
n1:LocalStuffen-GB\</n1:LocalStuff\>  
\</n1:GetUserDetailRequest\>  
\</env:Body\>  
\</env:Envelope\>

which is wrong (notably it misses CodeP) and returns an error from the  
webservice. It used to work perfectly.

Do you guys know which gem update could be “conflicting” with soap4r?

Thanks!

---

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [September 16, 2009, 3:20pm UTC](https://www.ruby-forum.com/t/wrong-soap4r-interpretation-of-a-wsdl/175585/2 "2009-09-16T15:20:12Z")

</div>

I ran wsdl2ruby on the WSDL file, and indeed, the  
defaultMappingRegistry.rb file has changed, and it is now wrong:

NOW:  
LiteralRegistry.register(  
:class =\> GetUsertDetailRequest,  
:schema\_name =\> XSD::QName.new(NsC\_0, “GetUsertDetailRequest”),  
:schema\_element =\> [ :choice,  
[“localStuff”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0,  
“LocalStuff”)]],  
[“codeP”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0, “CodeP”)]],  
[“id”, [“SOAP::SOAPLong”, XSD::QName.new(NsC\_0, “Id”)]],  
[“secondId”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0,  
“SecondId”)]]  
]  
)

the parameters shouldn’t be a choice like that. Indeed, they WERE:

LiteralRegistry.register(  
:class =\> GetUsertDetailRequest,  
:schema\_name =\> XSD::QName.new(NsC\_0, “GetUsertDetailRequest”),  
:schema\_element =\> [  
[“localStuff”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0,  
“LocalStuff”)], [0, 1]],  
[“codeP”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0, “CodeP”)],  
[0, 1]],  
[ :choice,  
[“id”, [“SOAP::SOAPLong”, XSD::QName.new(NsC\_0, “Id”)]],  
[“secondId”, [“SOAP::SOAPString”, XSD::QName.new(NsC\_0,  
“SecondId”)], [0, 1]]  
]  
]  
)

I have only used one version of soap4r (1.5.8) so I guess the problem  
has to come from the xml parsing. Has anyone experienced issues with  
soap4r in the recent weeks?

Thanks!

---

<div class="post-metadata">

**Author:** ![PierreW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/da6949/32.png) [@PierreW](https://www.ruby-forum.com/u/PierreW)\
**Post date:** [October 26, 2009, 9:13am UTC](https://www.ruby-forum.com/t/wrong-soap4r-interpretation-of-a-wsdl/175585/3 "2009-10-26T09:13:20Z")

</div>

I had a similar issue, it looks like xs:choice gets interpreted  
incorrectly when  
xs:choice follows xs:extension  
Then elements from the extension get included in the choice and the  
mapping is incorrect as you describe. I had to manually edit the  
generated registry. It might indeed be a bug in soap4r. I have soap4r  
1.5.8 and generated my mappings several months ago (around March) so I  
don’t think it’s a very recent issue.
