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  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
Moblin 
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: 4 stars4 stars4 stars4 stars4 stars / 4
    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:
      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

    Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!

    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.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Something not pointed out in this article, is that PHP5's SOAP extension is written...
     

       

    PHP ARTICLES

    - Handling Attachments in MIME Email with PHP
    - Completing the Project Management Application
    - Sending MIME Email with PHP
    - Handling Files for a Project Management Appl...
    - Viewing and Editing Tasks for a Project Mana...
    - More on Private Methods with PHP 5 Member Vi...
    - Adding Tasks to a Project Management Applica...
    - Utilizing Private Methods with PHP 5 and Mem...
    - Making Changes in a Project Management Appli...
    - Defining Public and Protected Methods with M...
    - HTML for a Project Management Application
    - Using Subclasses and Accessors with Member V...
    - Implementing Internet Protocols with PHP
    - Project Management: The Application
    - Working with Private Properties to Protect P...




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway