I am still working on a WCF solution that should be able to query the backend of the program and return the results.
The backend stores a dictionary of objects with the name Groups
, and they can be requested using functions such as:
GetGroup
to get a separate group by IDGetGroups
to get a list of groups by tags.
GetGroup
works great with the WCF test client and the application I created. And it works with the following application form code:
List<string> values = new List<string>(); GroupServiceClient client = new GroupServiceClient("WSHttpBinding_IGroupService"); www.test.co.uk.programme.programme Group = new www.test.co.uk.programme.programme(); DateTime time = DateTime.Now; values.Clear(); client.Open(); Group.number = textBox1.Text; client.GetGroup(ref time, ref Group); GroupStorageMessage toReturn = new GroupStorageMessage(); toReturn.group = Group; selectedGroupId = Convert.ToString(toReturn.group.number); values.Add(Convert.ToString(toReturn.group.number)); values.Add(Convert.ToString(toReturn.group.name)); listBox1.ItemsSource=values; client.Close();
GetGroups
works great with the WCF test client, but not with my application.
It sends the request as it should, but returns Null
(note that this code forms another application, and Im uses the link instead of the proxy file)
ServiceReference1.programme Group = new ServiceReference1.programme(); ServiceReference1.GroupServiceClient Client = new ServiceReference1.GroupServiceClient(); DateTime Time = DateTime.Now; Client.Open(); string[] aa = new string[1]; aa[0] = textBox1.Text; Group.tags = aa; Client.GetGroups(ref Time, Group); ServiceReference1.GroupArrayMessage toReturn = new ServiceReference1.GroupArrayMessage(); ServiceReference1.programme[] Groups = new ServiceReference1.programme[1]; toReturn.groups = Groups; ο§= returns null
in the new program ServiceReference1.programme [1]; I really know what to put there.
Interface:
[ServiceContract(Namespace = "http://www.Test.co.uk/groupstorage")] public interface IGroupStorageService { [OperationContract] GroupStorageMessage GetGroup(GroupStorageMessage message); [OperationContract] void AddGroup(GroupStorageMessage message); [OperationContract] void RemoveGroup(GroupStorageMessage message); [OperationContract] void UpdateGroup(GroupStorageMessage message); [OperationContract] GroupArrayMessage GetGroups(GroupStorageMessage message); }
Message:
[MessageContract] public class GroupArrayMessage { [MessageHeader(Name = "time")] public DateTime Time; [MessageBodyMember(Name = "groups")] public Group[] Groups; }
Group contact (sometimes called a program)
[DataContract(Namespace = "http://www.test.co.uk/programme", Name = "programme")] public class Group { [DataMember(Name = "number")] public string Number; [DataMember(Name = "name")] public string Name;