R – Exposing data from web server to other applications


www.whatpub.org is an ASP.NET v2 web application written by myself in VB.NET. It's hosted currently at www.webhost4life.com – cheap, lots of features but not exactly fast but that's an aside. The database for the pubs is held in a SQL 2005 database. There are two basic parts to the system. The front end "Search for pubs and display guide" and backend "administatration and management application" called HOPS. Pretty much run of the mill ASP.NET web app.

However, there is a new requirement. One of the CAMRA branches would like to use HOPS and whilst they don't mind the entries been accessible through www.whatpub.org, they also want to brand/style a static list of the pubs on their own website.

At the moment, their guide is a series of static web pages which have to be manually edited by the webmaster. Not ideal…

The obvious solution is for them to do something similar to what www.whatpub.org does already – either generate the pages on the fly when requested or do write a routine to generate the static HTML pages triggered by a change to the pub record. This would require PHP or ASP.NET programming – that's given.

However (and to finally get to the reason for my post), what's the best way to expose the data in the HOPS database to another application running on the different web server?

WebHost4Life do expose the SQL database on the internet but that doesn't feel quite right and maybe a bit dangerous. Also, might not stay with webhost4life and another provider might not expose the SQL server on the internet.

I've read a lot about web services. I like the idea of this one as it means I could write an intermediate layer that can keep the exposed interface consistent even if I decided to change the underlying database structure (within limits).

I've also used HTTP POST requests which return XML document which is another option.

Where does SOAP fit into all of this?

All advise gratefully received!

Cheers, Rob.

Best Solution

I think your best choice would be exposing your HOPS data using an ASP.NET web service. Your CAMRA partner could access the web service however best they see fit. For example, they could use JQuery to call your web service and work with the data in JSON format (an alternative data format that works well in JavaScript, instead of XML). As a warning, this article is really helpful in resolving common issues when calling an ASP.NET web service using JQuery and possibly other JavaScript frameworks.


Here is some sample JQuery code for calling an ASP.NET web service:

type: "POST",
contentType: "application/json",
beforeSend: function(x) {
url: "/services/MyService.asmx/GetRandomPubName",
error: function (XMLHttpRequest, textStatus, errorThrown) {
    // handle your error here
dataType: "json",
data: {},
success: function(msg) {
    // handle the successful web service call
    $('.responseDiv').html('Random Pub Name found in the database: '+msg.PubName);


Related Question