WCF array of paired numbers not called successfully

So I was able to use SOAP without issue, but I find it difficult to use WCF to do the same job.

My application takes a list of numbers and then sums them using a webservice, I can successfully do this using SOAP, but now I am having difficulty trying to use WCF.

        Webservices09004961.ServiceReference1.Service1SoapClient SumCLient = new ServiceReference1.Service1SoapClient();
        Webservices09004961.ServiceReference2.IService1 SumClientWCF = new ServiceReference2.Service1Client();

      

Please note that I am calling the client method in the same way that seems good.

However, when I try to use the same method, I cannot call ArrayOfDoubles like my previous method using soap:

        Webservices09004961.ServiceReference2.Service1Client arrayOfdoubles = new ServiceReference2.Service1Client(); //this line is wrong but I tryed it anyway
        //Webservices09004961.ServiceReference1.ArrayOfDouble arrayOfDoubles = new Webservices09004961.ServiceReference1.ArrayOfDouble(); 
        arrayOfDoubles.AddRange(myArrai12);
        string f = SumCLientWCF.CalculateSum(arrayOfDoubles);
        Console.WriteLine("The sum total equals: " + f);

      

My problem, I'm afraid, lies in my wcf method, Service1.svc.cs looks like this:

namespace WcfSum
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
    public class Service1 : IService1
    {
        public string CalculateSum(List<double> listDouble)
        {
            return listDouble.Sum().ToString();

             //return listDouble.Select(n => (double)n).ToString();

        }
    }
}

      

Does this sound wonderful to me? My IService might be a problem, this is all I have for that:

namespace WcfSum
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface IService1
    {

        [OperationContract]
        string CalculateSum(List<double> listDouble);

    }

      

I usually expect as soon as I type Myservice.ServiceReference1. arrayofdoubles

will appear, but this time I don't have that option, the only option I get is Service1

or serviceclient

.

EDIT

To clarify abit more, because I am using this method (because ArrayOfDoubles doesn't exist since my soap version is forgotten)

    Webservices09004961.ServiceReference2.Service1Client arrayOfdoubles = new ServiceReference2.Service1Client(); //this line is wrong but I tryed it anyway
    //Webservices09004961.ServiceReference1.ArrayOfDouble arrayOfDoubles = new Webservices09004961.ServiceReference1.ArrayOfDouble(); 

      

I am getting the error:

Error   1   'Webservices09004961.ServiceReference2.Service1Client' does not contain a definition for 'AddRange' and no extension method 'AddRange' accepting a first argument of type 'Webservices09004961.ServiceReference2.Service1Client' could be found (are you missing a using directive or an assembly reference?)

      

In this line, under AddRange.

arrayOfdoubles.AddRange(myArrai12);

      

I am trying to figure out why:

Webservices09004961.ServiceReference2.

wont show arrayofdoubles

Like my soap version.

This can help show what's going on:

enter image description here

0


source to share


1 answer


OK, some fixes:

    var arrayOfdoubles = new ServiceReference2.Service1Client(); 
    var inputData = new List<double> { 1.1, 2.2 };
    string f = arrayOfdoubles.CalculateSum(inputData);
    Console.WriteLine("The sum total equals: " + f);

      



Obviously arrayOfdoubles

not a good name (it's a client proxy), but I left it as a link to your code.

+1


source







All Articles