最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论