[Xml-compile] SOAP complexType
Julien.GILLES at sungard.com
Julien.GILLES at sungard.com
Fri Mar 25 14:38:53 GMT 2011
Hi,
I use XML::Compile::SOAP to send request to an external web services,
and I have something strange (well, I am definitively not a SOAP expert,
so perhaps the behavior is correct, and I am wrong...)
In a request, the parameters can contain a 'policy' defined in wsdl as
:
<complexType name="Policy">
<sequence>
<choice minOccurs="0" maxOccurs="unbounded">
<element name="subsetPolicy" type="tns:SubsetPolicy"
minOccurs="0" />
<element name="modelVersionPolicy"
type="tns:ModelVersionPolicy" minOccurs="0" />
<element name="descriptorPolicy" type="tns:DescriptorPolicy"
minOccurs="0" />
<element name="processInstanceDetailsPolicy"
type="tns:ProcessInstanceDetailsPolicy" minOccurs="0" />
(...)
</choice>
</sequence>
</complexType>
I tried using following perl structure:
policy => {
subsetPolicy => { ... } ,
modelVersionPolicy => { ... },
descriptorPolicy => { ... } ,
processInstanceDetailsPolicy => { ... }
}
But ended up with :
trace: available tags are: cho_subsetPolicy
mistake: unused tags descriptorPolicy modelVersionPolicy
processInstanceOid subsetPolicy at ...
Using the explain method :
policy =>
{ # sequence of cho_subsetPolicy
# choice of subsetPolicy, modelVersionPolicy, (...)
# occurs any number of times
cho_subsetPolicy =>
[ {
# is a baqt:SubsetPolicy
# is optional
subsetPolicy =>
{ # sequence of (...) },
# is a baqt:ModelVersionPolicy
# is optional
modelVersionPolicy =>
{ # sequence of restrictedToActiveModel (...) }
etc...
}]
So I tried :
policy => {
cho_subsetPolicy => [ {
subsetPolicy => {...}
modelVersionPolicy => { ... },
descriptorPolicy => { ... } ,
processInstanceDetailsPolicy => { ... }
}
No more error, but the sent soap message contain only one choice, one of
subsetPolicy, modelVersionPolicy, descriptorPolicy etc, but not all of
them.
Finally I found the correct syntax :
policy => { cho_subsetPolicy => [
{ subsetPolicy => {...} },
{ modelVersionPolicy => {...} },
{ descriptorPolicy {...} },
{ processInstanceDetailPolicy {...} }
]}
ie an array of hash, with only one key in each hash.
My questions are :
Why is there a cho_subsetPolicy level ? "cho" is for "choice" I suppose,
and the name is the first element of the choice, but why is this level
necessary ?
And why the syntax proposed by the explain method is wrong ?
--
Julien Gilles.
More information about the Xml-compile
mailing list