I'm attempting to pass a generic list of integers from a client application to a web service using the the SOAP protocol.
When I attempt to pass the list as a parameter to the web method declared in the web service, I get the error "cannot convert from generic.list to ArrayOfInt".
How do I go about resolving this?
// web service method
[WebMethod(CacheDuration = 30, Description = "Returns the calculated sum value of all numbers supplied in the list")]
public int CalculateListSum(int[] list)
{
int _sum = 0;
foreach (int _val in list)
{
_sum += _val;
}
return _sum;
}
// client app buton click event
private void btnRun_Click(object sender, EventArgs e)
{
string str = this.tbValues.Text;
// clear the list
ClearIntList();
// take the textbox input, format and add to the List
PopulateIntList(str);
WSCalculate.CalculateSoapClient client = new WSCalculate.CalculateSoapClient();
int[] _int_array = this._int_list.ToArray();
// the line below is generating the error
int _result = client.CalculateListSum(_int_array);
this.tbResult.Text = _result.ToString();
}
Error 1 The best overloaded method match for 'WFCalculate.WSCalculate.CalculateSoapClient.CalculateListSum(WFCalculate.WSCalculate.ArrayOfInt)' has some invalid arguments WFCalculate\Form1.cs 58 27 WFCalculate
Error 2 Argument '1': cannot convert from 'int[]' to 'WFCalculate.WSCalculate.ArrayOfInt' WFCalculate\Form1.cs 58 51 WFCalculate