Can WCF service transmit type (client doesn't know this type) information? -
i'm working on simple plug-in framework. wcf client need create instance of 'isubject' , send service side. 'isubject' can extended user. thing client knows @ runtime id of subclass of 'isubject'.
firstly, client need type information of specific subclass of 'isubject'. secondly, client using reflection enumerate members create custom property editor each member can asigned proper value. lastly, client create instance of subclass , send service.
the problem how client type information through wcf communication?
i don't want client load assembly subclass (of 'isubject') exists.
thanks
first, need aware there no magic way wcf provide type information client in scenario have descibed. if going it, have provide mechanism yourself.
next, understand wcf not pass objects server client or vice versa. passes xml infosets. often, xml infoset passed includes serialized representation of object existed on sender's side; in case, if client knows type (i.e. can load type's metadata assembly), can deserialize xml instantiate identical object on client side. if client doesn't have type metadata, can't: normal case wcf unless data contract types in assemblies shared both server , client implementations (generally not idea).
the way wcf used (for example if client implemented using "service reference" in visual studio), happens service publishes wsdl metadata describing operations , xml schemas operation parameters , return values, , these set of types generated use in client implementation. these not same .net types data contract types used service implementation, "equivalent" in sense can serialized same xml data passed on network. type generation done @ design time in visual studio.
in order trying do, type generation @ runtime, need mechanism client can sufficient knowledge of structure of xml representing various types of object implementing isubject can understand xml received service , generate appropriate xml service expecting (either working xml directly, or deserializing/serializing in fashion). if really, want this, possible ways might be:
some out-of-band mechanism whereby client preconfigured relevant type information corresponding each subclass of isubject might see. link provided in blindmeis's answer 1 way that.
provide separate service operation client can translate id of subclass type metadata subclass (perhaps xsd schema client generate suitable serializable .net type round trip xml).
it feasible in principle service pass type metadata in format within headers of response containing serialized object. client need read, interpret , act on type infomation in appropriate fashion.
whichever way, lot of effort , not standard way of using wcf. have decide if it's worth it.
Comments
Post a Comment