I am using groovy-wslite for making SOAP calls to a WSDL and need one of the xml nodes that it generates to have an attribute. Here is an example of what I need:
<soap-env:Envelope xmlns:soap-env='http://schemas.xmlsoap.org/soap/envelope/'
<soap-env:Header />
<soap-env:Body>
<getSomething id = "1">
</getSomething>
</soap-env:Body>
</soap-env:Envelope>
In this example, I need the getSomething call to have the id attribute.
Besides a closure that will build out child elements, you can also pass a map whose key/values will become attributes. The following would generate a SOAP request matching what you have.
Groovy’s MarkupBuilder is used under the hood, so any examples you find for MarkupBuilder should also apply when generating SOAP requests with wslite.