Suds seems to have problems parsing the following XSD:
<element name="quantity" minOccurs="1" maxOccurs="1">
<annotation>
<documentation>Quantity of this item that's being ordered.</documentation>
</annotation>
<complexType>
<simpleContent>
<extension base="int">
<attribute name="unitOfMeasure" use="required">
<annotation>
<documentation>
Unit of measurement.
The attribute can have the
following values: PCS - pieces
SEC- seconds BYT - bytes KB -
kilobytes
</documentation>
</annotation>
<simpleType>
<restriction base="string">
<enumeration value="PCS" />
<enumeration value="SEC" />
<enumeration value="BYT" />
<enumeration value="KB" />
</restriction>
</simpleType>
</attribute>
</extension>
</simpleContent>
</complexType>
</element>
The XML is supposed to look like:
<ns0:quantity unitOfMeasure="PCS">1</ns:quantity>
Sadly, I can only set the attribute:
>>> c.factory.create('ns0:item.quantity')
(quantity){
_unitOfMeasure = ""
}
with no possibility to set the "text" value of the XML node.
I've tried creating the XML literally:
element = Element('ns0:quantity')
element.setText("1")
element.set('unitOfMeasure', "PCS")
and passing that as parameter.
This looks good in the debug logging (as <ns0:quantity unitOfMeasure="PCS">1</ns0:quantity>
) but the actual request shows this value will be serialized as:
<ns0:quantity />
I'm getting lost here. How can I submit this value properly?
I'm using suds 0.4
Just found a temporary workaround.
The problem also occurs with suds-jurko. While the pretty-format logging in suds.client shows the XML element, the raw logging in suds.transport.http
shows that the "plain" output fails to serialize the element.
By enabling client.options.prettyxml = True
this issue is circumvented.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.