[Xml-compile] Problem with choice

Drew Taylor drew at drewtaylor.com
Tue Apr 22 17:23:45 BST 2008


I apologize in advance for such a long post!

I'm having an issue with an end-to-end test which is testing for  
errors in messages. Using X::C::WSDL, I create a client and send off a  
request to the server (it's Catalyst but I don't think that's  
relevant). The incoming and outgoing SOAP messages are below. In this  
particular case, I'm leaving off PackageRequest/DateRange/Start to  
test my error checking. I can see the warning message in the response,  
so that part is working correctly. However, the client gives me an  
error when trying to read in the response and parse it.

If I put back the PackageRequest/DateRange/Start element everything  
works fine. There must be something simple I'm overlooking... It seems  
crazy that I can't test failure scenarios because X::C is saving me  
from my (intentional) errors. :-)

Drew

Client:
my $wsdl    = XML::Compile::WSDL11->new($xml);
my $client  = $wsdl->compileClient($message,
     port => $message.'Port', transport_hook => \&proxy_to_test_app,
);
# $params is the monster data structure to be sent
$params->{PackageRequest}{DateRange} = {Duration => 'P7N'}; # testing  
lack of Start element
($answer, $trace) = $client->( { body => $params } );

Gives:
   error: no applicable choice for `Success' at {http://www.opentravel.org/OTA/2003/05 
}TTI_PkgBookRS

[debug] Outgoing XML:
<SOAPENV:Envelope xmlns:SOAPENV="http://schemas.xmlsoap.org/soap/envelope/ 
">
     <SOAPENV:Body>
         <x0:TTI_PkgBookRS xmlns:x0="http://www.opentravel.org/OTA/2003/05 
" Version="1">
             <x0:Success/>
             <x0:Warnings>
                 <x0:Warning Type="3" ShortText="Missing or invalid  
booking start date: []" Code="145"/>
             </x0:Warnings>
             <x0:PackageReservation>
                 <x0:POS>
                     <x0:Source AgentSine="root" AgentDutyCode="abc123">
                         <x0:RequestorID Type="4" ID="1234"/>
                     </x0:Source>
                 </x0:POS>
                 <x0:UniqueID Type="11" ID="WARNING1208880522"/>
                 <x0:Package ID="S08/2009-02-14/14" ProductCode="SKI">
                     <x0:DateRange Duration="P7N"/>
                     <x0:ItineraryItems>
                         <x0:ItineraryItem/>
                     </x0:ItineraryItems>
                 </x0:Package>
                 <x0:ContactDetail/>
                 <x0:PassengerListItems>
                     <x0:PassengerListItem Code="10" RPH="2"  
BirthDate="1971-09-27">
                         <x0:Name>
                             <x0:NamePrefix>Mr</x0:NamePrefix>
                             <x0:GivenName>John</x0:GivenName>
                             <x0:Surname>Doe</x0:Surname>
                         </x0:Name>
                     </x0:PassengerListItem>
                     <x0:PassengerListItem Code="10" RPH="1"  
BirthDate="1974-04-20" LeadPaxInd="1">
                         <x0:Name>
                             <x0:NamePrefix>Mrs</x0:NamePrefix>
                             <x0:GivenName>Jane</x0:GivenName>
                             <x0:Surname>Doe</x0:Surname>
                         </x0:Name>
                     </x0:PassengerListItem>
                 </x0:PassengerListItems>
                 <x0:InvoiceDetail>
                     <x0:GrossAmount Amount="1234.000"/>
                     <x0:DepositAmount Amount="0.000"/>
                     <x0:AgentCommission Amount="0.000"/>
                     <x0:NetAmount Amount="1234.000"/>
                     <x0:BalanceDueAmount Amount="1234.000"  
PaymentDueDate="2008-04-22"/>
                 </x0:InvoiceDetail>
             </x0:PackageReservation>
         </x0:TTI_PkgBookRS>
     </SOAPENV:Body>
</SOAPENV:Envelope>


Schema for message:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Amended 25Jun07 to correct it to OTA2004A -->
<xs:schema targetNamespace="http://www.opentravel.org/OTA/2003/05"  
xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xs="http://www.w3.org/2001/XMLSchema 
" elementFormDefault="qualified" version="1.0" id="OTA2004A">
	<xs:include schemaLocation="TTI_PkgReservation.xsd"/>
	<xs:element name="TTI_PkgBookRS">
		<xs:complexType>
			<xs:choice>
				<xs:sequence>
					<xs:element name="Success" type="SuccessType"/>
					<xs:element name="Warnings" type="WarningsType" minOccurs="0"/>
					<xs:element name="PackageReservation" type="PkgReservation"/>
				</xs:sequence>
				<xs:sequence>
					<xs:element name="Errors" type="ErrorsType"/>
				</xs:sequence>
			</xs:choice>
			<xs:attributeGroup ref="OTA_PayloadStdAttributes"/>
			<xs:attributeGroup ref="CurrencyCodeGroup"/>
		</xs:complexType>
	</xs:element>
</xs:schema>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/xml-compile/attachments/20080422/352cb9f7/attachment-0001.htm


More information about the Xml-compile mailing list