Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The service returns different responses to the same request, in no particular order. #650

Closed
random343 opened this issue Dec 8, 2020 · 4 comments
Labels

Comments

@random343
Copy link

random343 commented Dec 8, 2020

The service returns different responses to the same request, in no particular order.

Example service:

# -*- coding: utf-8 -*-

from spyne import Application, rpc, ServiceBase
from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from spyne.model.primitive import String
from spyne.model.complex import ComplexModel

class ErrorType(ComplexModel):

    __namespace__ = "other.ns"

    errorCode = String.customize(sub_ns="other.ns")

class PortType(ServiceBase):

    @rpc(_returns = [ErrorType.customize()])
    def test(ctx):
        return ErrorType(errorCode="code")

app = Application([PortType], tns="target.ns", in_protocol=Soap11(validator="soft"), out_protocol=Soap11())
application=WsgiApplication(app)

Request:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <test xmlns="target.ns"/>
    </Body>
</Envelope>

Response:

<?xml version="1.0" encoding="UTF-8"?>
<soap11env:Envelope xmlns:s0="other.ns" xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="target.ns">
    <soap11env:Body>
        <tns:testResponse>
            <tns:testResult0>
                <s0:errorCode>code</s0:errorCode>
            </tns:testResult0>
        </tns:testResponse>
    </soap11env:Body>
</soap11env:Envelope>

or

<?xml version="1.0" encoding="UTF-8"?>
<soap11env:Envelope xmlns:soap11env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tns="target.ns">
    <soap11env:Body>
        <tns:testResponse>
            <tns:testResult0>
                <ns0:errorCode xmlns:ns0="other.ns">code</ns0:errorCode>
            </tns:testResult0>
        </tns:testResponse>
    </soap11env:Body>
</soap11env:Envelope>

Why is that?
How to avoid this?

@plq
Copy link
Member

plq commented Dec 8, 2020

Can you add the missing bits and fix the formatting as well?

@plq
Copy link
Member

plq commented Dec 10, 2020

Both xml documents are equivalent, so any SOAP client should properly parse both documents.

That said, I can't see how the same server could produce different outputs randomly like this. Are you sure nothing is different between the servers that produce these two responses?

@random343
Copy link
Author

random343 commented Dec 17, 2020

I understand that the answers are equivalent.
But I met a client for whom these are different answers.

I noticed a feature.
This situation is reproduced only when the script is run through an external uwsgi server.
Through the built-in
from wsgiref.simple_server import make_server
it does not repeat itself.

@plq plq added the Interop label Dec 19, 2020
@plq
Copy link
Member

plq commented Dec 19, 2020

this is outside of scope of this project. xml canonicalization should be made in an after_serialize hook

@plq plq closed this as completed Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants