So I managed to use SOAP no problem but I am having difficulty using WCF to do the same job.
My application takes a list of numbers then sums them using a webservice, I can successfuly do this using SOAP but now I am running into trouble trying it with WCF.
Webservices09004961.ServiceReference1.Service1SoapClient SumCLient = new ServiceReference1.Service1SoapClient();
Webservices09004961.ServiceReference2.IService1 SumClientWCF = new ServiceReference2.Service1Client();
Notice that I call the client method the same way this seems fine.
However when I try the same method I cannot seem to 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 fear 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();
}
}
}
This seems fine to me? My IService tho may be the problem this is all I have for it:
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);
}
Normally I would expect once I type Myservice.ServiceReference1. arrayofdoubles
would come up but I dont have that option this time the only option I am getting is Service1
or serviceclient
.
EDIT
To clarifify abit more because I use this method (because ArrayOfDoubles isnt there like with my soap version commented out)
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 get the error message:
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?)
On this line under AddRange.
arrayOfdoubles.AddRange(myArrai12);
Im struggling to find out why:
Webservices09004961.ServiceReference2.
wont show ArrayOfDoubles
Like it does with my soap version.
This might help show whats going on: