Пример #1
0
    def standard_request_serializer(
            envelope: Envelope, version: str = "v1", extra_namespace: str = "", special_prefixes: dict = None) -> str:

        namespacedef_ = (
            f'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" '
            f'xmlns:{version}="http://ws.aramex.net/ShippingAPI/{version}/" '
            f'{extra_namespace}'
        )
        envelope.ns_prefix_ = "soap"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        for node in (envelope.Body.anytypeobjs_ + envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, version, special_prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Пример #2
0
    def serialize(envelope: Envelope, special_prefixes: dict = {}) -> str:
        namespacedef_ = (
            'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
            'xmlns: xsd="http://www.w3.org/2001/XMLSchema" '
            'xmlns: soap12="http://www.w3.org/2003/05/soap-envelope"')
        envelope.ns_prefix_ = "soap12"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        prefixes = special_prefixes

        for node in (envelope.Body.anytypeobjs_ +
                     envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, "", prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Пример #3
0
def standard_request_serializer(envelope: Envelope, version: str = "v2") -> str:
    namespacedef_ = f'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:{version}="http://purolator.com/pws/datatypes/{version}"'
    envelope.ns_prefix_ = "soap"
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Header.ns_prefix_ = envelope.ns_prefix_
    [
        apply_namespaceprefix(node, version)
        for node in (envelope.Body.anytypeobjs_ + envelope.Header.anytypeobjs_)
    ]
    return XP.export(envelope, namespacedef_=namespacedef_)
Пример #4
0
    def serialize(envelope: Envelope,
                  default_prefix: str = "ws",
                  extra_namespace: str = "",
                  special_prefixes: dict = None) -> str:

        namespacedef_ = (
            'xmlns:soap="http://www.w3.org/2003/05/soap-envelope" '
            ' xmlns:ws="http://ws.onlinerating.canshipws.canpar.com"'
            ' xmlns:xsd="http://ws.dto.canshipws.canpar.com/xsd"'
            f' {extra_namespace}')
        envelope.ns_prefix_ = "soap"
        envelope.Header = Header()
        envelope.Body.ns_prefix_ = envelope.ns_prefix_
        envelope.Header.ns_prefix_ = envelope.ns_prefix_

        prefixes = {**(special_prefixes or {}), 'request_children': 'xsd'}

        for node in (envelope.Body.anytypeobjs_ +
                     envelope.Header.anytypeobjs_):
            apply_namespaceprefix(node, default_prefix, prefixes)

        return XP.export(envelope, namespacedef_=namespacedef_)
Пример #5
0
def default_request_serializer(envelope: Envelope) -> str:
    namespace_ = (
        ' xmlns:soap="http://www.w3.org/2003/05/soap-envelope"'
        ' xmlns:ws="http://ws.onlinerating.canshipws.canpar.com"'
        ' xmlns="http://ws.dto.canshipws.canpar.com/xsd"'
        ' xmlns:xsd1="http://dto.canshipws.canpar.com/xsd"'
    )
    envelope.ns_prefix_ = 'soapenv'
    envelope.Body.ns_prefix_ = envelope.ns_prefix_
    envelope.Body.anytypeobjs_[0].ns_prefix_ = "ws"
    apply_namespaceprefix(envelope.Body.anytypeobjs_[0].request, "")
    envelope.Body.anytypeobjs_[0].request.ns_prefix_ = "ws"

    return XP.export(envelope, namespacedef_=namespace_)