WCF object reference methods missing
I have created a开发者_StackOverflow中文版 WCF service in my project and I have some classes on the server side that I use on the servers side and on the client side via reference.
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
namespace DataEntities {
[DataContract]
public class PlanEntriesData
{
private ObservableCollection<entry> entries;
public PlanEntriesData()
{
entries = new ObservableCollection<Entry>();
}
[DataMember]
public ObservableCollection<Entry> Entries
{
get { return entries; }
set { entries = value; }
}
public string helloWorld()
{
return "hello";
}
}
}
The problem is on the client side the object has no helloWorld() method. Can anyone help me with how to get the methods ?
best regards sushiBite
Methods are not sent, only properties. There is currently no way to supply the implementation details of a method across a WCF boundary on a DataContract.
If you want to be able to operate on an entity from the client in such a way, you will need to add the HelloWorld operation to your ServiceContract.
public IMyService
{
string HelloWorld(PlanEntriesData data);
}
I'd recommend a little bit of reading up on service orientation and WCF in general. I've found "Windows Communication Step-by-Step" to be a good read for beginners.
You may need to add an [OperationContract] in your WCF Host projects Interface and implement it in the service class itself to make it available to the clients.
精彩评论