Reputation: 431
I would like some advice on how to approach a programming task.
I am creating a website that collects data over time (users enter data) and then it displays spatial maps (upon request) created from that data.
Each time a user enters data I am using a webservice to store data into a SQL database (using ef4).
The design decision I have now is when a client requests a map/image, how should I return the image to them.
Should I:
I was hoping to do (2), but I am unsure of where to save the image and what implications that has when trying to expose it.
The WebService and Asp.Net application will most likely run from the same server if that helps at all.
Any advice on how to proceed would be most appreciated, particularly details like where it is safe to save from a WCF service etc
Thanks.
(I am using a service because there will be other clients other than the Asp.Net app that request the data).
Upvotes: 0
Views: 1260
Reputation: 49225
It would largely depend on what kind of API your clients can consume? If they need SOAP API then you have to use either WCF services or asmx to provide the images. However, the better alternative is clearly a HTTP API i.e a unique URL is provided for accessing the particular image - you may use REST style URL or may choose to accept parameters via query string. Essentially, URL should have all information needed to retrieve image from the database.
Now, you may directly choose REST based WCF services to serve these images or may put ASP.NET based HTTP Handler (as facade) over WCF services to serve them. If you are going to use WCF and image sizes are large then do consider streaming. I will prefer a putting a facade as it helps you to move some important concerns such as caching and streaming outside WCF world. So in such scenario, WCF services will use the best end-point possible to deliver image data from data store. Your facade HTTP handler would translate the url in necessary WCF service call, get the image data, cache into the file system and serve to client. The subsequent requests would be served via this cached image. Because you are using URLs and get requests, images would also cache on client side (you can control this by emitting explicit headers in your facade handler). Typically, requests to fetch the image would be substantially high than requests to update data - by serving get requests via different handler, you may scale it independently of WCF services.
Upvotes: 1
Reputation: 19797
I would use an HTTP handler to consume your WCF service based on some parameters. I use something similar to retrieve an image stored as a BLOB in a database and set some default sizes on the image.
The HTTP handler would be called from an image tag on the asp.net page.
This article has more info on http handlers
Upvotes: 0