I am trying to create a wcf service that returns json. I have some problems with my config file and i also don\'t know how to test it.
You need to add the
to the list of endpoint behaviors. Also, the endpoint needs to use the webHttpBinding
. And finally, to respond to GET
HTTP requests, you need to use the WebGet
attribute (instead of WebInvoke(Method="GET")
.
And the service contract:
[ServiceContract]
public interface IContact
{
[OperationContract]
[WebGet(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, UriTemplate = "contact")]
Contact GetContact(int idContact);
}