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