I recently converted a WCF SOAP service into REST/JSON service. As detailed in the response here, the Add Service Reference feature of Visual Studio is incapable of generating code for a JSON service. The linked article in that question's answer alludes to the possibility of having a WCF exposed as both REST and SOAP to solve the issue, but it doesn't give any details how to do so.
Does anyone know if this is possible and if so, how to set it up?
There's always the alternative of writing a code generator myself, which reads the WSDL for the WCF REST service and generates C# classes, but it seems like there should be an easier solution than this.
For reference, My web.config:
<system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="RestBehavior"> <webHttp /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="GetBehavior" > <serviceMetadata httpGetEnabled="true" /> <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <webHttpBinding> <binding name="WebHttpBinding"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="None" /> </security> </binding> </webHttpBinding> </bindings> <services> <service name="Service" behaviorConfiguration="GetBehavior"> <endpoint address="" binding="webHttpBinding" behaviorConfiguration="RestBehavior" contract="IService" bindingConfiguration="WebHttpBinding"> </endpoint> </service> </services> </system.serviceModel> My service methods all have the following attribute:
[WebInvoke(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]