I have taken over development on a .NET WCF project. Among other things, the project contains 3 files:
IApi.cs <=Defining the interfacesJsonApi.svc.cs <=Implementing interface for JSONSoapApi.svc.cs <=Implementing interface for SOAP
The two implementation files are almost identical – at least all the code in the implementation of the methods is identical. I am quite new to WCF programming, but it strikes me as odd, that we need to duplicate the code, just to implement JSON as well as SOAP.
Is there a way to merge this into one implementation and let the framework decide if data is to be transported by SOAP or JSON?
/ Carsten
Defines two endpoints, with the same contract for your service implementation. Defines the first to use SOAP, then the second to use JSon :
Then there will be an endpoint at http://…/yourservice.svc/soap and another at http://…/yourservice.svc/rest
[edit] to answer to your comment, what I said is to replace this section :
by :
One service, with two endpoints