Search code examples
soapspyne

Spyne fails with XMLSchemaParseError when building a SOAP API with multiple namespaces


I am implementing an existing WSDL that uses separate namespaces for messages and types.

<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>

I have tried to do something like this to represent the different namespaces:

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()
                   )

Which generates an exception when I try to run it:

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

The logging output tells me this is an error in Spyne... help please!


Solution

  • This is indeed a bug, already fixed in master waiting for release. If you can't wait, do:

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

    and the problem will go away