Nadal pracuję nad rozwiązaniem WCF, który powinien być w stanie zapytać o backend programu i zwrócić wyniki.WCF kwerendy tablicy obiektów
backend przechowuje słownikiem obiektów nazywa Groups
i mogą być sprawdzony z funkcji takich jak:
GetGroup
aby uzyskać pojedynczą grupę przez IDGetGroups
aby uzyskać listę grup według tagów.
GetGroup
działa poprawnie z klientem testowym WCF i aplikacją, którą zbudowałem. I to działa w następującej postaci kodu aplikacji:
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();
W GetGroups
doskonale współpracuje z WCF test klienta, ale nie z mojej aplikacji.
Wysyła zapytanie jak powinno ale ma wrócić Null
(proszę pamiętać, że ten kod jest tworzyć inną aplikację i używam odniesienie zamiast pliku proxy)
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
w nowym ServiceReference1. program [1]; Zgaduję, co tam umieścić.
interfejsu:
[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);
}
zamówieniu Wiadomość
[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;
}
kontakt grupy (czasami określane jako program)
[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;
Proszę wkleić kod interfejsu usługi i klasy implementacji usług. Proszę również wkleić kod dla klasy Group. Łatwiej będzie odpowiedzieć, gdy kod będzie dostępny. –
PS Wiem, że zapytanie wysłane z aplikacji jest w porządku, ponieważ system rejestracji backend oznaczy go jako pomyślne zapytanie i zwróci wynik w pliku dziennika – user1211929
Fajne pytanie. A co z plikami app.config. Czy są równe w obu twoich aplikacjach? –