The value of PHP Web services

Source: Internet
Author: User
Tags web services

As far as I know, Web service is the coolest technology, but it will eventually make everyone feel boring. I don't know how you feel, and every time I attend a lecture on Web services, I always hear many abbreviations, such as rest, XML/RPC, soap, and RSS. Then he began to doze off, dreaming of a place where the tree was covered with Krispy Kreme rolls of sweet flour. When I woke up, I realized that I actually did a lot of Web service work and didn't use all the standard programs that were meaningless. The way I look at Web services is very simple, it's an alternate interface for Web applications that allows other programs to communicate with my applications in a way that the programming language can understand. People communicate with applications through HTML, and applications communicate with my applications through XML, CSV, or other standards.

Figure 1 can better explain this theory:

Figure 1. Traditional Web applications and service-oriented architectures (SOA)

The left side is a traditional Web application. The server communicates with the Web client through HTML. This server can be any technology: Java,. NET, Rails, PHP, Python, or coldfusion. The same Web application is on the right. But instead of providing HTML, it communicates with XML, so it can communicate with dedicated servers such as other applications or RSS readers.

I often hear people talk about fully service-based application servers. This may be good for back-end technology. But for a typical Web application, you always want it to support both HTML and XML interfaces. One advantage of having two interfaces is that it forces you to centralize business logic in one place (possibly a "middle tier"), so both HTML and XML interfaces can communicate with the database and get the same results.

The value of allowing Web applications to communicate with other programs through XML may be obvious to you, but not for me, at least initially. So this article is an example of what you can accomplish by setting up an XML interface in your application. Start with a simple HTML front-end, and then show how to build an XML interface and add a variety of readers (including Ajax, RSS, and Adobe Flex).

Article Application

The test application that is first described is a program that has a list of articles in the database. Listing 1 shows the database.

Listing 1. Articles.sql

DROP TABLE IF EXISTS articles;
CREATE TABLE articles (
id INTEGER NOT NULL AUTO_INCREMENT,
title VARCHAR(255),
author VARCHAR(255),
description TEXT,
PRIMARY KEY( id ) );
INSERT INTO articles VALUES ( null,
'What I like about dogs', 'Megan Herrington',
'Everything that I love about dogs I learned in preschool' );
INSERT INTO articles VALUES ( null,
'Making action movies', 'Jack Herrington',
'How to script, produce and direct Hong Kong action flicks' );
INSERT INTO articles VALUES ( null,
'Super Paper Mario Tips', 'Lori Herrington',
'Everything you need to know to win at Paper Mario' );
INSERT INTO articles VALUES ( null,
'Why I bark', 'Oso Herrington',
'' );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.