Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Build a Web service with PHP

Learn how to create integrated Web applications with SOAP

Tyler Anderson (tyleranderson5@yahoo.com), Engineer, Stexar Corp.
Tyler Anderson used to work for DPMG.com, an SEO company, for whom he wrote proprietary SEO software. He graduated with a degree in computer science from Brigham Young University in 2004 and has just graduated with a master of science degree in computer engineering in 2005, also from Brigham Young University. He is currently an engineer for Stexar Corp., based in Beaverton, Ore.

Summary:  In the past few years, new Web services have been popping up all over the Internet. And what better language to build your own Web service in than PHP? With PHP, you have the advantage of a great scripting language with the power to connect to databases, an easy development curve that allows for faster development, and high response times -- thanks to the underlying libraries compiled for performance.

Date:  23 May 2006
Level:  Intermediate

Activity:  105988 views
Comments:  

Before you start

About this tutorial

This tutorial is for PHP programmers that would like to jump on the Web services bandwagon by creating a Web service in PHP. You'll build a Web service by building a SOAP server in PHP. The Web service you will create will be a vehicle lookup service that takes in queries based on make, model, and year. The Web service will then query an internal database and respond appropriately. A Web-based client will also be coded in PHP to communicate and query the SOAP server. It creates a chain of three SOAP servers in PHP. In reality, each of the three servers would be placed in three different physical locations or cities where a chain of car dealerships would coexist. The client would then be hosted at one location where car customers would come and visit, entering search queries to find the vehicles of their dreams. The client routes the query to each of the three SOAP servers, which, in turn, send results back to the client. Upon receiving each response, the client displays the search results to the user for analysis.


System requirements

The following tools are needed to follow along:

Web server
Any operating system and any Web server can be used. Feel free to use Apache V2.X, or IBM's HTTP Server; download from Apache or from IBM.
PHP
Due to the use of PHP data objects, PHP V5.1 or later is required. Be sure to configure with the following option to include support for Derby and the SOAP extensions: --with-pdo-odbc=ibm-db2,/home/db2inst1/sqllib --enable-soap. See Resources for information about configuring Apache or IBM's HTTP Server with PHP.
Database
This tutorial uses Apache Derby, which is open source and lightweight. Also download the IBM DB2® JDBC Universal Driver and the DB2 Run-Time Client. Make sure to set your CLASSPATH appropriately by following the instructions on each page. You can follow the Linux® or Windows® instructions for installing and downloading the DB2 Run-Time Client. See Resources for more information to help you get the configuration right.

IBM Cloudscape may also be used for this tutorial. The internals of it are the same as Derby; however, the DB2 JDBC Universal Driver and other things are packaged into Cloudscape, and it is supported by IBM. Download IBM Cloudscape V10.1 and the DB2 Run-Time Client from IBM.
Java technology
Derby requires Java™ technology. Download from Sun Microsystems or from IBM.

1 of 11 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=111236
TutorialTitle=Build a Web service with PHP
publish-date=05232006
author1-email=tyleranderson5@yahoo.com
author1-email-cc=troy@backstopmedia.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers