Tutorial :Fetching remote database info from a client application



Question:

What would be the preferred method of pulling content from a remote database?

I don't think that I would want to pull directly from the database for a number of reasons. (Such as easily being able to change where it is fetching the info from and a current lack of access from outside the server.)

I've been thinking of using HTTP as a proxy to the database basically just using some PHP to display raw text from the database and then grabbing the page and dumping it to a string for displaying.

I'm not exactly sure how I would go about doing that though. (Sockets?)

Right now I am building it around a blog/news type system. Though the content would expand in the future.


Solution:1

I've got a similar problem at the moment, and the approach I'm taking is to communicate from the client app with a database via a SOAP web service.

The beauty of this approach is that on the client side the networking involved consists of a standard HTTP request. Most platforms these days include an API to perform basic HTTP client functions. You'll then also need an XML or JSON parser to parse the returned SOAP data, but they're also readily available.

As a concrete example, a little about my particular project: It's an iPhone app communicating with an Oracle database. I use a web service to read data from the database and send the data to the app formatted in XML using SOAP. The app can use Apple's NSURLConnection API to perform the necessary HTTP request. The XML is then parsed using the NSXMLParser API.

While the above are pretty iPhone-specific (and are Objective-C based) I think the general message still applies - there's tools out there that will do most of the work for you. I can't think of an example of an HTTP API offhand, but for the XML parsing part of the equation there's Xerces, TinyXML, Expat...

HTH!


Solution:2

You might look at using AJAX (I recommend JSON instead of XML though). This is the technology underlying Google Maps.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »