Subject: | Problem with <xs:choice><xs:sequence>...</xs:sequence></xs:choice> |
I'm writing a SOAP server and ran into an issue with the data structure needed for the
WRITER. I don't think I should need the top level "Success" hash key (and in fact I get a
warning: "mistake: tag `Success' not used at
{http://www.opentravel.org/OTA/2003/05}OTA_PingRS#el(OTA_PingRS)" if it's included. But
if I don't then I only get the outermost element <OTA_PingRS>, with none of the inner
elements (<Success>, <EchoData>).
The writer object is constructed like:
my $res = pack_type($ns, $msg);
my $write = $wsdl->compile(WRITER => $res, elements_qualified => 'TOP' );
The writer returns the following SOAP message:
<x0:OTA_PingRS xmlns:x0="http://www.opentravel.org/OTA/2003/05"
Version="1"><x0:Success/><x0:EchoData>Hello world!</x0:EchoData></x0:OTA_PingRS>
The data structure I'm passing to $write:
{
Version => 1,
Success => 1, # true value required for sequence. Bug???
seq_Success => [{
Success => {},
EchoData => $echo,
}]
}
And the schema for the message:
<xs:element name="OTA_PingRS">
<xs:complexType>
<xs:choice>
<xs:sequence maxOccurs="2">
<xs:element name="Success" type="SuccessType"/>
<xs:element name="Warnings" type="WarningsType" minOccurs="0"/>
<xs:element name="EchoData" type="xs:string">
</xs:element>
</xs:sequence>
<xs:element name="Errors" type="ErrorsType"/>
</xs:choice>
<xs:attributeGroup ref="OTA_PayloadStdAttributes"/>
</xs:complexType>
</xs:element>
<xs:complexType name="SuccessType">
<!-- This element is normally empty and used as a boolean -->
</xs:complexType>