I have a Product Datacontract with a couple of Datamembers that are part of a WCF Service. I also serialise and store this Product Datacontract in my app using the DataContractSerializer.
Now, I want to remove some of the Datamembers of the Product Datacontract when the Service metadata (WSDL) gets generated. However, I want all Datamembers from the Product Datacontract to be available when I serialise the object within my app.
What I wanna do, actually, is this: grab hold of the WSDL generation process and remove the required Datamembers from being injected into the generated WSDL.
Thanks Mofolo
Hacking WSDL to not contain the information will not help you. Your service will still use full serialization of your types when passing them to your client and when deserializing them from your clients. Instead of hacking WSDL and WCF use DTOs for WCF service = new set of types which will contain only properties you really want to exchange with clients. Convert your master object to DTOs and vice-versa (you can either create your own custom convertors or use some framework like AutoMapper). This is the best practice.