DPS907 WSA500 Assignment 6 – alternative

Alternative Assignment 6.

Warning / notice:

This is a challenging assignment. It is harder than Assignment 6.

You will be researching and implementing a partial or full solution for one of the tasks/scenarios below. It is possible that you may not be able to fully/successfully solve the task. (That’s OK – if you make substantial progress, then that will probably be good enough to earn a good grade.)

You should budget no more than about four to six hours total on this.

Read/skim all of this document before you begin work.

 

Introduction to the alternative assignment

Recently, we identified two areas of improvement in our design-and-code approach to web services:

1. We may want to have a simpler and more robust way to generate a hypermedia representation.

2. It would be nice to automatically generate “templates” for data-sending operations (POST, PUT, commands).

If you want to attempt to solve one of these, that would be welcomed. A solution would be published for other students to use, and your professor would add it to the inventory of code examples and best practices. If you wished, you would receive credit and a shout-out, either this term or in future terms (your choice).

Choose only one scenario/task below. You do not have to do both.

 

Due date, etc.

Same due date as Assignment 6 – Wednesday, October 19, at 11:00pm ET. Same submissions procedure. When you submit, add a comment/message that says that you attempted the

 

Scenario / task 1

In a recent class/session, we identified a few problems with the current way of generating a hypermedia representation. The work is done partly in the controller, and partly in a factory class. It’s a bit brittle, and puts the onus on the programmer to do more in the controller.

It would be nice to experiment with a media type formatter, which would handle a new content type. For example, if a user sent an “accept” header in the request, with a value of “application/json+h”, the media type formatter would handle that response. It would take the object graph that’s returned by the controller method, and transform it into a hypermedia representation.

At this point, we do not know what kind of media type formatter to base our work on. The base class has several subclasses to choose from. The …BaseJson… class may be suitable, maybe not. In any case, it should support writing only, and would probably do something like this:

  1. Fetch request URI
  2. Make hypermedia representation
  3. Return using the base JSON serializer

One of the pieces of data that you’ll need is the request URI. Study the code in the link factory class to see how it’s used to create link relations. How do you get that info in the media type formatter? By using the GetPerRequestFormatterInstance() method.

Good luck. Questions? Ask, and your professor will attempt to answer and guide you.

 

Scenario / task 2

In a recent class session, we determined that it would be nice to send information to users/requestors that would tell them what data to send in a POST, PUT, or command request. We have a manual solution for “add new” (POST), with a “template”.

The API Explorer service (GlobalConfiguration.Configuration.Services.GetApiExplorer()) knows all about your controller methods, and your resource models.

It would be nice to somehow auto-generate resource model templates and return them to users/requestors, on demand. Try to figure out to get access to the data that is displayed on the Web API Help Page views that show resource models.

Maybe start with the idea that this should be in a service layer class, with instance or static methods, that would do the work. It could be called on demand. (It is also possible to envision it being called by a scenario / task 1 solution above, or embedded in that solution.)

Good luck. Questions? Ask, and your professor will attempt to answer and guide you.

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

%d bloggers like this: