I have a WCF service and I want to expose it as both a RESTfull service and as a SOAP service. Anyone has done something like this before?
We must define the behavior configuration to REST endpoint
and also to a service
After the behaviors, next step is the bindings. For example basicHttpBinding to SOAP endpoint and webHttpBinding to REST.
Finally we must define the 2 endpoint in the service definition. Attention for the address="" of endpoint, where to REST service is not necessary nothing.
In Interface of the service we define the operation with its attributes.
namespace ComposerWcf.Interface
{
[ServiceContract]
public interface IComposerService
{
[OperationContract]
[WebInvoke(Method = "GET", UriTemplate = "/autenticationInfo/{app_id}/{access_token}", ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
Task autenticationInfo(string app_id, string access_token);
}
}
Joining all parties, this will be our WCF system.serviceModel definition.
To test the both endpoint, we can use WCFClient to SOAP and PostMan to REST.