Solved

How does WCF resolve which concrete class is used when its service is called?

Posted on 2014-03-06
3
658 Views
Last Modified: 2014-03-07
I began my WCF web service with the standard Service.cs and IService.cs.  I have since made enhancements to the individual methods (OperationContracts) in a new MyService.cs file that also inherits from IService.cs.

I looked through the App.Config and found that the "contract" being referenced is the interface class but see no code, yet, that choses which concrete implementation class should be used when its called.

Does ,NET WCF always call the use the class that is the same name as the interfaces(minus the "I")?
0
Comment
Question by:Bruce
3 Comments
 
LVL 25

Assisted Solution

by:apeter
apeter earned 250 total points
ID: 39912016
No it is not always just the minus. You can have any name for your concrete class.

You can use a concrete class as service contract but below are the benefits you get when using interfaces. All your .svc file markup has attribute "Service" which points to the class implements the service. So when you use the address to create proxy class using "add reference" or  client channel factory, run time knows which class to invoke.


•Service contract interfaces can extend any number of other service contract interfaces.
• A single class can implement any number of service contracts by implementing those service contract interfaces.
• You can modify the implementation of a service contract by changing the interface implementation, while the service contract remains the same.
• You can version your service by implementing the old interface and the new one. Old clients connect to the original version, while newer clients can connect to the newer version.
0
 
LVL 16

Accepted Solution

by:
SriVaddadi earned 250 total points
ID: 39912152
In short, It is resolved from the fully qualified service name specified in the configuration that is implementing the service contract specified in the configuration.

You do not need to use the same name but what ever the name you use, your service configuration should be updated accordingly.
0
 
LVL 1

Author Closing Comment

by:Bruce
ID: 39912666
Thank you!!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question