Wrong soap4r interpretation of a WSDL

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
xmlns:env=“http://schemas.xmlsoap.org/soap/envelope/
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”>
env:Body
<n1:GetUserDetailRequest xmlns:n1=“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!

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!

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs