2

I have to implement a service with spyne that exposes a specific wsdl

right now I'm unable to replicate this definition:

<xs:complexType name="MyType">
    <xs:simpleContent>
        <xs:extension base="xs:string">
            <xs:attribute name="version" type="xs:string"/>
        </xs:extension>
    </xs:simpleContent>
</xs:complexType>

So far the best I was able to achieve is

class MyType(ComplexModel):
    __namespace__ = "uri:my-ns"
    __extends__ = primitive.Unicode
    version = XmlAttribute(primitive.Unicode)

that raise an AttributeError but if I "patch" models/complex.py[1] I obtain:

<xs:complexType name="MyType">
    <xs:complexContent>
         <xs:extension base="xs:string">
              <xs:attribute name="version " type="xs:string"/>
         </xs:extension>
    </xs:complexContent>
</xs:complexType>

almost there! but my complexType has a complexContent instead of a simpleContent

[1] I'm using the master branch of spyne (0f587b2d606b54e41fc5cc3d33b51cc3b324a2ca) and if I add __extends__ = primitive.Unicode I need to change line 602 of model/complex.py from:

if eattr._subclasses is None

to

if getattr(eattr, "_subclasses", None) is None
dvd
  • 1,014
  • 6
  • 12
  • You can't do this anymore with master branch. spyne complains that one cannot extend a ComplexModel whose base type is a simply type. If using , the base type is expected to be a complex type. The base type '{http://www.w3.org/2001/XMLSchema}decimal' is a simple type., line 69 – Divick Jul 29 '19 at 11:25

0 Answers0