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

Cloudflare and <soap:Header> #1400

Open
JonhSilver opened this issue Dec 7, 2023 · 0 comments
Open

Cloudflare and <soap:Header> #1400

JonhSilver opened this issue Dec 7, 2023 · 0 comments

Comments

@JonhSilver
Copy link

JonhSilver commented Dec 7, 2023

zeep 4.1.0

https://draudejai.sodra.lt/edas-external/services/DataService?wsdl

soapui5.7.0 auto create request is:

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:typ="http://types.data.external.ws.edas.sodra.epr.lt">
soap:Header<wsse:Security soap:mustUnderstand="true" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"><wsse:UsernameToken wsu:Id="UsernameToken-49CCFE59547E2413CF17019748335422">wsse:Username.............</wsse:Username><wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">..................</wsse:Password><wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">iftd......uKjQ==</wsse:Nonce>wsu:Created2023-12-07T18:47:13.542Z</wsu:Created></wsse:UsernameToken></wsse:Security></soap:Header>
soap:Body
typ:getPossibleDocuments/
</soap:Body>
</soap:Envelope>

and working fine

python zeep create request is:

<soap-env:Envelope xmlns:soap-env="http://www.w3.org/2003/05/soap-envelope">
soap-env:Body
<ns0:getPossibleDocuments xmlns:ns0="http://types.data.external.ws.edas.sodra.epr.lt"/>
</soap-env:Body>
</soap-env:Envelope>

and get Cloudflare chalange
why this happens and how to fix?

class MyLoggingPlugin(Plugin):
    def egress(self, envelope, http_headers, operation, binding_options):
        if not DEBUG: return
        # Format the request body as pretty printed XML
        xml = etree.tostring(envelope, pretty_print=True, encoding='unicode')
        print(f'\nRequest\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}')

    def ingress(self, envelope, http_headers, operation):
        if not DEBUG: return
        # Format the response body as pretty printed XML
        xml = etree.tostring(envelope, pretty_print=True, encoding='unicode')
        print(f'\nResponse\n-------\nHeaders:\n{http_headers}\n\nBody:\n{xml}')


        session = Session()
        session.trust_env = True
        session.verify = True
        DEBUG = True
        from zeep.wsa import WsAddressingPlugin

        client = Client(
            wsdl=wsdl
            , wsse=UsernameToken(Username, Password)
            , transport=Transport(session=session)
            ,plugins=[MyLoggingPlugin(),WsAddressingPlugin()]
        )
        with client.settings(raw_response=True):
            node = client.service.uploadEdasDraft(uploadedFileName, encoded_string) 
@JonhSilver JonhSilver changed the title Clodflare and <soap:Header> Cloudflare and <soap:Header> Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant