Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #424 (closed defect: fixed)

Opened 8 months ago

Last modified 8 months ago

wsdl2ruby.rb generates inconsistent class definition which derives an Array

Reported by: nahi Assigned to: nahi
Priority: normal Milestone: 1.5.8
Component: soap4r Version: 1.5
Keywords: Cc:

Description

from soap4r-ml

http://webservices.micros.com/ows/5.1/Availability.wsdl

Hi NaHi,

Thanks for the patch .. it almost works!

Firstly, I have applied it to my local copy of
soap4r-1.5.7.90.20070911.

The code-gen now emits a class definition for "AvailabilityRequest".
The code emitted is:


# {http://webservices.micros.com/ows/5.1/
Availability.wsdl}AvailabilityRequest
#   availRequestSegment - AvailRequestSegment
#   xmlattr_summaryOnly - SOAP::SOAPBoolean
class AvailabilityRequest < AvailRequestSegmentList
  AttrSummaryOnly = XSD::QName.new(nil, "summaryOnly")

  attr_accessor :availRequestSegment

  def __xmlattr
    @__xmlattr ||= {}
  end

  def xmlattr_summaryOnly
    __xmlattr[AttrSummaryOnly]
  end

  def xmlattr_summaryOnly=(value)
    __xmlattr[AttrSummaryOnly] = value
  end

  def initialize(availRequestSegment = [])
    @availRequestSegment = availRequestSegment
    @__xmlattr = {}
  end
end



Now, when I invoke this code, the SOAP message does not emit any
nested elements within the top-level <AvailabilityRequest> element.
For example, all that is emitted 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:AvailabilityRequest xmlns:n1="http://webservices.micros.com/
ows/5.1/Availability.wsdl"
        summaryOnly="true"></n1:AvailabilityRequest>
  </env:Body>
</env:Envelope>



I then modified the class definition in default.rb to remove the
inheritance from the base class "AvailRequestSegmentList", i.e. the
class definition is now:

# {http://webservices.micros.com/ows/5.1/
Availability.wsdl}AvailabilityRequest
#   availRequestSegment - AvailRequestSegment
#   xmlattr_summaryOnly - SOAP::SOAPBoolean
class AvailabilityRequest
...
end


Now, when I run my AvailabilityServiceClient.rb with this change, I
get the full SOAP envelope rendered as expected:

<?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:AvailabilityRequest xmlns:n1="http://webservices.micros.com/
ows/5.1/Availability.wsdl"
        xmlns:n2="http://webservices.micros.com/og/4.3/Availability/"
        summaryOnly="true">
      <n2:AvailRequestSegment numberOfRooms="1"
          availReqType="Room"
          roomOccupancy="2"
          numberOfChildren="1"
          totalNumberOfGuests="3">
          ......... (contents removed here !) .........
      </n2:AvailRequestSegment>
    </n1:AvailabilityRequest>
  </env:Body>
</env:Envelope>


The relevant snippet of my AvailabilityServiceClient code that
populates the request is as follows:

...
# build avail request segment
avail_request_segment = AvailRequestSegment.new
avail_request_segment.ratePlanCandidates = [rpc]
avail_request_segment.hotelSearchCriteria = [hsc]
avail_request_segment.stayDateRange = stay_date_range # note: not an
array!
avail_request_segment.xmlattr_availReqType = Room # Room is a
AvailRequestType obj => "Room"
avail_request_segment.xmlattr_numberOfRooms = "1"
avail_request_segment.xmlattr_roomOccupancy = "2"
avail_request_segment.xmlattr_totalNumberOfGuests = "3"
avail_request_segment.xmlattr_numberOfChildren = "1"


# build availability request
availabilityRequest = AvailabilityRequest.new
availabilityRequest.xmlattr_summaryOnly = "true"
availabilityRequest.availRequestSegment = [avail_request_segment]

# send request
puts obj.availability(availabilityRequest)


So ... either I'm attaching the avail_request_segment incorrectly to
the availabilityRequest object, OR there is another little issue in
the code-gen, such that the"... < AvailRequestSegmentList" extension
should _not_ be added to the code definition for "class
AvailabilityRequest".

What are your thoughs NaHi? Thanks for your help so far btw!


Dave

Change History

09/14/07 19:56:55 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.

(In [1959]) * wsdl2ruby.rb generated inconsistent class definition when the base class was :TYPE_ARRAY and the derived class was a :TYPE_STRUCT. let the derived class be a standalone (not a derived) class. closes #424.