Miscellaneous
  Home arrow Miscellaneous arrow Page 6 - Using SOAP with PHP
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Dedicated Servers  
Download TestComplete 
JMSL Numerical Library 
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? 
MISCELLANEOUS

Using SOAP with PHP
By: Matt Wade
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 22
    2004-06-22

    Table of Contents:
  • Using SOAP with PHP
  • Definitions
  • Define Our Goal
  • Create a SOAP server
  • The WSDL Document
  • Creating a SOAP Client
  • 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


    Using SOAP with PHP - Creating a SOAP Client


    (Page 6 of 7 )

    Creating a SOAP Client to access our Server with is just as simple as creating the Server was. Understand though that the Client does not necessarily need to be a PHP Client. The SOAP Server we just created can be connected to by any type of Client, whether that be Java, C#, C++, etc.

    To create the SOAP Client, all we need to do are three things.

    First, include the NuSOAP library. This is done just as it was for the Server.

    require_once('nusoap.php');

    Secondly, we need to instantiate the soapclient class. We pass in the URL of the SOAP Server we are dealing with.

    $c = new soapclient('http://localhost/stockserver.php');

    Last make a call to the Web Service. The one caveat is that the parameters to the Web Service must be encapsulated in an array in which the keys are the names defined for the service. You will see that I have an array key named 'symbol' because that is the name of the input parameter of my function. If you remember how we specified the input parameters when we registered the function with the server, you will see that this is very similar.

    $stockprice = $c->call('getStockQuote',
                  array('symbol' => 'ABC'));

    Now, here is the completed Client script, which I have saved in a file named stockclient.php.

    <?php
    require_once('nusoap.php');

    $c = new soapclient('http://localhost/stockserver.php');

    $stockprice $c->call('getStockQuote',
                  array(
    'symbol' => 'ABC'));

    echo 
    "The stock price for 'ABC' is $stockprice.";

    ?>
    ?>

    There it is. It really is that simple.

    More Miscellaneous Articles
    More By Matt Wade


       · Apparently, I live in a cave, but I did not know exactly what SOAP did prior to...
       · SOAP (and XML-RPC) are for doing remote procedure calls. Effectively, you call a...
       · Exactly. Pass off the values and get back values, but the function doing the actual...
       · Hello,this tutorial is very interesting and gives a good quickstart about SOAP...
       · Great tutorial Matt, the one thing I would recommend it a link to where a person...
       · Or I could follow along better :) Thanks for this.Laura
       · Not getting a value back from the server?Did you remember to change the...
       · I too am not getting a response for $stockprice.this is the $c-&gt;response...
       · I'm just intrested to know... can you view your WSDL from the server page?I had...
       · Hello,Im getting this error msg,Im using PHP5.Can anyone help me...
       · Hello,Im getting this error msg,Im using PHP5.Can anyone help me...
       · how to send parameter with more than one parameter...
       · yes that article unfortunatly don't give real example of real life of XML and SOAP...
       · hiya I am trying to get this soap example working to provide a est bed for a soap...
       · I think the problem may be with php5 soap class you will need to redefine the class...
       · i looked @ it and found if u change it to $c = new nusoap_client it will...
     

    MISCELLANEOUS ARTICLES

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP






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