0
votes

I am new to WCF, I am able to add multiple <OperationContract()> under one service contract, however, could not fine any information on how to add multiple DataContracts under a single contract.

The problem is: With one service on contract (a single service reference in WPF) many procedures can be accessed, however, now I need to create many service references (one for each data Contract) in WPF, and that is bad option I believe.

My Classes are not inherited, they are independent.

Please advice if there is a option to get all class (data contracts) under one service reference or an alternative procedure if there could be one.

Thank you.

1
You can define multiple data contracts, why did you think you can't?Gökhan Çoban
Yes, I can define multiple data contracts,however, when I add service reference in WPF, I need to add that many services and update each reference without forgetting when I update a class.surpavan

1 Answers

0
votes

One common thing is to create your own proxy, service and data contracts on the client and not use service reference option. You still have to update things manually when service change but gives you ability to control classes and interfaces created for data and service contracts.

If you own both service side and client side, then you can also share types (by referencing a dll with data and service contracts). If you don't own service side, you can define your own interface and data contracts in the client. As long as they match with the service contracts things will work. You can use add reference or wsdl.exe utility to generate service and data contracts.

If you use Add Service Reference, you can check an option to use types from referenced assemblies. As long as you have reference to the service and data contract assemblies, add service reference will reuse the types.