Home arrow PHP arrow Page 3 - Building XML Web Services with PHP NuSOAP

Building XML Web Services with PHP NuSOAP

In this article, Ahm shows us how to build XML Web Services using PHP NuSOAP, as an alternative to Microsoft .NET or Sun J2EE.

Author Info:
By: Ahm Asaduzzaman
Rating: 5 stars5 stars5 stars5 stars5 stars / 78
February 06, 2003
  1. · Building XML Web Services with PHP NuSOAP
  2. · What are Web Services?
  3. · Walkthrough Example 1
  4. · Walkthrough Example 2
  5. · Conclusion

print this article

Building XML Web Services with PHP NuSOAP - Walkthrough Example 1
(Page 3 of 5 )

The installation of NuSOAP is a straightforward process. Download the files and extract the file nusoap.php from the zip. For easy access, copy the classes to a location in your include path, or into the directory (say, http://yourServer.com/nusoap/) in which you will be using the classes. Letís develop a simple SOAP server with NuSOAP toolkit that will provide update information (whether a new update is released) of your software product, which is installed in the customerís computers.

Listing: cvs.php
Create a file (in this example, cvs.php) and copy it to location http://yourServer.com/nusoap/

require_once('nusoap.php'); // include the NuSOAP classes
$s = new soap_server; // instantiate the server object, provided by soap_server classes
$s->register('cvs'); /* to allow our function to be called remotely, we must register it with the server object. If this is not done server will generate a fault indicating that the service is not available if a client accesses the service. In the absence of such a registration process, any PHP functions would be remotely available, which would present a serious security risk. */
function cvs ($StrBuild){ /* Now define our simple function that we are exposing as service. Notice that we first check to make sure a string (version info) was passed. If the parameter is not a string, we use the soap_fault class to return an error to the client. */
// Optionally catch an error and return a fault
if($StrBuild == ''){
return new soap_fault('Client','','Must supply a valid build string.');
if ($StrBuild < "200212") { // If customer is using an older version of the product
return "A new version of this product is available now for download, please visit http://www.wordware.com/education";
if ($StrBuild =="200212") {
return "Update Not Necessary. Thank you for using our product.";
$s->service($HTTP_RAW_POST_DATA); /* The final step is to pass any incoming posted data to the SOAP serverís service method. The method processes the incoming request and calls the appropriate function (in our case cvs ()). It will then formulate the response. */

Now how your product will use this service, which will automatically notify your customer if a new version of your application is available. For simplicity sake we will design the following dialog with VB. You can download the project file. You will find enough commentary with code, which describes how to build SOAP envelope and parsing XML document with Microsoft XML parser.

Figure 2.1
Figure 2.1

Figure 2.2
Figure 2.2

blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials