Problem Statement:
We have built MVC 4 application using WCF Service library (not WCF Service Application with svc file). All of the MVC CRUD operations we are doing through WCF SOAP Service library.Everything is working fine.Now suddenly client has changed requirement and asking us to convert WCF SOAP to REST.
I went through many URL's for converting WCF SOAP to REST.In all the URL's they have mentioned converting WCF SOAP Service Application to WCF REST not the WCF SOAP Service library to WCF REST.
My question is can we convert WCF Service library in SOAP to REST.??Is Conversion is same for both WCF Service library and WCF Service Application.??If possible does it impact too much,in changing the existing code??
It would be great if anyone can suggest the better way of converting WCF SOAP to REST in MVC with some URL's and explanation.
Not sure if it helps, but i have done WCF library which is exposed to Soap and REST at the same time. REST exposes XML/JSON and return type depends on input request.
It can be configured via config file, mine looked like this:
<behaviors>
<serviceBehaviors>
<behavior name="BehaviourService">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="BehaviourEndPoint"></behavior>
<behavior name="BehaviourWebHttp">
<webHttp defaultBodyStyle="Wrapped" faultExceptionEnabled="True" automaticFormatSelectionEnabled="True"/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="NameSpace.MyClass" behaviorConfiguration="BehaviourService" >
<!--SoapUI-->
<endpoint name="Name" address ="soap" binding="basicHttpBinding" contract="NameSpace.IMyClass"></endpoint>
<!--Rest-->
<endpoint name="Name" address="" binding="webHttpBinding" behaviorConfiguration="BehaviourWebHttp" contract="NameSpace.IMyClass" ></endpoint>
<!--MEX-->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:89/MyAddress"/>
</baseAddresses>
</host>
</service>
</services>
And service like:
[ServiceContract(Namespace = "http://www.mycompany.com", Name = "MyName")]
[DataContractFormat]
public interface IMyClass
{
[OperationContract]
[WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "MyMethod", Method = "POST")]
bool MyMethod();
}