Welcome!

AJAX & REA Authors: Andreas Grabner, Carmen Gonzalez, Brad Abrams, Deborah Strickland, John Savageau

Related Topics: AJAX & REA

AJAX & REA: Article

Real-World AJAX Book Preview: Common Server-Side Languages

Real-World AJAX Book Preview: Common Server-Side Languages

This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs for the special pre-order price, click here for more information. Aimed at everyone from enterprise developers to self-taught scripters, Real-World AJAX: Secrets of the Masters is the perfect book for anyone who wants to start developing AJAX applications.

Common Server-Side Languages
The beauty of Web services being platform-agnostic is that we can use any language to develop them - although there are features to watch for when choosing a language. While a Web service can return data in any format, the title of this chapter is "Building AJAX-Friendly Web Services" and our examples will be returning XML or JSON. In keeping with that philosophy we'll look at languages with inherent XML support or a JSON library.

Language Rundown
We'll briefly touch on several of the more common languages that can be used to create Web services and support XML and JSON. Debating the merits of one server-side programming language over the other is as productive as a debate over the best operating system. We'll provide some basic information about several languages, but in the end the decision of which language to use will fall to you.

PHP
There are a number of JSON libraries freely available for PHP:

Zend_Json is part of the Zend Framework, which is currently available as a preview release from http://framework.zend.com/.

JSON-PHP is PHP implementation of JSON.

PHP-JSON is a C implementation of JSON-PHP that can be compiled and installed as a PHP extension. It's significantly faster, but will require root-level privileges on your Web server or a cooperative administrator. It can be downloaded from www.aurore.net/projects/php-json/.

We'll use the XMLRPC extension with our PHP Web services. PHP also has a SOAP extension available. The XMLRPC extension is poorly documented and you may find it easier to use XMLRPCEPI- PHP, which is at http://xmlrpc-epi.sourceforge.net/. More information about XML-RPC can be found at www.xmlrpc.com/. The PHP manual for XMLRPC is located at http://php.net/xmlrpc. The PHP manual for the SOAP extension is online at http://php.net/soap.

Perl
There are several Perl modules for JSON and XML-RPC:

JSON modules can be found at CPAN at http://search.cpan.org/dist/JSON/.

XMLRPC::Lite provides its own XML parser http://search.cpan.org/search?module=XMLRPC::Lite.

RPC::XML requires XML::Parser. http://search.cpan.org/dist/RPC-XML/.

ColdFusion
Jehiah Czebotar has written a JSON library for ColdFusion that can be downloaded from http://jehiah.com/projects/cfjson/.

ColdFusion has native XML and SOAP support as documented at http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000372.htm.

One thing that ColdFusion lacks is a decent XML-RPC parser. Thankfully Roger Benningfield has created one available at http://mxblogspace.journurl.com/users/admin/?mode=article&entry=763. With examples from his original post at http://support.journurl.com/users/admin/index.cfm?mode=article&entry=362.

This content is reprinted from Real-World AJAX: Secrets of the Masters published by SYS-CON Books. To order the entire book now along with companion DVDs, click here to order.

More Stories By Corey Gilmore

Corey Gilmore is the president of CFG Consulting, Inc., specializing in developing rich internet applications with ColdFusion, PHP and Ajax for the Federal government and Fortune 100 clients. He guiltily enjoys designing and implementing low-cost, high performance business continuity plans using VMware ESX server. As the former Director of Information Technology for the United States Senate Democratic Leadership, he designed and implemented a continuity of operations plan to ensure Senate business continuity in the event of a disaster. Corey can be reached at cfgci.com.

More Stories By Jason Blum

Jason Blum is principal engineer with the advanced technologies development team in the United States Senate, Office of the Sergeant at Arms. Formerly the lead administrator of the Senate’s shared Web hosting environment, Jason now designs and manages the implementation of schema and pattern-centric solutions for Senate offices in XML, ColdFusion, Flex, and .NET. He is a Certified Advanced ColdFusion developer with a BA in philosophy, Masters Degrees in philosophy of education and in IT, and an intermediate certification in Hungarian from itk.hu.

More Stories By Phil McCarthy

Philip McCarthy is a UK-based software development consultant
specializing in J2EE and Web technologies. An early adopter of rich
browser-based client development, he has several years' experience of integrating Ajax technologies into enterprise Java frameworks, gained on projects in the financial services, telecoms, and digital media sectors. Philip is also the author of the "Ajax for Java Developers" series for IBM developerWorks, and blogs about software development at chimpen.com.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.