Ask a Question

Need help with converting a String Property to Integer while Sending a soap request

SOLVED
Ahaan
New Contributor

Need help with converting a String Property to Integer while Sending a soap request

Hi,

 

I am new to Soap UI and am trying the following scenario -

 

Scenario: Read an excel file for the data to be used in the Soap requests and also which Test steps are to be executed  and then execute the same.

 

WSDL used:http://www.dneonline.com/calculator.asmx?WSDL

 

Issue: setPropertyValue() takes in only String parameters from what I understand so it looks like the integer data from the excel is stored in string format in  the properties created. The Soap requests in questions need integer data but when I import the data into the requests using property expansion,the data loaded is in string format which leads to the following fault string being returned. How do I get past this issue?

 

 <faultstring>System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (5, 31). ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer&amp; number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Xml.XmlConvert.ToInt32(String s)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read1_Add()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</faultstring>

 

 

Excel data:

ExcelSS.png

 

Groovy code:

 

Groovy1.png

 

Add Request:

 

Add.png

 

 

I tried  a few things like (${#testSuite#testData1}).toInteger() and ${=(int)#testSuite#testData1} but they didn't work.

 

Thanks for any help on this.

4 REPLIES 4
nmrao
Champion Level 3

Would you mind posting the script? Otherwise, need write code by looking at your image of the post to give a try from other people end.

Thank you for understanding.


Regards,
Rao.
Ahaan
New Contributor

Here's the Groovy code:

 

import java.io.*
import jxl.*
def f=new File("C:\\Users\\Ahaan\\Desktop\\SOAPXLS\\Calculator.xls") def wb=Workbook.getWorkbook(f) def ws=wb.getSheet("DataSheet") def rowcount=ws.getRows() log.info rowcount for(def count=1;count<rowcount;count++) { Cell execute=ws.getCell(2,count) if(execute.getContents().equalsIgnoreCase("Y")) { Cell data1=ws.getCell(3,count) testRunner.testCase.testSuite.setPropertyValue("testData1",data1.getContents()) Cell data2=ws.getCell(4,count) testRunner.testCase.testSuite.setPropertyValue("testData2",data2.getContents()) Cell TestStep=ws.getCell(1,count) testRunner.runTestStepByName(TestStep.getContents()) } }

 Thanks.

Ahaan
New Contributor

My mistake. It's #TestSuite# , I was trying with #testSuite#. Works properly now.

nmrao
Champion Level 3

Glad you could figured out yourself and thank you for posting the update.


Regards,
Rao.
cancel
Showing results for 
Search instead for 
Did you mean: