Reputation: 31
from spyne.application import Application
from spyne.decorator import rpc
from spyne.model.complex import ComplexModel
from spyne.model.primitive import String, Integer
from spyne.service import ServiceBase
from spyne.protocol.soap import Soap11
from spyne.server.django import DjangoApplication
from spyne import Unicode
from django.views.decorators.csrf import csrf_exempt
from lxml import etree
class StatusData(ComplexModel):
date = String
class AppealsExternalStatusRequest(ComplexModel):
messageId = String
class DataWrapper(ComplexModel):
AppealsExternalStatusRequest = AppealsExternalStatusRequest
class AppealsService(ServiceBase):
@rpc(DataWrapper, _returns=String, _body_style='bare', _operation_name='data')
def receive_status(ctx, data_wrapper):
print(data_wrapper)
return "Received"
soap_app = Application([AppealsService],
tns='certain_path,
in_protocol=Soap11(validator='lxml'),
out_protocol=Soap11())
django_soap_app = DjangoApplication(soap_app)
django_soap_app = csrf_exempt(django_soap_app)
When I try to access to this via http://localhost/soap_api?wsdl, I receive in this format:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="path" xmlns:e="app.soap_service">
<soapenv:Header/>
<soapenv:Body>
<v1:data>
<e:AppealsExternalStatusRequest>
<!--Optional:-->
<e:messageId>?</e:messageId>
<e:statusData>
<!--Optional:-->
<e:date>?</e:date>
<!--Optional:-->
</e:statusData>
</e:AppealsExternalStatusRequest>
</v1:data>
</soapenv:Body>
</soapenv:Envelope>
But I want to remove those e: prefixes, how that is possible?
I added namespace in that case, it adds just other prefixes, and when I remove the namespace it adds e:
prefixes.
But spyne library automatically generates this: xmlns:e="eplay.soap_template"> which is app_name.file_name, for that reason, it is adding prefix e: for the fields with namespace = None. For that reason, it is automatically always generating this prefixes. How to solve that issue?
Upvotes: 2
Views: 91