Genry
Genry

Reputation: 301

How to change the configuration elementFormDefault and attributeFormDefault fields in Python spyne SOAP wsdl service

Thank you in advance for your help and for reading my question.

I have a WSDL file, for which I want to disable the explicit relation of the transmitted data to the namespace.

The service is written in spyne, which does not have such an explicit feature. It automatically generates xml in which there is only one field:

<xs:targetNamespace="http://simpleTest/" elementFormDefault="specified">

And the result I want to achieve is:

< attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://simpleTest/">

Here are the versions I'm working with

spyne = 3.11.3 python = 2.14.0

This is how I create my service.

from logging import getLogger
from spyne import Application
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from configs import APP_CONFIG
from routers import SameTestRouter


debug_loggers = getLogger('debug_logger')

soap_app = Application(
    [SameTestRouter],
    name=APP_CONFIG.APP_NAME,
    tns=APP_CONFIG.URL_PREFIX,
    in_protocol=Soap11(validator='lxml'),
    out_protocol=Soap11()
)

wsgi_app = WsgiApplication(soap_app)

Well, then there's the test method with its schematics, which I'm sending the message to. Well, it works if I explicitly specify the namespace, but I need it without explicitly specifying it.

class TestBlockTwo(ComplexModel):
    __namespace__ = APP_CONFIG.URL_PREFIX
    test_test = Unicode
    test_test = Decimal
    
class message(ComplexModel):
    __namespace__ = APP_CONFIG.URL_PREFIX
    test_block_two = TestBlockTwo

class SameTestRouter(ServiceBase):
    
    @rpc(TestBlockOne, _returns=Unicode)
    def process(self, message: TestBlockOne) -> str:
        passage = vars(message.test_block_two)
        debug_loggers.info(f"Received data: {passage}")

If you have encountered this, please tell me how it can be solved.

Upvotes: 0

Views: 21

Answers (0)

Related Questions