Send Interface Definition Over Wire (WCF Service)

I have a WCF service that generates loads of Entity Framework objects (as well as some other structures and simple classes used to facilitate loading) and sends them to the client application.

I changed 2 classes to implement the interface so that I can refer to them in my application as one type of object. Like this example: Is it possible to force properties created by the Entity Framework to implement interfaces?

However, the interface type is not being added to my WCF service proxy thingymebob because it does not directly refer to the objects that are sent back over the wire.

So in my application that uses the service proxy classes, I cannot use or reference my interface.

Any ideas what I'm missing?

Here's some sample code:

//ASSEMBLY/PROJECT 1 -- EF data model

namespace Model
{
    public interface ISecurable
    {
        [DataMember]
        long AccessMask { get; set; }
    }

    //partial class extending EF generated class
    //there is also a class defined as "public partial class Company : ISecurable"
    public partial class Chart : ISecurable
    {
        private long _AccessMask = 0;
        public long AccessMask
        {
            get { return _AccessMask; }
            set { _AccessMask = value; }
        }

        public void GetPermission(Guid userId)
        {
            ChartEntityModel model = new ChartEntityModel();
            Task task = model.Task_GetMaskForObject(_ChartId, userId).FirstOrDefault();
            _AccessMask = (task == null) ? 0 : task.AccessMask;
        }
    }
}

//ASSEMBLY/PROJECT 2 -- WCF web service
namespace ChartService
{
    public Chart GetChart(Guid chartId, Guid userId)
    {
         Chart chart = LoadChartWithEF(chartId);
         chart.GetPermission(userId); //load chart perms
         return chart; //send it over the wire
    }
}

      

0


a source to share


1 answer


Interfaces will not appear as separate objects in your WSDL - they will simply add their methods and properties to the object that provides them.

What you want to accomplish can be done with abstract classes. They will be perceived as different objects.



Good luck. Let us know how you chose to proceed.

+1


a source







All Articles