Wcf service for communication and data transmission

I recently contributed to the development of a WCF service that acts as a kind of multicast relay (i.e. it takes some input, does some processing, and then sends it to several other external services). this service (which I will call "my service") feeds the data to a second back-end service.

this data will be passed from my service as XML, stored in a string. so my service can just accept a string as a parameter to request a method, but this is not ideal as we lose type safety.

the second service has a class that encapsulates all the information that my service requires to process and ultimately be passed to external services.

the second service provides this class in this data contract. Ideally, to maintain type safety and not require a lot of changes in the second implementation of the service, I should accept this type of class as an argument for my service.

what would be the best way for me to say in my datacontract that I require this type of class without duplicating code? can I add a service reference for this second class and then use the proxy class that is generated in my data contract?

I just can't get around it, although it seems like a trivial problem!

any help is welcomed!

+1


source to share


1 answer


If you're trying to avoid duplicating classes, place the class declaration in your own assembly and pass that DLL between all sides of the WCF service. When you create a service link, you can choose which assemblies will be available (if you are using a VS GUI utility).



Using a proxy class can be a good avenue too. If you expose your main data class as a data contract then create a proxy, the proxy will have a public class version that can be used by your other services.

+2


source







All Articles