c# - How To Use Interface as DataContract in WCF -
i need invoke webservice operations using standard wsdl, data objects must different in client , in server.
using interfaces data objects in common library, making proxy classes in client , in server.
then, i'm declaring operation contract using interface, wcf don't recognize it.
i yet tried use datacontractserializerbehavior , set knowntypes, no success yet.
someone can help-me? i've attached complete solution more details.
public interface thing { guid id {get;set;} string name {get;set;} thing anotherthing {get;set;} } [datacontract] public class thingatserver: bsondocument, thing // mongodb persistence { [datamember] guid id {get;set;} //... } [datacontract] public class thingatclient: thing, inotifypropertychanged // wpf bindings { [datamember] guid id {get;set;} //... } [servicecontract] public interface myservice { [operationcontract] thing dosomething(thing input); }
click here see sample project on github testcases
i've created wcf service contract:
[operationcontract] compositetypeserver getdatausingdatacontract( compositetypeserver composite );
my compositetypeserver
looks this:
[datacontract( namespace = "http://enes.com/" )] public class compositetypeserver { [datamember] public bool boolvalue { get; set; } [datamember] public string stringvalue { get; set; } }
then i've created client project type compositetypeclient
:
[datacontract( namespace = "http://enes.com/" )] public class compositetypeclient { [datamember] public bool boolvalue { get; set; } [datamember] public string stringvalue { get; set; } }
then i've added reference service , selected reuse types. worked charm. able use compositetypeclient
on client side.
so trick specify namespace datacontract match on both client , service.
[datacontract( namespace = "http://enes.com/" )]
ps. can provide full working vs solution on request.
Comments
Post a Comment