Subject: | child elements duplicated and inherit name from parent through options hash ref |
I have SOAP::WSDL checked out from svn -
https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/branches/Typemap/
- and am using the wsdl2perl.pl script against the UPS web services
Rating API.
in RateWebServiceSchema.xsd:
<xsd:element name="RateRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="common:Request"/>
<xsd:element minOccurs="0" name="PickupType"
type="rate:CodeDescriptionType"/>
<xsd:element minOccurs="0" name="CustomerClassification"
type="rate:CodeDescriptionType"/>
<xsd:element name="Shipment" type="rate:ShipmentType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
and in common.xsd:
<xsd:element name="Request" type="common:RequestType"/>
...
<xsd:complexType name="RequestType">
<xsd:sequence>
<xsd:element name="RequestOption" type="xsd:string" minOccurs="0"
maxOccurs="unbounded"/>
<xsd:element name="TransactionReference"
type="common:TransactionReferenceType" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
with the following perl data structure
{
Request => {
RequestOption => 'Shop',
},
}
results in the following xml:
<Request xmlns="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<Request>
<Request>Shop</Request>
</Request>
</Request>
the expected xml is as follows:
<Request xmlns="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<RequestOption>Shop</RequestOption>
</Request>
If I add the following at line 388 of
SOAP/WSDL/XSD/Typelib/ComplexType.pm, the issue is resolved:
if ($name && $option_ref->{name}) {
delete $option_ref->{name};
}
It seems as thought $option_ref->{name} is overwriting $name in this
specific case which is what is causing the incorrect xml to be generated.