tags:

views:

65

answers:

1

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.

+1  A: 

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.

http://encosia.com/2008/03/27/using-jquery-to-consume-aspnet-json-web-services/

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

jQuery.ajax({
type: "POST",
contentType: "application/json",
beforeSend: function(x) {
 x.setRequestHeader("Content-Type","application/json");
},
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);
}

});

Jon
Excuse my lack of knowledge on web services (need to read up I think) but I assume they work through standard web protocols like HTTP? So no firewall and port issues? I guess what I'm asking is what's the chances of a web service working on a hosted site?
Rob Nicholson
Yes a web service uses HTTP. An ASP.NET web service (page) would be named Service1.asmx by default when creating a new web service project in Visual Studio. I've always had a hard time finding a really good web services introduction and patterns, but think of your web service as a page/service within your web server service (IIS, Apache, etc).
Jon
It's easier to visualize your "web service" as an .asmx page hosted within IIS just like your normal .aspx page. A web service is called by another application in order to retrieve data in either XML format or JSON format. SOAP and WSDL are just a protocol and a model for describing the web service to the client application, such as what functions are exposed on your web service.
Jon