简体   繁体   中英

WCF: Can I expose a class of an external assembly?

I have given reference to a dll in my WCF service application. My WCF operation requires input of type class (let's say XYZ) which is present in that dll.

Now, is it possible to expose that class to the clients so that they can call the exposed wcf method?

If yes then can you please explain the idea or with some pesudo code/references ?

Thanks in advance !

Contract:

[OperationContract]
void Add(XYZ item);

Server:

public void Add(XYZ item){}

[DataContract]
class XYZ{}

Client:

var item = new XYZ();
client.Add(item);

Dll containing 'XYZ' should be referenced by both Server and Client. Class 'XYZ' should have 'DataContract' attribute. Implementation is more or less similar to FaultContracts in WCF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM