【问题标题】:Spyne fails with XMLSchemaParseError when building a SOAP API with multiple namespaces构建具有多个命名空间的 SOAP API 时,Spyne 失败并出现 XMLSchemaParseError
【发布时间】:2014-12-24 10:19:32
【问题描述】:

我正在实现一个现有的 WSDL,它为消息和类型使用单独的命名空间。

<message name="searchDetailRequest">
    <part element="ixa:searchDetail" name="body" />
</message>
<message name="searchDetailResponse">
    <part element="ixa:searchDetailResponse" name="result" />
</message>

    <operation name="searchDetail">
        <input message="tns:searchDetailRequest" />
        <output message="tns:searchDetailResponse" />
    </operation>

我试图做这样的事情来表示不同的命名空间:

class RXIType(ComplexModel):
    __namespace__ = 'urn:badger/ixa'


class searchDetailRequest(RXIType):
    intput = Unicode()


class searchDetailResponse(RXIType):
    output = Unicode()


class TestService(ServiceBase):
    @rpc(searchDetailRequest, _returns=searchDetailResponse, _body_style='bare')
    def searchDetail(cls, body):
        pass

soap = Application((TestService,),
                   'urn:badger/definitions',
                   in_protocol=Soap11(),
                   out_protocol=Soap11()
                   )

当我尝试运行它时会产生异常:

Traceback (most recent call last):
  File "./manage.py", line 14, in <module>
    from soapbridge import app
  File "/home/danni/src/GIT/s2x-hsnet-soap-bridge/soapbridge/__init__.py", line 52, in <module>
    out_protocol=Soap11()
  File "/home/danni/src/GIT/s2x-hsnet-soap-bridge/python_env/src/spyne/spyne/application.py", line 111, in __init__
    self.in_protocol.set_app(self)
  File "/home/danni/src/GIT/s2x-hsnet-soap-bridge/python_env/src/spyne/spyne/protocol/xml.py", line 324, in set_app
    xml_schema.build_validation_schema()
  File "/home/danni/src/GIT/s2x-hsnet-soap-bridge/python_env/src/spyne/spyne/interface/xml_schema/_base.py", line 221, 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:174715)
lxml.etree.XMLSchemaParseError: Element '{http://www.w3.org/2001/XMLSchema}element', attribute 'type': References from this schema to components in the namespace 'urn:badger' are not allowed, since not indicated by an import statement., line 9

日志输出告诉我这是 Spyne 中的一个错误...请帮助!

【问题讨论】:

    标签: soap spyne


    【解决方案1】:

    这确实是一个错误,已经在 master 中修复,等待发布。如果你等不及了,那就去做吧:

    pip install -e git://github.com/arskom/spyne.git@60ed622b088c13f4f84c81f1f43302edbc7f6027#egg=spyne
    

    问题就会消失

    【讨论】:

    • 这打破了一个新的例外:'lxml.etree._Element'对象没有属性'add'
    • 这是真的。我对 spyne 也有同样的经历。这个新的 'lxml.etree._Element'' 对象没有属性 'add' 问题如何解决。
    • 等待 2.12 或申请 github.com/arskom/spyne/commit/… 2.12 即将到来。
    猜你喜欢
    • 1970-01-01
    • 2013-06-03
    • 2011-08-25
    • 1970-01-01
    • 2019-02-21
    • 1970-01-01
    • 2018-01-12
    • 2011-11-14
    相关资源
    最近更新 更多