Hi I am just learning WCF and am trying to create an web service for an existing ASP.NET MVC 4 applicatation.This is what I have done so far:
I have created a WCF Service Application. I defined the data contract and the data members:
[DataContract]
public class BookData
{
[DataMember]
public int Id { get; set; }
[DataMember]
public string Name { get; set; }
[DataMember]
public string Author { get; set; }
[DataMember]
public string Description { get; set; }
[DataMember]
public DateTime PublicationDate { get; set; }
[DataMember]
public int CategoryId { get; set; }
[DataMember]
public decimal Price { get; set; }
[DataMember]
public string BookUrl { get; set; }
}
I have defined the service contract:
[ServiceContract]
public interface IBookService
{
IEnumerable<BookData> GetBooks(int pageNumber, int numberOfBooksOnPage);
IEnumerable<BookData> GetBookByCategory(int categoryId, int pageNumber, int numberOfBooksOnPage);
BookModel GetBookById(int bookId);
int CountBooks();
int CountBooksByCategory(int categoryId);
void AddBook(BookData book);
void UpdateBook(BookData book);
void DeleteBook(int bookId);
}
There was an existing Service1.svc file witch I renamed to BookService.svc. When double clicking this file it is actually a class and I made it inherit from IBookService and implemented all the methods.
When I right click on the BookService.svc and click view in Browser I get this error:
The type 'BookService.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
How can I solve this problem?