Forum Discussion

dragonfly03's avatar
dragonfly03
Regular Visitor
7 years ago
Solved

How do you convert SOAP Response to double or integer?

I am new to SOAPUI/Groovy.  I manage to connect to a web service and get a response.  I manage to see the response in groovy script.  The response is a string like "1.0966" and when I try to convert I get NumberFormatExpection.  Below is my code:

 

def conversionRate = context.expand( '${EuroConvertorRequest#Response#declare namespace ns1=\'http://tempuri.org/\'; //ns1:EuroConvertorResponse[1]}' )

double convertedNumber = Double.parseDouble(conversionRate);
log.info("Conversion Rate: " + convertedNumber);

 

Error message is: java.lang.NumberFormatException: For input string: " 1.0966 " error at line: 11

 

BUT, when I do double convertedNumber = Double.parseDouble("1.0966") it works fine then!!

 

Any ideas?