PHP
  Home arrow PHP arrow Page 4 - 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? 
Google.com  
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 - PHP's SOAP Extension
    ( Page 4 of 4 )

    From PHP version 5.0.4, PHP has a SOAP extension. Using this SOAP Extension supports SOAP client applications with a class called SoapClient, which offers the following main functions:

    • SoapClient->__construct() - Constructs a new SoapClient object.
    • SoapClient->__soapCall() - Calls a SOAP function.
    • SoapClient->__getFunctions() - Returns a list of SOAP functions.
    • SoapClient->__getLastRequestHeaders() - Returns the last SOAP request headers.
    • SoapClient->__getLastRequest() - Returns the last SOAP request.
    • SoapClient->__getLastResponseHeaders() - Returns the last SOAP response headers.
    • SoapClient->__getLastResponse() - Returns the last SOAP response.

    The SoapClient->__construct() constructor creates SoapClient objects in WSDL or non-WSDL mode. This function also has some options like the location and uri options, where location is the URL to request and uri is the target namespace of the SOAP service.

    SoapClient->__getFunctions() allows you to get a list of functions supported by the target node. This function is only valid in WSDL mode. After getting the supported functions, SoapClient->__soapCall() allows you to make an RPC function call on the target SOAP node. Our above client implementation can also be developed using the PHP SOAP extension as shown below.

    <?php
    //Create the SoapClient object
    $client = new SoapClient("http://localhost/add.wsdl");

    //Call the add function of SOAP server
    echo $client->__soapCall("add", array(5, 7));

    ?>

    If we are using WSDL then we can simply call the remote function as local function. The above example will generate same output as below.

    <?php
    //Create the SoapClient object
    $client = new SoapClient("http://localhost/add.wsdl");

    //Call the add function of SOAP server (possible only in WSDL Mode)
    echo $client->add(5, 7);

    ?>

    The PHP SOAP extension is very useful for creating SOAP headers with security credentials. Usernames and passwords can be securely encrypted and then added into SOAP headers using the SOAP extension of PHP.

    In this article I tried to focus on some different implementations of SOAP using PHP. Both PEAR::SOAP and NuSOAP are easy to install and use. But I personally like PHP5's SOAP extension, because it has more features than the other two. But if you are using a PHP version earlier than 5.0.4, you have to use these libraries.



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

       

    PHP ARTICLES

    - Implementing Factory Methods in PHP 5
    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL





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