I am working on an automation script that uses SoapUI api classes to read a wsdl and execute it after dynamically filling data from a excel file.
I am using XmlHolder class to get or set Soap request Node values but I am facing issues in accessing the request XML nodes using the XPath with XmlHolder. Following is the sample request and the code that I have tried:
//sample Soap request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
<soapenv:Header/>
<soapenv:Body>
<web:ConversionRate>
<web:FromCurrency>?</web:FromCurrency>
<web:ToCurrency>?</web:ToCurrency>
</web:ConversionRate>
</soapenv:Body>
</soapenv:Envelope>
//code
XmlHolder xmlHolder = null;
try {
xmlHolder = new XmlHolder(soapOperation.createRequest(true));
} catch (XmlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
};
xmlHolder.declareNamespace("web","http://www.webserviceX.NET");
// Here tagCell.getStringCellValue() = FromCurrency
System.out.println("FromCurrency= " + request.getNodeValue(".//web:" + tagCell.getStringCellValue()));
request.setNodeValue(".//web:" + tagCell.getStringCellValue() , valCell.getStringCellValue());
//Other tried xPath
//System.out.println("FromCurrency= " + request.getNodeValue("//web:" + tagCell.getStringCellValue()));
//System.out.println("FromCurrency= " + request.getNodeValue("//:" + tagCell.getStringCellValue()));
//System.out.println("FromCurrency= " + request.getNodeValue("//*:" + tagCell.getStringCellValue()));
Can anyone please suggest the xPath for XmlHolder.setNodeValue().
Also to be noted here that Soap nodes have namespace i.e; <web:FromCurrency>
Thanks in advance