PHP
  Home arrow PHP arrow Page 3 - Developing SOAP Clients using PHP
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
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

Developing SOAP Clients using PHP
By: Mamun Zaman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 7
    2007-08-14


    Table of Contents:
  • Developing SOAP Clients using PHP
  • Debugging NuSOAP
  • PEAR::SOAP
  • PHP's SOAP Extension

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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


    Developing SOAP Clients using PHP - PEAR::SOAP
    ( Page 3 of 4 )

    Let us assume that our web service is described at http://localhost/add.wsdl. To create a PEAR::SOAP client you can use the example below.

    <?php
    require_once 'SOAP/Client.php';

    $url = 'http://localhost/add.wsdl';
    $WSDL = new SOAP_WSDL($url);
    $client = $WSDL->getProxy();

    $params = array(
        'a' => 1,
        'b' => 6
    );

    $result = $client->add($params);

    print_r($result);
    ?>

    The first line includes PEAR::SOAP's client classes. If you have trouble loading the files, make sure your include_path contains the folder where PEAR files are stored. You first instantiate a new SOAP_WSDL object by passing $url, the location of our web service's WSDL file, to the constructor. Next, SOAP_WSDL::getProxy() is called, and it returns a client object, $client. This is what you use to make SOAP requests. Now make the actual add() query. This method takes a few arguments, which are passed in as an (associative) array. Parameter names are the array's keys, and their values are array values.

    PEAR:SOAP converts your PHP data structures to a SOAP message written in XML and sends an HTTP request to the web server. PEAR::SOAP listens for the server's response and parses the XML into a PHP object, which is then returned by our method and stored in $result. Then we print the result value.

    Installing PEAR::SOAP is very easy if you have a pear manager installed in your server. Use the following shell command for installing PEAR::SOAP.

    pear install SOAP

    This will download, unzip, and install PEAR::SOAP. Depending on which packages you've yet to install, you may get a dependency error. First install the dependent packages and then install SOAP.



     
     
    >>> More PHP Articles          >>> More By Mamun Zaman
     

       

    PHP ARTICLES

    - Using Directory Iterators to Build Loader Ap...
    - Using the spl_autoload() Functions to Build ...
    - Working Out of the Object Context to Build L...
    - Using the _autoload() Magic Function to Buil...
    - The Destruct Magic Function in PHP 5
    - The Autoload Magic Function in PHP 5
    - Developing a Recursive Loading Class for Loa...
    - The Sleep and Wakeup Magic Functions in PHP 5
    - Using the Clone Magic Function in PHP 5
    - Including Files Recursively with Loader Appl...
    - The Call Magic Function in PHP 5
    - Designing a Captcha System with PHP and MySQL
    - Using Static Methods to Build Loader Apps in...
    - The Isset and Unset Magic Functions in PHP 5
    - Advanced PHP Form Input Validation to Check ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT