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

Namespaces declared in Soap:Envelope ignored when comparing SOAP response with expected value #2469

Open
bouncysteve opened this issue Dec 22, 2023 · 2 comments

Comments

@bouncysteve
Copy link

I am testing a soap service which sometimes returns nil elements, defined in xsi namespace. Unlike issue #754, the xsi namespace is defined in the response, it is declared in the soap envelope, so that this test using locally defined xml will pass:

Scenario:

        * def content =
        """
        <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soap:Body>
        <GetNextDeparturesResponse xmlns="http://gndrurl">
        <DeparturesBoard
        xmlns:c6="http://c6url"
        xmlns:t13="http://t13url">
        <t13:destination>
        <t13:service xsi:nil="true"/>
        </t13:destination>
        </DeparturesBoard>
        </GetNextDeparturesResponse>
        </soap:Body>
        </soap:Envelope>
        """

        * def content2 =
        """
        <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <soap:Body>
        <GetNextDeparturesResponse xmlns="http://gndrurl">
        <DeparturesBoard
        xmlns:c6="http://c6url"
        xmlns:t13="http://t13url">
        <t13:destination>
        <t13:service xsi:nil="true"/>
        </t13:destination>
        </DeparturesBoard>
        </GetNextDeparturesResponse>
        </soap:Body>
        </soap:Envelope>
        """
        
        * match content == content2

However, a scenario where a SOAP request produces the same XML in the response will fail on the match statement:

 ...
 Then match soapCall.response == content2
 ...
javax.xml.transform.TransformerException: java.lang.RuntimeException: Namespace for prefix 'xsi' has not been declared.

This looks like a problem in the handling of the response when used in match, as if it is being treated differently to any other xml document, perhaps by stripping the soap wrapper from both documents before comparing, so that the xsi namespace declaration is lost?

Note that this problem happens regardless of the value of xmlNamespaceAware

@ptrthomas
Copy link
Member

thanks for the repro. you may have seen this already, but a workaround could be to manually strip / modify the namespace data from the XML: https://stackoverflow.com/a/75626292/143475

@bouncysteve
Copy link
Author

bouncysteve commented Dec 22, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants