[ServiceContract] [ServiceKnownType(typeof(test))] interface ItestbService { [OperationContract] IList<test> RetrieveTestList(); } public class TestWebService : ItestbService { [WebInvoke(UriTemplate = "RetrieveTestList", Method = "GET", ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json)] public IList<test> RetrieveTestList() { return new test().ListOftests(); }
then in separate project I hosted it using the following code using svc file using the following line
<%@ ServiceHost Language="C#" Debug="true" Service="test.WebService.TestWebService" CodeBehind="test.WebService.TestWebService.cs" %>
and this is the web.config
<system.serviceModel> <services> <service name="test.WebService.TestWebService"> <endpoint address="" binding="webHttpBinding" contract="test.WebService.ItestbService" behaviorConfiguration="web"> </endpoint> </service> </services> <behaviors> <endpointBehaviors> <behavior name="web"> <webHttp /> <dataContractSerializer maxItemsInObjectGraph="2147483647"/> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> </behavior> </serviceBehaviors> </behaviors> <bindings> <webHttpBinding> <binding name="defaultRest"> <readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxDepth="64" maxNameTableCharCount="2147483647" /> <security mode="None" /> </binding> </webHttpBinding> </bindings> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel>
put when call in the browser the method it give bad request