Los Techies : Blogs about software and anything tech!

Convention, configuration and WCF


Convention is something that's fairly lacking in WCF.  Here's what I'd like to do:

[ServiceContract]
public interface ICustomerSearch
{
    Customer FindCustomerByName(string name);
}

public class Customer
{
    public string Name { get; set; }
    public CustomerType Type { get; set; }
}

public enum CustomerType
{
    Good,
    Canadian
}

I understand maybe just that one attribute.  Here's what I'm forced to do:

[ServiceContract]
public interface ICustomerSearch
{
    [OperationContract]
    Customer FindCustomerByName(string name);
}

[DataContract]
public class Customer
{
    [DataMember]
    public string Name { get; set; }
    [DataMember]
    public CustomerType Type { get; set; }
}

public enum CustomerType
{
    Good,
    Canadian
}

All those noisy attributes, none adding any information nor functionality.  What's consistently bothered me the most is how much configuration is necessary to get straightforward scenarios working.  I'm tired of opting-in to every single piece of information on the contract side.  I want to point to an interface, and just let the framework figure out the rest.

On the plus side, lots of vendors recognized this and created products on top of WCF to make it usable.  Good for them.

Kick It on DotNetKicks.com
Posted Aug 18 2008, 07:56 PM by bogardj
Filed under:

Comments

MotoWilliams wrote re: Convention, configuration and WCF
on 08-18-2008 9:17 PM

Will this be improved, in your eyes, somewhat with the 3.5 SP1 (after MS Fixes the SP) changes to WCF in that [DataContract] / [DataMember]?

MotoWilliams wrote re: Convention, configuration and WCF
on 08-18-2008 9:35 PM

I need to proof read - Does this get better with the SP in that some of those attribues aren't needed anymore?

Rob wrote re: Convention, configuration and WCF
on 08-18-2008 11:10 PM

I Believe that sp1 enables you to serialize objects without DataContract/DataMember.  But, I don't think you can remove the ServiceContract/OperationContract.  I haven't confirmed yet.

bogardj wrote re: Convention, configuration and WCF
on 08-19-2008 7:19 AM

@Rob, Moto

Ah thanks, I'll check that out.  The WCF improvements seem to have been glossed over in many announcements.

Though with Ayende's recent troubles, I'm not sure when I'll upgrade.

Ben Scheirman wrote re: Convention, configuration and WCF
on 08-19-2008 8:44 AM

Wow, I have that same enumeration in many of MY projects!

Jeremy Gray wrote re: Convention, configuration and WCF
on 08-19-2008 10:17 AM

@Jimmy and Ben - Consider yourselves very lucky to only have customers that are either good or awesome. ;)

Arjan`s World » LINKBLOG for August 19, 2008 wrote Arjan`s World » LINKBLOG for August 19, 2008
on 08-19-2008 4:23 PM

Pingback from  Arjan`s World    » LINKBLOG for August 19, 2008

erichexter wrote re: Convention, configuration and WCF
on 08-19-2008 11:46 PM

3.5 sp1 really covers most of your pain, here.  They have clearly stated the support for POCO with wcf in the service pack.  I think it is time for Rhino Mocks to not worry about being all things to all languages and just roll in the fix for c#....

Add a Comment

(required)  
(optional)
(required)  
Remember Me?

Enter the numbers above:
Copyright Los Techies 2008, 2009. All rights reserved.
Powered by Community Server (Commercial Edition), by Telligent Systems