Hi,
I have a doubt.
I have a structure containing an dynamic array.
[DataContract]
public struct Employee
{
[DataMember]
public string id;
[DataMember]
public string name;
[DataMember]
public float[] data;
}
I have a WCF web service which has a function named GetEmployees returns all employee details
[WebGet(UriTemplate = "/Employees")]
List<Employee> GetEmployees();
Service implementation as follows
public List<Employee> GetEmployees()
{
List<Employee> employees = new List<Employee>{
new Employee
{
id = "1",
name = "Abc",
data = new float{1.5f, 3.5f}
},
new Employee
{
id = "2",
name = "def" ,
data = new float{10.5f, 30.5f}
}
}
And I used this service as follows...
var url = new Uri("http://localhost:34698/RestService.svc/Employees");
var request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
var response = (HttpWebResponse)request.GetResponse();
List<Employee> retEmps;
var dataContractSerializer = new DataContractSerializer(typeof(List<Employee>));
using (var responseStream = response.GetResponseStream())
{
retEmps = (List<Employee>)dataContractSerializer.ReadObject(responseStream);
}
response.Close();
The Id and Name are getting properly, but the
data is not getting properly...
Can anyone help me?????