Home > 2010 Fall DPS907 > DPS907 WSA500 Lab 2 (Due Wed Oct 13)

DPS907 WSA500 Lab 2 (Due Wed Oct 13)

September 29, 2010 Leave a comment Go to comments

Lab 2 enables you to get experience creating a WCF Data Services project. It is due on (new due date) Wednesday, October 13.
.

 

DPS907 WSA500 Lab 2 – due Wed Oct 13

Assigned: During Week 4

Due date: Wednesday, October 13, at 9:50am ET

Grade value: 3% of your final course grade

Grading method: The following will be checked:

  • Your “labs/lab2.aspx” page
  • Correct interactive operation of the page’s logic
  • Implementation of the specifications
  • Code writing quality, including commenting

.

Objective(s)

Create a WCF Data Services project

Create a web forms page that consumes the endpoint above

.

Introduction to the problem that you will solve

A WCF Data Service is needed that will expose data in a RESTful manner. The data will come from your copy of the Northwind database.

.

Specifications

In your warp server database, you need a copy of the Northwind database.

A link to the script that copies the Northwind tables into your database is at the bottom of this post.

Then, create a local file system web site for this Lab 2.

The current configuration of the warp server cluster does not fully support WCF Data Services in .NET Framework 4. We are working on a solution.

You will then create an Entity Framework data model, in accordance with best practices.

Next, you will create a WCF Data Service, named “lab2.svc”.

Enable read and write access to your Employees and Shippers entities.

Then, in your “labs” folder, create lab2.aspx in your labs folder. (The purpose of this lab2.aspx page is to provide a controlled user interface for your WCF Data Service.)

.

General guidance

After this lab was originally posted, a new and detailed blog post was created:

Consume a WCF Data Service using XML

The details in that post will help you with this Lab 2. It provides a comprehensive walkthrough for all the coding requirements.

.

Guidance about the lab2.aspx page

As you have learned, a highly functional WCF Data Service can be created with a reasonable amount of effort. However, we still need a client to test the service. Your lab2.aspx will do that.

Create a user interface that will enable the user to do the following:

  1. Enter a URI (probably in a text box)
  2. Select an HTTP method (probably using one of the list controls)
  3. Select the data/message format (probably using one of the list controls)
  4. Enter data for PUT and POST methods (probably in a textbox)
  5. Submit the request (probably using a button)
  6. Display the results (probably in a multi-line text box)

The request/response operations will be coded using a System.Net.WebRequest object. You will have to learn how this object works. You have already seen an example of its usage in this example from a week or so ago.

You must support the following operations:

GET – xml, json, and plain text when it makes sense

DELETE

POST – xml only

PUT (for both an entry, and a property) – xml only (although it’s easy to support plain text)

Note – you do not have to support PUT or POST with JSON.

Here are a few screen shots of your professor’s working example.

.

GET nwCategories

.

DELETE a specific entry

.

POST a new entry

.

PUT showing an update of a full entry

.

PUT showing an update of a property

.

Reminder about academic honesty

You must comply with the College’s academic honesty policy. Although you may interact and collaborate with others, submit your own work.

.

Submitting your work

New – zip and email the finished folder to me.

When you do a lab exercise, you are creating it online on the warp server (or, you are creating it elsewhere, and then copying it to the warp server). Therefore, you do NOT have to submit paperwork to your professor. Just do the lab, and your professor will find it (as long as it is in the right location!).

Reminder: The URL to your Lab 2 should be in the following format (replace “dps907_103a01” with your account name):

http://warp.senecac.on.ca/dps907_103a01/labs/lab2.aspx

.

~~~~~~~~~~~~~~~~~~~~~~~~~~~

Script to copy the Northwind tables – copy the query text (from the following Word 2007 document) into a new query window in SQL Server Management Studio, and then run it:

Copy Northwind Tables

.


Advertisements
Categories: 2010 Fall DPS907
  1. Elton
    October 10, 2010 at 9:02 pm

    I’m getting errors for the PUT/POST method,
    with a URI such as
    http://localhost:1586/Lab2/lab2.svc/nwCategories(10)

    “The remote server returned an error: (400) Bad Request.”
    Content-Type:application/atom+xml,application/xml
    Is there something I could be missing in web.config, etc to allow the PUT/POST to work?

    • petermcintyre
      October 11, 2010 at 4:37 pm

      You will not need any Web.config settings to make this work.

      I created a new and detailed blog post as a companion to Lab 2. It is also a standalone post for anyone who needs to learn how to “Consume a WCF Data Service using XML“.

      Your service must allow adds and updates, you must set the right header values, and send the right data. Check the xml you are sending, and compare it to the guidance in the new blog post. You may find that you are sending too much, and it’s causing an exception.

  2. Elton
    October 11, 2010 at 4:59 pm

    Thank-you for your clarification. I was able to resolve those 400 bad request errors by these changes.

    You were right, I was sending too much. By taking the response of a GET of http://localhost:1586/Lab2/lab2.svc/nwCategories(25) and removing most elements to just have the a)xml declaration, b)entry,c)content,and d)m:properties, and using that as input data for a PUT, I was able to get that working, and very similar with a POST .

    I also had a content type of “application/atom+xml,application/xml” instead of
    “application/atom+xml”.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: