既存のWSDLを実現する必要があります。 複合型クラスを継承しようとしています。 しかし、派生クラスがxml属性を実装する場合、私はエラーを受け取ります。 派生クラスがXML属性を実装していない場合、エラーは発生しません。spyne - 複合型から継承し、派生クラスがxml属性を実装するときのエラー
何か問題がありますか? (spyneバージョン '2.12.11'、のpython 2.7.9)
エラー:
No handlers could be found for logger "spyne.interface.xml_schema"
Traceback (most recent call last):
File "/home/leto/workspace/spyne_test/inherited_classes.py", line 32, in <module>
out_protocol=Soap12())
File "/usr/local/lib/python2.7/dist-packages/spyne/application.py", line 113, in __init__
self.in_protocol.set_app(self)
File "/usr/local/lib/python2.7/dist-packages/spyne/protocol/xml.py", line 368, in set_app
xml_schema.build_validation_schema()
File "/usr/local/lib/python2.7/dist-packages/spyne/interface/xml_schema/_base.py", line 223, in build_validation_schema
self.validation_schema = etree.XMLSchema(etree.parse(f))
File "xmlschema.pxi", line 90, in lxml.etree.XMLSchema.__init__ (src/lxml/lxml.etree.c:175129)
lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}complexType': The content is not valid. Expected is (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))., line 10
コード:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from spyne.model.primitive import Unicode
from spyne.server.wsgi import WsgiApplication
from spyne.protocol.soap.soap12 import Soap12
from spyne.model.complex import XmlAttribute, ComplexModel
from spyne import Application, rpc, ServiceBase
ADDRESS = '127.0.0.1'
PORT = 8070
class DeviceEntity(ComplexModel):
token = XmlAttribute(Unicode, use='required')
class DigitalInput(DeviceEntity):
# IdleState = Unicode
IdleState = XmlAttribute(Unicode)
class Service(ServiceBase):
@rpc(_returns=DigitalInput, _body_style='bare')
def GetDigitalInput(ctx):
return DigitalInput()
application = Application([Service], 'some_tns',
in_protocol=Soap12(validator='lxml'),
out_protocol=Soap12())
wsgi_application = WsgiApplication(application)
if __name__ == '__main__':
from wsgiref.simple_server import make_server
server = make_server(ADDRESS, PORT, wsgi_application)
server.serve_forever()
それは私が実装しようとWSDLの一部です:
<xs:complexType name="DeviceEntity">
<xs:annotation>
<xs:documentation>
Base class for physical entities like inputs and outputs.
</xs:documentation>
</xs:annotation>
<xs:attribute name="token" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>Unique identifier referencing the physical entity.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
<xs:complexType name="DigitalInput">
<xs:complexContent>
<xs:extension base="tt:DeviceEntity">
<xs:sequence>
<xs:any namespace="##any" processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
<!-- first ONVIF then Vendor -->
</xs:sequence>
<xs:attribute name="IdleState" type="xs:string">
<xs:annotation>
<xs:documentation>Indicate the Digital IdleState status.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:anyAttribute processContents="lax"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
はい、あります。 https://github.com/arskom/spyne/issues/491 –
そして私は次のバージョンでspyneがこの問題を抱えないことを願っています。 –