I’m 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 called Groups
and they can be queried with functions like:
GetGroup
to get a single group by IDGetGroups
to get a list of groups by tags.The GetGroup
works fine with the WCF Test Client and the application I have built.
And it works with the following code form the application:
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();
The GetGroups
works perfectly with WCF Test Client but not with my application.
It sends the query as it should but it does return Null
(please note that this code is form another app and I’m using a reference instead of a 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 new ServiceReference1.programme[1]; I am actually guessing what to put there.
Interface:
[ServiceContract(Namespace = "http://www.Test.co.uk/groupstorage")]
public interface IGroupStorageService
{
/**
* Get a group from the collection of groups
*/
[OperationContract]
GroupStorageMessage GetGroup(GroupStorageMessage message);
/**
* Add a group to the collection of groups
*/
[OperationContract]
void AddGroup(GroupStorageMessage message);
/**
* Remove a group from the collection of groups
*/
[OperationContract]
void RemoveGroup(GroupStorageMessage message);
/**
* Update a group in the collection of groups
*/
[OperationContract]
void UpdateGroup(GroupStorageMessage message);
[OperationContract]
GroupArrayMessage GetGroups(GroupStorageMessage message);
}
Message Contract:
[MessageContract]
public class GroupArrayMessage
{
/**
* Message header is the timestamp when the message was created
*/
[MessageHeader(Name = "time")]
public DateTime Time;
/**
* Message body is a collection of Users
*/
[MessageBodyMember(Name = "groups")]
public Group[] Groups;
}
Group contact (sometimes referred as programme)
[DataContract(Namespace = "http://www.test.co.uk/programme", Name = "programme")]
public class Group
{
/**
* The number representing the Programme (Programme ID)
*/
[DataMember(Name = "number")]
public string Number;
/**
* The name of the Programme
*/
[DataMember(Name = "name")]
public string Name;
/// <summary>
/// Add Tags
/// </summary>
[DataMember(Name = "tags")]
public string[] Tags;
I finally found the solution:
GroupService.GroupArrayMessage toReturn = new GroupService.GroupArrayMessage();
GroupService.programme[] Groups = Client.GetGroups(ref Time, Group);
toReturn.groups = Groups;
listBox1.ItemsSource = toReturn.groups;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With