Forum Discussion
Hi,
If you would be ok to use Groovy to provide the SOAP request (including parameters), then please take a look at my solution to the following post:
Does this sort you out?
Let me know if you need more help,
Cheers,
Rupert
So, in particular you can create the request XML as you did and use Groovy Slurper to amend it:
...
//Create the request and capture the XML content
String requestXMLString = operation.createRequest( true ).toString()
System.out.println("Request String Content: "+requestXMLString);
//Use XMLSlurper to pass and update the invoiceNo=7 in my getInvoice operation
def envelopeNode = new XmlSlurper().parseText(requestXMLString)
envelopeNode.Body.getInvoice.invoiceNo=7
//This is just to serialize the XML objects back to a request XML String
XmlUtil xmlUtil = new XmlUtil()
requestXMLString = xmlUtil.serialize(envelopeNode)
println( "modified request: g"+requestXMLString)
//Update the SoapUI request content with the new updated XML request content
request.setRequestContent(requestXMLString)
...
Then when you submit the request it should be fine.
Hope this helps,
Cheers,
Rupert
- prm_svm9 years agoNew Contributor
Hi Rupert,
Thanks,
As per your suggestions, I have created a new groovy class and write the below method in groovy class
class ParseXML {
def parseFile(xmlString) {
def envelopeNode = new XmlSlurper().parseText(requestXMLString)
envelopeNode.Body.CreateDevice.name="testSoapUI"
return envelopeNode
}
}
But am unable to set the parameter in the request
In java code:
-------------
String requestContent = wsdlOperation.createRequest(true).toString();
System.out.println(requestContent);
ParseXML xml = new ParseXML(); // groovy file name
Object obj = xml.parseFile(requestContent);But the envelopeNode returns - ??
My request is (requestContent):
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://soap.xxx.com">
<soapenv:Header/>
<soapenv:Body>
<soap:CreateDevice>
<!--Optional:-->
<soap:name>?</soap:name>
<!--Optional:-->
<soap:size>?</soap:size>
</soap:CreateDevice>
</soapenv:Body>
</soapenv:Envelope>Kindly guide me..
Related Content
Recent Discussions
- 4 days agoemoya