I am trying to consume a WCF service in a class library by adding a service reference to it. In one of the class libraries it gets consumed properly and I can access the client types in order to generate a proxy off of them. However in my second class library (or even in a console test app), when i add the same service reference, it only exposes the types that are involved in the contract operations and not the client type for me to generate a proxy against.
e.g. Endpoint has 2 services exposed - ISvc1 and ISvc2. When I add a service reference to this endpoint in the first class library I get ISvc1Client andf ISvc2Client to generate proxies off of in order to use the operations exposed via those 2 contracts. In addition to these clients the service reference also exposes the types involved in the operations like (type 1, type 2 etc.) this is what I need. However when i try to add a service reference to the same endpoing in another console application or class library only Type 1, Type 2 etc. are exposed and not ISvc1Client and ISvc2Client because of which I cannot generate a proxy to access the operations I need. I am unable to determine why the service reference gets properly generated in one class library but not in the other or the test console app.
I'd faced similar issue this is due to type mismatch. Because of which I was not able to generate the client in the test project. We maintain different versions of contracts, while creating new version I'd introduced type mismatch error. Following was the code scenario in my case.
Version 1 Contract
Version 2 Contract
I've resolved this issue using svcutil command line utility. Command
I got the below error message
I changed the namespace from version 1 to version 2 and I was able to generate service reference in test project.
Make use of svcutil this will help to resolve this issue.