PHP
  Home arrow PHP arrow Page 3 - Building XML Web Services with PHP NuSOAP
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Building XML Web Services with PHP NuSOAP
By: Ahm Asaduzzaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 57
    2003-02-06

    Table of Contents:
  • Building XML Web Services with PHP NuSOAP
  • What are Web Services?
  • Walkthrough Example 1
  • Walkthrough Example 2
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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/

    <?php
    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

    More PHP Articles
    More By Ahm Asaduzzaman


     

    PHP ARTICLES

    - 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
    - PHP Frontend to ImageMagick
    - Using PEAR's mimeDecode Module
    - Incoming Mail and PHP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek