5-2-CRUD-WCF-RESTful - CRUD Operations using WCF RESTful...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CRUD Operations using WCF RESTful Service – Part 1 REST (Representational State Transfer) is basically an architectural style that is based on the same principles as that of “Web”. In this WCF Service tutorial we are going to see these web principles in action. We will be using standard HTTP verbs for CRUD (Create, Retrieve, Update, Delete) operations, HTTP Content-Types etc. In part-1 of this article, we will build a RESTful web service using WCF while in second part, we will be consuming the web service using jQuery. Let’s start by creating a WCF Service Application Project using Visual Studio. For the purpose of this implementation, we are using Visual Studio 2013 . Open Visual Studio 2013, From File -> New Project -> WCF Service Application . Name it SimpleRESTServiceCRUD . Before creating WCF REST Service , let’s prepare object that represents data in our application i.e. DataContract class. Right click on newly created project in Visual Studio 2013 and go to Add -> Class and name it as “ Books.cs ”. Following is the code for our DataContract class i.e. “Book”. Don’t forget to add System.ServiceModel and System.Runtime.Serialization as mentioned above. Also note that we have created WCF DataContract class “Book” but the file name is “Books.cs”. Although it doesn’t make any difference but just clarifying as we will be adding below BookRepository to same physical file (Books.cs). For the purpose of simplicity, we are not going to write code for interacting with database. Instead we will separate code for actual CRUD operations using repository design pattern . Benefit of using repository pattern approach is that we can easily replace the implementation with actual database interaction code according to our own need. We will create an interface “ IBookRepository ” and implement class “ BookRepository ” for the interface as in the file BooksCode.txt . As we are going to perform CRUD operations using RESTful service, we must know that how these actions map to standard HTTP verbs. Method Action GET Getting a specific representation of a resource. In our case, get all books or get a book by a specific ID are relevant actions. PUT Create/Update a resource. Add a new book or update an existing book. DELETE Delete a resource. Delete an existing book.
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '17
  • Lina A.Nemri
  • Representational State Transfer, Hypertext Transfer Protocol, wcf service, WCF RESTful, wcf restful service

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern