In soap mock service i want to have dynamic response base on value in request so i create the script but i get error Failed to dispatch using script; groovy.lang.MissingMethodException: No signature of method: static java.lang.String.parseString() is applicable for argument types: (String) values: [testowy]
My script looks that
def holder = new com.eviware.soapui.support.XmlHolder( mockRequest.requestContent )
// get arguments
def invoiceId = Integer.parseInt( holder["//invoiceId"] )
def header1 = String.parseString( holder["//header1"] )
def header2 = String.parseString( holder["//header2"] )
def invoiceNumber = String.parseString( holder["//invoiceNumber"] )
def invoiceOrder = Integer.parseInt( holder["//invoiceOrder"] )
def totalValue = Float.parseFloat( holder["//totalValue"] )
def categoryId = Integer.parseInt( holder["//categoryId"] )
def categoryName = String.parseString( holder["//categoryName"] )
requestContext.result = invoiceId header1 invoiceNumber invoiceOrder invoiceDate dueDate totalValue categoryId categoryName
The problem is with String.parseString i didint know why for every other arguments its ok can someone explain why i get this error
CodePudding user response:
There is no method String.parseString
in the JDK. What you want to do is something like the following:
def categoryName = holder["//categoryName"]
However, I suspect that may even be questionable because XmlHolder
is a map and get()
returns an Object
so it's unknown what that's going to return. But there is a method that returns a String which is what you're after so you might do this instead:
def categoryName = holder.getNodeValue("//categoryName")
That method seems to take an xpath expression and return the contents of an XML node as a String.