We are trying to build a SOAP app with Django + Spyne building specific required endpoints. The exposed WSDL has to precisely match a predetermined XML file, including the custom simpleType definitions. We're currently failing to show the simple type definitions on our WSDL, everything else matches up precisely.
A simple example is the following hello world app:
import logging
logging.basicConfig(level=logging.DEBUG)
from spyne import Application, rpc, ServiceBase, \
Integer, Unicode, SimpleModel
from spyne import Iterable
from spyne.protocol.xml import XmlDocument
from spyne.protocol.soap import Soap11
from spyne.interface.wsdl import Wsdl11
from spyne.server.django import DjangoApplication
from django.views.decorators.csrf import csrf_exempt
class IdType(SimpleModel):
__type_name__ = "IdType"
__namespace__ = 'spyne.examples.hello'
__extends__ = Unicode
class Attributes(Unicode.Attributes):
out_type = 'TxnIdType'
class HelloWorldService(ServiceBase):
@rpc(IdType, Integer, _returns=Iterable(Unicode))
def say_hello(ctx, TxnIdType, times):
for i in range(times):
yield 'Hello, %s' % TxnIdType
application = Application([HelloWorldService],
tns='spyne.examples.hello',
interface = Wsdl11(),
in_protocol=Soap11(validator = 'lxml'),
# out_protocol=XmlDocument(validator='schema')
out_protocol=Soap11()
)
hello_app = csrf_exempt(DjangoApplication(application))
Which yields the following WSDL:
<wsdl:definitions xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:plink="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:wsdlsoap11="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdlsoap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap11enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope" xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding" xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing" xmlns:xop="http://www.w3.org/2004/08/xop/include" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:tns="spyne.examples.hello/types" xmlns:s0="spyne.examples.hello" targetNamespace="spyne.examples.hello/types" name="Application">
<wsdl:types>
<xs:schema targetNamespace="spyne.examples.hello/types" elementFormDefault="qualified">
<xs:import namespace="spyne.examples.hello" />
<xs:complexType name="say_helloResponse">
<xs:sequence>
<xs:element name="say_helloResult" type="xs:string" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="say_hello">
<xs:sequence>
<xs:element name="IdType" type="s0:IdType" minOccurs="0" nillable="true" />
<xs:element name="times" type="xs:integer" minOccurs="0" nillable="true" />
</xs:sequence>
</xs:complexType>
<xs:element name="say_helloResponse" type="tns:say_helloResponse" />
<xs:element name="say_hello" type="tns:say_hello" />
</xs:schema>
</wsdl:types>
<wsdl:message name="say_hello">
<wsdl:part name="say_hello" element="tns:say_hello" />
</wsdl:message>
<wsdl:message name="say_helloResponse">
<wsdl:part name="say_helloResponse" element="tns:say_helloResponse" />
</wsdl:message>
<wsdl:service name="HelloWorldService">
<wsdl:port name="Application" binding="tns:Application">
<wsdlsoap11:address location="http://localhost:8000/gtw/services/HelloWorldService" />
</wsdl:port>
</wsdl:service>
<wsdl:portType name="Application">
<wsdl:operation name="say_hello" parameterOrder="say_hello">
<wsdl:input name="say_hello" message="tns:say_hello" />
<wsdl:output name="say_helloResponse" message="tns:say_helloResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="Application" type="tns:Application">
<wsdlsoap11:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="say_hello">
<wsdlsoap11:operation soapAction="say_hello" style="document" />
<wsdl:input name="say_hello">
<wsdlsoap11:body use="literal" />
</wsdl:input>
<wsdl:output name="say_helloResponse">
<wsdlsoap11:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
</wsdl:definitions>
As you can see, the simpleType "IdType" does not show up. Is there a way to force Spyne to reflect these tags? Currently our output WSDL does not pass the required validation since it does not recognize the custom simpleTypes.
Our expected output is the following:
<simpleType name="IdType">
<restriction base="xsd:string">
<xsd:maxLength value="10"/>
</restriction>
</simpleType>
Any help will be greatly appreciated.
Thanks!