6
我還是一個WCF的解決方案,應該能夠查詢程序的後臺並返回結果工作的數組。WCF查詢對象
後端存儲對象的字典叫Groups
,他們可以用功能進行查詢,如:
GetGroup
通過IDGetGroups
獲得單組獲得通過標籤組的列表。
GetGroup
可以正常使用WCF測試客戶端和我構建的應用程序。 並將它與下面的代碼表的工作方式應用:完美
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
作品與WCF測試客戶端,但不是我的申請。
它發送查詢,因爲它應該,但它確實返回Null
(請注意,此代碼是形成另一種應用程序,我使用的是基準而不是代理文件)
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
在新ServiceReference1。方案[1];我其實猜測要放在那裏。
接口:
[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);
}
消息合同:
[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;
}
組觸點(有時被稱爲程序)
[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;
,請複製粘貼服務接口的代碼和服務實現類。也請粘貼Group類的代碼。這將是比較容易回答的時候代碼將可 – 2012-04-10 16:17:06
PS我知道查詢發送形式的應用是好的,作爲後臺日誌系統將其標記爲一個成功的查詢,並在日誌文件中 – user1211929 2012-04-10 16:17:26
酷派問題返回結果。怎麼樣app.config文件。它們在你的兩個應用程序中是否相同? – 2012-04-10 17:38:34