[Xml-compile] Fault when required child within optional parent node
Thibadeau, Daniel
dan.thibadeau at hp.com
Sat Aug 19 04:29:22 GMT 2017
I am getting the following error when I send a request with a WSDL that contains an optional parent element (cte_document/document_header/payment_information) but a required child element (amount_collect):
--- ERROR ---
error: decode error: data for element or block starting with `amount_collect' missing at tns:calculateTaxOnCteDataModelResponse/return/cte_document/document_header/payment_information
Errors while decoding:
error: decode error: data for element or block starting with `amount_collect' missing at tns:calculateTaxOnCteDataModelResponse/return/cte_document/document_header/payment_information
---
My request does not contain the "payment_information" element, so the response is also missing that element (as expected). The fault message seems to only be on the response and not the request.
I believe this should be a valid WSDL configuration. I do get back a valid/expected response in $answer
What can I do to prevent the error?
Should the printErrors() method be printing the error twice?
Dan T.
--- CODE ---
use XML::Compile::SOAP::WSS; # list before WSDL11
use XML::Compile::WSDL11;
use XML::Compile::SOAP11;
use XML::Compile::Transport::SOAPHTTP;
use XML::Compile::WSS::Util qw(:utp11);
use XML::LibXML::Simple qw(XMLin);
my $base = "data/ex_cte";
my $wsdlfn = "${base}_wsdl.xml";
my $reqfn = "${base}_request_orig.xml";
my $opname = "calculateTaxOnCteDataModel";
my $wss = XML::Compile::SOAP::WSS->new;
my $wsdl = XML::Compile::WSDL11->new( $wsdlfn );
my $auth = $wss->basicAuth
(
username => "my_user",
created => time(),
nonce => 'RANDOM',
pwformat => UTP11_PDIGEST,
password => "my_password",
);
my $data = XMLin ($reqfn, KeepRoot => 1);
my $call = $wsdl->compileClient($opname);
my ($answer, $trace) = $call->($data);
$trace->printErrors if ($trace->errors);
__END__
WSDL info:
<xs:element minOccurs="0" name="payment_information" type="tns:payment-information"/>
<xs:complexType name="payment-information">
<xs:sequence>
<xs:element minOccurs="0" name="payment_number" type="xs:string"/>
<xs:element minOccurs="0" name="payment_terms" type="xs:string"/>
<xs:element minOccurs="0" name="paid_date" type="xs:string"/>
<xs:element minOccurs="1" name="amount_collect" type="xs:string"/>
<xs:element minOccurs="0" name="vat_amount_rec" type="xs:string"/>
<xs:element minOccurs="0" name="pay_disc_perc" type="xs:string"/>
<xs:element minOccurs="0" name="pay_terms_day" type="xs:string"/>
<xs:element minOccurs="0" name="installments" type="tns:payment-installments"/>
</xs:sequence>
</xs:complexType>
More information about the Xml-compile
mailing list