Skip to content

SoapBinding - create_message function broken - wrong indentation #1475

@Maxdeboer9

Description

@Maxdeboer9

Zeep version: 4.3.2

I have no script or WSDL since the error is pretty straight forward.

When using the create_message from the SoapBinding class directly, I get the following error:

AttributeError: 'NoneType' object has no attribute 'settings'

From line 103 in soap.py:

if client.settings.extra_http_headers:
            http_headers.update(client.settings.extra_http_headers)

Since client is None when using the binding.create_message directly.

There is an if client check above, but this part isn't indented correctly and will always fail when there is no Client

       # Apply ws-addressing
        if client:
            if not options:
                options = client.service._binding_options

            if operation_obj.abstract.wsa_action:
                envelope, http_headers = wsa.WsAddressingPlugin().egress(
                    envelope, http_headers, operation_obj, options
                )

            # Apply plugins
            envelope, http_headers = plugins.apply_egress(
                client, envelope, http_headers, operation_obj, options
            )

            # Apply WSSE
            if client.wsse:
                if isinstance(client.wsse, list):
                    for wsse in client.wsse:
                        envelope, http_headers = wsse.apply(envelope, http_headers)
                else:
                    envelope, http_headers = client.wsse.apply(envelope, http_headers)

        ###############################
        # WRONG INDENTATION BELOW
        ###############################

        # Add extra http headers from the setings object
        if client.settings.extra_http_headers:
            http_headers.update(client.settings.extra_http_headers)

Fix:
A simple extra indent to these two lines solves makes it fall inside the if client and solves the issue for me

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions