[Python] Remove namespace on request variables

Discussão em 'Python' iniciado por Stack, Março 27, 2025.

  1. Stack

    Stack Membro Participativo

    Use spyne for create soap server. Create models and services. The request message of the sendDocument method is formed as follows. How to remove "efat" ns prefix from
    variables in documentRequest.

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
    xmlns:efat="http://gib.gov.tr/vedop3/eFatura">
    <soap:Header/>
    <soap:Body>
    <efat:documentRequest>
    <!--Optional:-->
    <efat:fileName>?</efat:fileName>
    <!--Optional:-->
    <efat:binaryData contentType="?">cid:973156330962</efat:binaryData>
    <!--Optional:-->
    <efat:hash>?</efat:hash>
    </efat:documentRequest>
    </soap:Body>
    </soap:Envelope>


    My model class is here:

    from spyne import Unicode, ByteArray, ComplexModel, XmlAttribute, XmlData

    class Base64Binary(ComplexModel):
    __namespace__ = 'http://www.w3.org/2005/05/xmlmime'
    __type_name__ = "base64Binary"
    _type_info = [
    ('_value', XmlData(ByteArray)),
    ('contentType', XmlAttribute(
    Unicode.
    customize(__namespace__='http://www.w3.org/2005/05/xmlmime')))]

    class DocumentType(ComplexModel):
    __namespace__ = ""
    fileName= Unicode.customize(__namespace__=None)
    binaryData = Base64Binary.customize(__namespace__=None)
    hash = Unicode.customize(__namespace__=None)

    class DocumentReturnType(ComplexModel):
    __namespace__ = ""
    _type_info = [
    ('msg', Unicode),
    ('hash', Unicode)
    ]

    Continue reading...

Compartilhe esta Página