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

Defining the "standalone" declaration using the PactXmlBuilder #1414

Closed
LucasRll opened this issue Aug 12, 2021 · 5 comments
Closed

Defining the "standalone" declaration using the PactXmlBuilder #1414

LucasRll opened this issue Aug 12, 2021 · 5 comments

Comments

@LucasRll
Copy link

LucasRll commented Aug 12, 2021

Hello,

while using the PactXmlBuilder I'm not able to define the XML declaration "standalone". The generated XML-Message always defines "standalone=no" which doesn't match my expected XML-Structure.

Example
I want to define this XML-Structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TestRoot>
    <Test>TestValue</Test>
</Test>

Using this Code:

return PactXmlBuilder(
                "TestRoot",
                null,
                emptyMap(),
                "1.0",
                Charsets.UTF_8.displayName()
            ).build { Test: XmlNode ->
                Test.appendElement("Test", Collections.emptyMap(), string("TestValue"))
            }

Which results in:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<TestRoot>
    <Test>TestValue</Test>
</Test>

Is there a way to define the "standalone" declaration?

Best regards

@uglyog
Copy link
Member

uglyog commented Aug 21, 2021

I've updated the builder, so you can now set it with either:

    PactXmlBuilder(
            "TestRoot",
            null,
            emptyMap(),
            "1.0",
            Charsets.UTF_8.displayName(),
            true
    )

or

    PactXmlBuilder("TestRoot")
        .withStandalone(true)
        .build {

Just note that the JVM XML implementation does not always add the attribute.

standalone == true -> <?xml version="1.0" encoding="UTF-8"?>
standalone == false -> <?xml version="1.0" encoding="UTF-8" standalone="no"?>

@uglyog
Copy link
Member

uglyog commented Aug 22, 2021

4.1.25 released

@LucasRll
Copy link
Author

I tried out your updates in version 4.2.10 because I needed some other fixes as well. Thanks for the fix, but as you already mentioned, in my case the standalone attribute defined "yes" wasn't added to the XML.

So the Unit Tests won't work without further adjustments.

@parvathinakka
Copy link

<SOAP-ENV:Envelope xmlns:SOAP-ENV=http://schemas.xmlsoap.org/soap/envelope/>
SOAP-ENV:Header/
SOAP-ENV:Body
<ns2:GetStudentDetailsResponse xmlns:ns2=http://pactfloweng.jpmchase.net/beans>
ns2:StudentDetails
ns2:id1</ns2:id>
ns2:nameAdam</ns2:name>
ns2:passportNumberE1234567</ns2:passportNumber>
</ns2:StudentDetails>
</ns2:GetStudentDetailsResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
How to achive this using PactXmlBuilder, any suggestions

@rholshausen
Copy link
Contributor

@parvathinakka what have you tried?

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

4 participants