Hello every one.
I have downloaded WCF REST Starter Kit2 and created a Rest Collection Service application using default template it is working well. I tried GET and POST Data this is ok. Now In Code behind page of Service .svc I removed those Default CollectionServiceBase<SampleItem> and ICollectionService<SampleItem> and added my own IPostalContract. Now I am not able to POST DATA it is saying Method Not Allowed but GET is working fine.
[ServiceContract]
public interface IPostContract
{
[OperationContract]
[WebGet(UriTemplate = "post/{id}")]
Post GetPost(string id);
[OperationContract]
[WebGet(UriTemplate = "posts")]
PostCollections GetPosts();
[OperationContract]
[WebInvoke(Method = "Post", UriTemplate = "", BodyStyle = WebMessageBodyStyle.Wrapped , ResponseFormat=WebMessageFormat.Xml)]
PostCollections AddPost(Post post);
}
and I implemented this in codebehind page of Service.svc like this
Markup is this
<%@ ServiceHost Language="C#" Debug="true" Service="Geeks_Lounge_Services.Service" Factory="Microsoft.ServiceModel.Web.WebServiceHost2Factory"%>
[ServiceBehavior(IncludeExceptionDetailInFaults = true, InstanceContextMode = InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Single)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service:IPostContract
{
// TODO: These variables are used by the sample implementation. Remove if needed
public Post GetPost(string id)
{
// TODO: Change the sample implementation here
PostDS ds = new PostDS();
Post p = ds.GetSingle(Convert.ToInt32(id));
return p;
}
public PostCollections GetPosts()
{
// TODO: Change the sample implementation here
PostDS ds = new PostDS();
PostCollections p = ds.GetAll();
return p;
}
public PostCollections AddPost(Post p)
{
PostDS ds = new PostDS();
return ds.AddPost(p);
}
}
Web Config is as it is
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
</configuration>
Please help me where I am making mistake or suggest me if there are any setting I am missing any where
ASP.NET C# new bee...